Update net_utils to raise a more specific error if loopback fails to
enable due to bonding being enabled.

Signed-off-by: Ryan Kubiak <[email protected]>

--- autotest/client/bin/net/net_utils.py        2011-05-25 17:01:14.000000000 
-0700
+++ autotest/client/bin/net/net_utils.py        2011-08-05 12:26:56.000000000 
-0700
@@ -266,9 +266,11 @@
         # If bonded do not set loopback mode.
         # Try mac loopback first then phy loopback
         # If both fail, raise an error
-        if (bond().is_enabled() or
-            (self._set_loopback('phyint', 'enable') > 0 and
-             self._set_loopback('mac', 'enable') > 0)):
+        if bond().is_enabled():
+            raise error.TestError('Unable to enable loopback while '
+                                  'bonding is enabled.')
+        if (self._set_loopback('phyint', 'enable') > 0 and
+            self._set_loopback('mac', 'enable') > 0):
             raise error.TestError('Unable to enable loopback')
         # Add a 1 second wait for drivers which do not have
         # a synchronous loopback enable
@@ -279,12 +281,10 @@
 
 
     def disable_loopback(self):
-        # If bonded, to not disable loopback.
         # Try mac loopback first then phy loopback
         # If both fail, raise an error
-        if (bond().is_enabled() or
-            (self._set_loopback('phyint', 'disable') > 0 and
-             self._set_loopback('mac', 'disable') > 0)):
+        if (self._set_loopback('phyint', 'disable') > 0 and
+            self._set_loopback('mac', 'disable') > 0):
             raise error.TestError('Unable to disable loopback')
 
 
--- autotest/client/bin/net/net_utils_unittest.py       2011-05-25 
17:01:14.000000000 -0700
+++ autotest/client/bin/net/net_utils_unittest.py       2011-08-05 
12:26:56.000000000 -0700
@@ -205,14 +205,10 @@
         mock_netif.loopback_enabled = True
         mock_netif.was_down = False
 
-        self.god.stub_function(net_utils.bonding, 'is_enabled')
-
         # restore using phyint
         cmd = 'ifconfig %s %s' % (mock_netif._name, mock_netif.orig_ipaddr)
         utils.system.expect_call(cmd)
 
-        net_utils.bonding.is_enabled.expect_call().and_return(False)
-
         cmd = '%s -L %s %s %s' % (mock_netif.ethtool, mock_netif._name,
                                   'phyint', 'disable')
         utils.system.expect_call(cmd, ignore_status=True).and_return(0)
@@ -224,8 +220,6 @@
         cmd = 'ifconfig %s %s' % (mock_netif._name, mock_netif.orig_ipaddr)
         utils.system.expect_call(cmd)
 
-        net_utils.bonding.is_enabled.expect_call().and_return(False)
-
         cmd = '%s -L %s %s %s' % (mock_netif.ethtool, mock_netif._name,
                                   'phyint', 'disable')
         utils.system.expect_call(cmd, ignore_status=True).and_return(1)
@@ -244,8 +238,6 @@
         cmd = 'ifconfig %s %s' % (mock_netif._name, mock_netif.orig_ipaddr)
         utils.system.expect_call(cmd)
 
-        net_utils.bonding.is_enabled.expect_call().and_return(False)
-
         cmd = '%s -L %s %s %s' % (mock_netif.ethtool, mock_netif._name,
                                   'phyint', 'disable')
         utils.system.expect_call(cmd, ignore_status=True).and_return(0)
@@ -720,10 +712,7 @@
         mock_netif.loopback_enabled = True
         mock_netif.was_down = False
 
-        self.god.stub_function(net_utils.bonding, 'is_enabled')
-
         # restore using phyint
-        net_utils.bonding.is_enabled.expect_call().and_return(False)
         cmd = '%s -L %s %s %s' % (mock_netif.ethtool, mock_netif._name,
                                   'phyint', 'disable')
         utils.system.expect_call(cmd, ignore_status=True).and_return(0)
@@ -731,7 +720,6 @@
         self.god.check_playback()
 
         # restore using mac
-        net_utils.bonding.is_enabled.expect_call().and_return(False)
         cmd = '%s -L %s %s %s' % (mock_netif.ethtool, mock_netif._name,
                                   'phyint', 'disable')
         utils.system.expect_call(cmd, ignore_status=True).and_return(1)
@@ -741,18 +729,7 @@
         mock_netif.disable_loopback()
         self.god.check_playback()
 
-        # catch exception on bonding enabled
-        net_utils.bonding.is_enabled.expect_call().and_return(True)
-        try:
-            mock_netif.disable_loopback()
-        except error.TestError:
-            pass
-        else:
-            self.assertEquals(0,1)
-        self.god.check_playback()
-
         # catch exception on phyint and mac failures
-        net_utils.bonding.is_enabled.expect_call().and_return(False)
         cmd = '%s -L %s %s %s' % (mock_netif.ethtool, mock_netif._name,
                                   'phyint', 'disable')
         utils.system.expect_call(cmd, ignore_status=True).and_return(1)
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to