]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add terminate support for hostapd/wpa_supplicant
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>
Fri, 4 Mar 2016 09:20:40 +0000 (10:20 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 5 Mar 2016 15:44:51 +0000 (17:44 +0200)
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
tests/hwsim/hostapd.py
tests/hwsim/wpasupplicant.py

index 54bc57824ae0a775e93ec1d140602918f1abc560..1b6e23bcd898721a364dbae1ec33d49484a94869 100644 (file)
@@ -101,6 +101,13 @@ class HostapdGlobal:
         words = line.split(":")
         return int(words[1])
 
+    def terminate(self):
+        self.mon.detach()
+        self.mon.close()
+        self.mon = None
+        self.ctrl.terminate()
+        self.ctrl = None
+
 class Hostapd:
     def __init__(self, ifname, bssidx=0, hostname=None, port=8877):
         self.ifname = ifname
@@ -114,6 +121,14 @@ class Hostapd:
         self.bssid = None
         self.bssidx = bssidx
 
+    def close_ctrl(self):
+        if self.mon is not None:
+            self.mon.detach()
+            self.mon.close()
+            self.mon = None
+            self.ctrl.close()
+            self.ctrl = None
+
     def own_addr(self):
         if self.bssid is None:
             self.bssid = self.get_status_field('bssid[%d]' % self.bssidx)
@@ -365,6 +380,11 @@ def remove_bss(ifname, hostname=None, port=8878):
     hapd_global = HostapdGlobal(hostname=hostname, port=port)
     hapd_global.remove(ifname)
 
+def terminate(hostname=None, port=8878):
+    logger.info("Terminating hostapd")
+    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global.terminate()
+
 def wpa2_params(ssid=None, passphrase=None):
     params = { "wpa": "2",
                "wpa_key_mgmt": "WPA-PSK",
index e5a07e2b57fd257ebd82ad0cdb000fb972b851f2..3978b860fdd107c5b20629b60fa61407b1a55bb0 100644 (file)
@@ -39,6 +39,13 @@ class WpaSupplicant:
         else:
             self.global_mon = None
 
+    def terminate(self):
+        if self.global_mon:
+            self.global_mon.detach()
+            self.global_mon = None
+            self.global_ctrl.terminate()
+            self.global_ctrl = None
+
     def close_ctrl(self):
         if self.global_mon:
             self.global_mon.detach()