Index: client/site_tests/network_DisableInterface/network_DisableInterface.py |
diff --git a/client/site_tests/network_DisableInterface/network_DisableInterface.py b/client/site_tests/network_DisableInterface/network_DisableInterface.py |
index 06f4ac06af1e4b55e7d9bd42f275ecdedcb6963e..32ad0aacc5fa3af5e14b740cfa9ecab5460130d1 100644 |
--- a/client/site_tests/network_DisableInterface/network_DisableInterface.py |
+++ b/client/site_tests/network_DisableInterface/network_DisableInterface.py |
@@ -5,25 +5,40 @@ from autotest_lib.client.common_lib import error |
class network_DisableInterface(test.test): |
version = 1 |
+ |
def run_once(self, iface_name='wlan0'): |
- forced_up = False |
# use the right interface configuration utility |
self._ifconfig = 'ifconfig' |
if iface_name.startswith('hci'): |
self._ifconfig = 'hciconfig' |
+ utils.system('%s %s up' % (self._ifconfig, iface_name)) |
+ |
+ # Allow 'all' keyword - builds a list to test |
+ if iface_name == 'all': |
+ ifaces = utils.system_output('ls /sys/class/net/') |
+ for nic in ifaces.split(): |
+ if nic != 'lo' and not nic.startswith('sit'): |
+ self.test_one_nic(nic) |
+ else: |
+ self.test_one_nic(iface_name) |
+ |
+ |
+ def test_one_nic(self, iface_name='wlan0'): |
+ |
+ forced_up=False |
# bring up the interface if its not already up |
if not self.is_iface_up(iface_name): |
utils.system('%s %s up' % (self._ifconfig, iface_name)) |
if not self.is_iface_up(iface_name): |
- raise error.TestFail('interface failed to come up') |
+ raise error.TestFail('%s failed to come up' % iface_name) |
forced_up = True |
# bring interface down |
utils.system('%s %s down' % (self._ifconfig, iface_name)) |
if self.is_iface_up(iface_name): |
- raise error.TestFail('interface failed to go down') |
+ raise error.TestFail('%s failed to go down' % iface_name) |
# if initial interface state was down, don't bring it back up |
if forced_up: |
@@ -32,7 +47,7 @@ class network_DisableInterface(test.test): |
# bring interface back up |
utils.system('%s %s up' % (self._ifconfig, iface_name)) |
if not self.is_iface_up(iface_name): |
- raise error.TestFail('interface failed to come up') |
+ raise error.TestFail('%s failed to come back up' % iface_name) |
def is_iface_up(self, name): |
@@ -40,7 +55,7 @@ class network_DisableInterface(test.test): |
out = utils.system_output('%s %s' % (self._ifconfig, name)) |
except error.CmdError, e: |
logging.info(e) |
- raise error.TestNAError('test interface not found') |
+ raise error.TestNAError('"ifconfig %s" gave error %d' % (name,out) ) |
match = re.search('UP', out, re.S) |
return match |