From: Jouni Malinen Date: Wed, 13 Mar 2019 21:32:31 +0000 (+0200) Subject: tests: Make WNM test case scan clearing more robust X-Git-Tag: hostap_2_8~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86db4e63d35a1032ff6bdab8b147dee1753b846f;p=thirdparty%2Fhostap.git tests: Make WNM test case scan clearing more robust 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 --- diff --git a/tests/hwsim/test_wnm.py b/tests/hwsim/test_wnm.py index d1b76f5bd..ea959e76a 100644 --- a/tests/hwsim/test_wnm.py +++ b/tests/hwsim/test_wnm.py @@ -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()