From: Jouni Malinen Date: Sun, 18 Jan 2015 15:13:55 +0000 (+0200) Subject: tests: Close wlan5 control interface monitor more explicitly X-Git-Tag: hostap_2_4~369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a66d2248a006e529e31342be1fb2738587c5bf11;p=thirdparty%2Fhostap.git tests: Close wlan5 control interface monitor more explicitly There were couple of common cases where the control interface for the dynamic wpa_supplicant instance could have been left in attached state until Python ends up cleaning up the instance. This could result in issues if many monitor interface events were queued for that attached socket. Make this less likely to cause issues by explicitly detaching and closing control interfaces before moving to the next test case. Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index 7556abd59..09a3acd4b 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -48,6 +48,7 @@ def reset_devs(dev, apdev): print str(e) ok = False + wpas = None try: wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') ifaces = wpas.global_request("INTERFACES").splitlines() @@ -56,6 +57,8 @@ def reset_devs(dev, apdev): wpas.interface_remove(iface) except Exception, e: pass + if wpas: + wpas.close_ctrl() try: hapd = HostapdGlobal() @@ -455,14 +458,16 @@ def main(): logger.info("Failed to issue TEST-STOP after {} for {}".format(name, d.ifname)) logger.info(e) result = "FAIL" + wpas = None try: - wpas = WpaSupplicant("/tmp/wpas-wlan5") - d.dump_monitor() + wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5") rename_log(args.logdir, 'log5', name, wpas) if not args.no_reset: wpas.remove_ifname() except Exception, e: pass + if wpas: + wpas.close_ctrl() if args.no_reset: print "Leaving devices in current state" else: diff --git a/tests/hwsim/test_wext.py b/tests/hwsim/test_wext.py index 718466041..9fef54b71 100644 --- a/tests/hwsim/test_wext.py +++ b/tests/hwsim/test_wext.py @@ -22,6 +22,7 @@ def get_wext_interface(): try: wpas.interface_add("wlan5", driver="wext") except Exception, e: + wpas.close_ctrl() raise HwsimSkip("WEXT driver support not included in wpa_supplicant") return wpas @@ -59,6 +60,7 @@ def test_wext_wpa_psk(dev, apdev): hapd = hostapd.add_ap(apdev[0]['ifname'], params) testfile = "/sys/kernel/debug/ieee80211/%s/netdev:%s/tkip_mic_test" % (hapd.get_driver_status_field("phyname"), apdev[0]['ifname']) if not os.path.exists(testfile): + wpas.close_ctrl() raise HwsimSkip("tkip_mic_test not supported in mac80211") wpas.connect("wext-wpa-psk", psk="12345678") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 15a86aeb5..ebfec6241 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -33,6 +33,13 @@ class WpaSupplicant: else: self.global_mon = None + def close_ctrl(self): + if self.global_mon: + self.global_mon.detach() + self.global_mon = None + self.global_ctrl = None + self.remove_ifname() + def set_ifname(self, ifname): self.ifname = ifname self.ctrl = wpaspy.Ctrl(os.path.join(wpas_ctrl, ifname))