]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Close wlan5 control interface monitor more explicitly
authorJouni Malinen <j@w1.fi>
Sun, 18 Jan 2015 15:13:55 +0000 (17:13 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 18 Jan 2015 15:13:55 +0000 (17:13 +0200)
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 <j@w1.fi>
tests/hwsim/run-tests.py
tests/hwsim/test_wext.py
tests/hwsim/wpasupplicant.py

index 7556abd59b0d3dd51fd8704374b4e62afa31d8c1..09a3acd4b1ce6b6b492e92f389bef97f65f7d344 100755 (executable)
@@ -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:
index 7184660418bbad9e714122b0d207edef2565fa48..9fef54b71a0c74f23993ad67f47447f968483f14 100644 (file)
@@ -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")
index 15a86aeb59fd925e1d0816f58f18f7d53c25a985..ebfec624196bc2cc6a78d969d37a0f785d26b0dd 100644 (file)
@@ -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))