From: Jouni Malinen Date: Mon, 19 Jan 2015 18:12:38 +0000 (+0200) Subject: tests: Error handling for scan trigger failure cases X-Git-Tag: hostap_2_4~354 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dc18e9a2624a522c1b8fb4c269d9d6f9370c526;p=thirdparty%2Fhostap.git tests: Error handling for scan trigger failure cases Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_scan.py b/tests/hwsim/test_scan.py index d5d542285..496199b20 100644 --- a/tests/hwsim/test_scan.py +++ b/tests/hwsim/test_scan.py @@ -734,3 +734,46 @@ def _test_scan_random_mac(dev, apdev, params): break if not found: raise Exception("Fixed OUI random address not seen") + +def test_scan_trigger_failure(dev, apdev): + """Scan trigger to the driver failing""" + hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-scan" }) + bssid = apdev[0]['bssid'] + + if "OK" not in dev[0].request("SET test_failure 1"): + raise Exception("Failed to set test_failure") + + if "OK" not in dev[0].request("SCAN"): + raise Exception("SCAN command failed") + ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED"], timeout=10) + if ev is None: + raise Exception("Did not receive CTRL-EVENT-SCAN-FAILED event") + if "retry=1" in ev: + raise Exception("Unexpected scan retry indicated") + if dev[0].get_status_field('wpa_state') == "SCANNING": + raise Exception("wpa_state SCANNING not cleared") + + id = dev[0].connect("test-scan", key_mgmt="NONE", scan_freq="2412", + only_add_network=True) + dev[0].select_network(id) + ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED"], timeout=10) + if ev is None: + raise Exception("Did not receive CTRL-EVENT-SCAN-FAILED event") + if "retry=1" not in ev: + raise Exception("No scan retry indicated for connection") + if dev[0].get_status_field('wpa_state') == "SCANNING": + raise Exception("wpa_state SCANNING not cleared") + dev[0].request("SET test_failure 0") + dev[0].wait_connected() + + dev[0].request("SET test_failure 1") + if "OK" not in dev[0].request("SCAN"): + raise Exception("SCAN command failed") + ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED"], timeout=10) + if ev is None: + raise Exception("Did not receive CTRL-EVENT-SCAN-FAILED event") + if "retry=1" in ev: + raise Exception("Unexpected scan retry indicated") + if dev[0].get_status_field('wpa_state') != "COMPLETED": + raise Exception("wpa_state COMPLETED not restored") + dev[0].request("SET test_failure 0")