From 64766a77835ced5063e6ea512ae0f54cf041cd56 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 13 Mar 2019 21:05:15 +0200 Subject: [PATCH] tests: Make TDLS 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 --- tests/hwsim/test_ap_tdls.py | 12 ++++++++---- tests/hwsim/wpasupplicant.py | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/hwsim/test_ap_tdls.py b/tests/hwsim/test_ap_tdls.py index 315b2cc9b..6f6f65a5c 100644 --- a/tests/hwsim/test_ap_tdls.py +++ b/tests/hwsim/test_ap_tdls.py @@ -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) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 8a253c7a6..b447ba6a8 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -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")