]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make TDLS test case scan clearing more robust
authorJouni Malinen <jouni@codeaurora.org>
Wed, 13 Mar 2019 19:05:15 +0000 (21:05 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 13 Mar 2019 21:33:21 +0000 (23:33 +0200)
There was a race condition on starting the flush_scan_cache() operations
if a scan happened to be in progress when the test case ended since the
ABORT_SCAN success case did not wait for the pending scan operation to
be completed. Wait for the scan completion event in addition to the
disconnection event if the ABORT_SCAN command is accepted.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
tests/hwsim/test_ap_tdls.py
tests/hwsim/wpasupplicant.py

index 315b2cc9b6892503d61515f4f4f6a1573b6f5e0f..6f6f65a5c17ca5025c457df18754126ae5c9c396 100644 (file)
@@ -363,12 +363,16 @@ def tdls_clear_reg(hapd, dev):
     if hapd:
         hapd.request("DISABLE")
     dev[0].request("DISCONNECT")
-    dev[0].request("ABORT_SCAN")
+    res0 = dev[0].request("ABORT_SCAN")
     dev[1].request("DISCONNECT")
-    dev[1].request("ABORT_SCAN")
-    dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
+    res1 = dev[1].request("ABORT_SCAN")
+    for i in range(2 if "OK" in res0 else 1):
+        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
+                           "CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
     dev[0].dump_monitor()
-    dev[1].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
+    for i in range(2 if "OK" in res1 else 1):
+        dev[1].wait_event(["CTRL-EVENT-DISCONNECTED",
+                           "CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
     dev[1].dump_monitor()
     subprocess.call(['iw', 'reg', 'set', '00'])
     dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
index 8a253c7a62dd01a8fd88a98a9eeffc40796406d0..b447ba6a88f9d70c08b9b3f512a1133ea30f6460 100644 (file)
@@ -1062,8 +1062,9 @@ class WpaSupplicant:
             cmd += " passive=1"
         if not no_wait:
             self.dump_monitor()
-        if not "OK" in self.request(cmd):
-            raise Exception("Failed to trigger scan")
+        res = self.request(cmd)
+        if not "OK" in res:
+            raise Exception("Failed to trigger scan: " + str(res))
         if no_wait:
             return
         ev = self.wait_event(["CTRL-EVENT-SCAN-RESULTS",
@@ -1089,6 +1090,7 @@ class WpaSupplicant:
         self.scan(freq=freq, only_new=True)
         res = self.request("SCAN_RESULTS")
         if len(res.splitlines()) > 1:
+            logger.debug("Scan results remaining after first attempt to flush the results:\n" + res)
             self.request("BSS_FLUSH 0")
             self.scan(freq=2422, only_new=True)
             res = self.request("SCAN_RESULTS")