tests: Increase scan_fail coverage
authorJouni Malinen <j@w1.fi>
Sat, 28 May 2016 19:01:32 +0000 (22:01 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 28 May 2016 19:47:31 +0000 (22:47 +0300)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_scan.py

index 5737f4b..9a7e6b1 100644 (file)
@@ -1014,6 +1014,16 @@ def test_scan_fail(dev, apdev):
             raise Exception("Did not see scan failure event")
     dev[0].dump_monitor()
 
+    for i in range(1, 5):
+        with alloc_fail(dev[0], i,
+                        "wpa_scan_clone_params;wpa_supplicant_trigger_scan"):
+            if "OK" not in dev[0].request("SCAN ssid 112233 freq=2412"):
+                raise Exception("SCAN failed")
+            ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED"], timeout=5)
+            if ev is None:
+                raise Exception("Did not see scan failure event")
+        dev[0].dump_monitor()
+
     with alloc_fail(dev[0], 1, "radio_add_work;wpa_supplicant_trigger_scan"):
         if "OK" not in dev[0].request("SCAN freq=2412"):
             raise Exception("SCAN failed")
@@ -1049,6 +1059,24 @@ def test_scan_fail(dev, apdev):
         wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
     dev[0].dump_monitor()
 
+    try:
+        if "OK" not in dev[0].request("SET setband 2G"):
+            raise Exception("SET setband failed")
+        with alloc_fail(dev[0], 1, "=wpa_setband_scan_freqs_list"):
+            # While the frequency list cannot be created due to memory
+            # allocation failure, this scan is expected to be completed without
+            # frequency filtering.
+            if "OK" not in dev[0].request("SCAN"):
+                raise Exception("SCAN failed")
+            wait_fail_trigger(dev[0], "GET_ALLOC_FAIL")
+            dev[0].request("ABORT_SCAN")
+            ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"])
+            if ev is None:
+                raise Exception("Scan did not complete")
+    finally:
+        dev[0].request("SET setband AUTO")
+    dev[0].dump_monitor()
+
     wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
     wpas.interface_add("wlan5")
     wpas.request("SET preassoc_mac_addr 1")