tests: Verify behavior during externally triggered scan
authorJouni Malinen <j@w1.fi>
Sat, 4 Jan 2014 08:35:01 +0000 (10:35 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 7 Jan 2014 08:45:10 +0000 (10:45 +0200)
Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/test_scan.py

index ebc62b6..938abda 100644 (file)
@@ -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)