diff --git a/tests/hwsim/test_scan.py b/tests/hwsim/test_scan.py index ebc62b6b2..938abda8d 100644 --- a/tests/hwsim/test_scan.py +++ b/tests/hwsim/test_scan.py @@ -9,16 +9,31 @@ import time import logging logger = logging.getLogger() +import subprocess import hostapd -def check_scan(dev, params): - dev.dump_monitor() +def check_scan(dev, params, other_started=False): + if not other_started: + dev.dump_monitor() id = dev.request("SCAN " + params) if "FAIL" in id: raise Exception("Failed to start scan") id = int(id) + 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") + if "id=" + str(id) in ev: + raise Exception("Own scan id unexpectedly included in completed event") + ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"]) if ev is None: raise Exception("Scan did not start") @@ -86,3 +101,10 @@ def test_scan_only(dev, apdev): check_scan(dev[0], "type=only freq=2412 passive=0 use_id=1") if int(dev[0].get_bss(bssid)['age']) > 1: raise Exception("Unexpectedly old BSS entry") + +def test_scan_external_trigger(dev, apdev): + """Avoid operations during externally triggered scan""" + hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-scan" }) + bssid = apdev[0]['bssid'] + subprocess.call(['sudo', 'iw', dev[0].ifname, 'scan', 'trigger']) + check_scan(dev[0], "use_id=1", other_started=True)