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 <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-03-13 21:05:15 +02:00 committed by Jouni Malinen
parent 32e4ad4433
commit 64766a7783
2 changed files with 12 additions and 6 deletions

View 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)

View 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")