]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Avoid race condition in scan_external_trigger
authorJouni Malinen <j@w1.fi>
Sun, 10 Dec 2023 14:26:21 +0000 (16:26 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 10 Dec 2023 17:40:18 +0000 (19:40 +0200)
Wait for the externally triggered scan to actually start before issuing
the own scan command to avoid a race condition with UML time-travel.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_scan.py

index 80c6d4cc7ad8102e9762144ff400c6c72309a39b..5cb054d4d22959dfe0047d8562dd1ae310d80374 100644 (file)
@@ -20,6 +20,13 @@ from tshark import run_tshark
 from test_ap_csa import switch_channel, wait_channel_switch
 
 def check_scan(dev, params, other_started=False, test_busy=False):
+    if other_started:
+        ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
+        if ev is None:
+            raise Exception("Other scan did not start")
+        if "id=" in ev:
+            raise Exception("Scan id unexpectedly included in start event")
+
     if not other_started:
         dev.dump_monitor()
     id = dev.request("SCAN " + params)
@@ -32,12 +39,6 @@ def check_scan(dev, params, other_started=False, test_busy=False):
             raise Exception("SCAN command while already scanning not rejected")
 
     if other_started:
-        ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"])
-        if ev is None:
-            raise Exception("Other scan did not start")
-        if "id=" + str(id) in ev:
-            raise Exception("Own scan id unexpectedly included in start event")
-
         ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"])
         if ev is None:
             raise Exception("Other scan did not complete")