Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging, re | 5 import logging, re, time |
| 6 from autotest_lib.client.common_lib import error | 6 from autotest_lib.client.common_lib import error |
| 7 from autotest_lib.server import site_eap_tls | 7 from autotest_lib.server import site_eap_tls |
| 8 | 8 |
| 9 def isLinuxRouter(router): | 9 def isLinuxRouter(router): |
| 10 router_uname = router.run('uname').stdout | 10 router_uname = router.run('uname').stdout |
| 11 return re.search('Linux', router_uname) | 11 return re.search('Linux', router_uname) |
| 12 | 12 |
| 13 class LinuxRouter(object): | 13 class LinuxRouter(object): |
| 14 """ | 14 """ |
| 15 Linux/mac80211-style WiFi Router support for WiFiTest class. | 15 Linux/mac80211-style WiFi Router support for WiFiTest class. |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 if not self.hostapd['configured']: | 307 if not self.hostapd['configured']: |
| 308 return | 308 return |
| 309 | 309 |
| 310 # Taking down hostapd takes wlan0 and mon.wlan0 down. | 310 # Taking down hostapd takes wlan0 and mon.wlan0 down. |
| 311 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) | 311 self.router.run("pkill hostapd >/dev/null 2>&1", ignore_status=True) |
| 312 # self.router.run("rm -f %s" % self.hostapd['file']) | 312 # self.router.run("rm -f %s" % self.hostapd['file']) |
| 313 | 313 |
| 314 # Tear down the bridge. | 314 # Tear down the bridge. |
| 315 self.router.run("%s link set %s down" % (self.cmd_ip, self.bridgeif), | 315 self.router.run("%s link set %s down" % (self.cmd_ip, self.bridgeif), |
| 316 ignore_status=True) | 316 ignore_status=True) |
| 317 self.router.run("%s delbr %s" % (self.cmd_brctl, self.bridgeif), | 317 |
| 318 ignore_status=True) | 318 # Try a couple times to remove the bridge; hostapd may still be exiting |
| 319 for attempt in range(3): | |
| 320 result = self.router.run("%s delbr %s" % | |
| 321 (self.cmd_brctl, self.bridgeif), | |
| 322 ignore_status=True) | |
| 323 if not result.stderr: | |
| 324 break | |
| 325 time.sleep(1) | |
| 326 else: | |
| 327 raise error.TestFail("Unable to delete bridge %s: %s" % | |
| 328 (self.bridgeif, result.stderr)) | |
|
Sam Leffler
2010/09/01 21:15:07
would it be better to wait on the hostapd pid and/
Paul Stewart
2010/09/01 23:00:47
The "trap" technique just kicks the can down the r
| |
| 329 | |
| 319 | 330 |
| 320 self.hostapd['configured'] = False | 331 self.hostapd['configured'] = False |
| 321 | 332 |
| 322 | 333 |
| 323 def get_ssid(self): | 334 def get_ssid(self): |
| 324 return self.hostapd['conf']['ssid'] | 335 return self.hostapd['conf']['ssid'] |
| OLD | NEW |