]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make WNM test case scan clearing more robust
authorJouni Malinen <jouni@codeaurora.org>
Wed, 13 Mar 2019 21:32:31 +0000 (23:32 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 13 Mar 2019 21:33:41 +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_wnm.py

index d1b76f5bdf17df6b892a8bdf35dcbdfe680ffc9e..ea959e76ad6f4ef044904779b6b74fef6c438a49 100644 (file)
@@ -28,8 +28,10 @@ def clear_regdom_state(dev, hapd, hapd2):
         if hapd2:
             hapd2.request("DISABLE")
         dev[0].request("DISCONNECT")
-        dev[0].request("ABORT_SCAN")
-        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
+        res = dev[0].request("ABORT_SCAN")
+        for i in range(2 if "OK" in res else 1):
+                dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
+                                   "CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
         dev[0].dump_monitor()
         subprocess.call(['iw', 'reg', 'set', '00'])
         dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
@@ -1136,11 +1138,13 @@ def stop_wnm_tm(hapd, dev):
         hapd.request("DISABLE")
         time.sleep(0.1)
     dev[0].request("DISCONNECT")
-    dev[0].request("ABORT_SCAN")
+    res = dev[0].request("ABORT_SCAN")
     try:
         dev[0].wait_disconnected()
     except:
         pass
+    if "OK" in res:
+        dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
     subprocess.call(['iw', 'reg', 'set', '00'])
     wait_regdom_changes(dev[0])
     country = dev[0].get_driver_status_field("country")
@@ -1881,8 +1885,10 @@ def test_wnm_bss_tm_reject(dev, apdev):
         if hapd:
             hapd.request("DISABLE")
         dev[0].request("DISCONNECT")
-        dev[0].request("ABORT_SCAN")
-        dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.5)
+        res = dev[0].request("ABORT_SCAN")
+        for i in range(2 if "OK" in res else 1):
+                dev[0].wait_event(["CTRL-EVENT-DISCONNECTED",
+                                   "CTRL-EVENT-SCAN-RESULTS"], timeout=0.5)
         subprocess.call(['iw', 'reg', 'set', '00'])
         dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=0.5)
         dev[0].flush_scan_cache()