From e766f56643f91cc1071d5a5ed43582cb404ec5a8 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 4 Jan 2014 10:35:01 +0200 Subject: [PATCH] tests: Verify behavior during externally triggered scan Signed-hostap: Jouni Malinen --- tests/hwsim/test_scan.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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)