aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2017-01-08 10:44:36 (GMT)
committerJouni Malinen <j@w1.fi>2017-01-08 12:44:35 (GMT)
commit479c05b0675384b66dd8ce8f983276cbed44225b (patch)
tree489deaaa5615e646ea05f424b3fd8ecbd016a846 /tests
parent2901bc2725aca3f465856ae5520eb4b4fa6ebe54 (diff)
downloadhostap-479c05b0675384b66dd8ce8f983276cbed44225b.zip
hostap-479c05b0675384b66dd8ce8f983276cbed44225b.tar.gz
hostap-479c05b0675384b66dd8ce8f983276cbed44225b.tar.bz2
tests: Additional bgscan test coverage
Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'tests')
-rw-r--r--tests/hwsim/test_bgscan.py122
1 files changed, 121 insertions, 1 deletions
diff --git a/tests/hwsim/test_bgscan.py b/tests/hwsim/test_bgscan.py
index 0df6da7..06eb126 100644
--- a/tests/hwsim/test_bgscan.py
+++ b/tests/hwsim/test_bgscan.py
@@ -1,5 +1,5 @@
# bgscan tests
-# Copyright (c) 2014, Jouni Malinen <j@w1.fi>
+# Copyright (c) 2014-2017, Jouni Malinen <j@w1.fi>
#
# This software may be distributed under the terms of the BSD license.
# See README for more details.
@@ -10,6 +10,7 @@ logger = logging.getLogger()
import os
import hostapd
+from utils import alloc_fail, fail_test
def test_bgscan_simple(dev, apdev):
"""bgscan_simple"""
@@ -68,6 +69,75 @@ def test_bgscan_simple(dev, apdev):
if ev is None:
raise Exception("dev1 did not complete a scan")
+def test_bgscan_simple_beacon_loss(dev, apdev):
+ """bgscan_simple and beacon loss"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="simple:1:-20:2")
+ hapd.set("ext_mgmt_frame_handling", "1")
+ if "OK" not in hapd.request("STOP_AP"):
+ raise Exception("Failed to stop AP")
+ ev = dev[0].wait_event(["CTRL-EVENT-BEACON-LOSS"], timeout=10)
+ if ev is None:
+ raise Exception("Beacon loss not reported")
+
+def test_bgscan_simple_scan_failure(dev, apdev):
+ """bgscan_simple and scan failure"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="simple:1:-20:2")
+ with alloc_fail(dev[0], 1,
+ "wpa_supplicant_trigger_scan;bgscan_simple_timeout"):
+ ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED"], timeout=10)
+ if ev is None:
+ raise Exception("No scan failure reported")
+ ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
+ if ev is None:
+ raise Exception("Scanning not continued after failure")
+
+def test_bgscan_simple_scanning(dev, apdev):
+ """bgscan_simple and scanning behavior"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="simple:1:-20:2")
+ # Go through seven bgscan_simple_timeout calls for code coverage. This falls
+ # back from short to long scan interval and then reduces short_scan_count
+ # back to zero.
+ for i in range(7):
+ ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
+ if ev is None:
+ raise Exception("Scanning not continued")
+
+def test_bgscan_simple_same_scan_int(dev, apdev):
+ """bgscan_simple and same short/long scan interval"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="simple:1:-20:1")
+ for i in range(2):
+ ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
+ if ev is None:
+ raise Exception("Scanning not continued")
+
+def test_bgscan_simple_oom(dev, apdev):
+ """bgscan_simple OOM"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ with alloc_fail(dev[0], 1, "bgscan_simple_init"):
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="simple:1:-20:2")
+
+def test_bgscan_simple_driver_conf_failure(dev, apdev):
+ """bgscan_simple driver configuration failure"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ with fail_test(dev[0], 1, "bgscan_simple_init"):
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="simple:1:-20:2")
+
def test_bgscan_learn(dev, apdev):
"""bgscan_learn"""
hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
@@ -165,3 +235,53 @@ def test_bgscan_learn(dev, apdev):
os.remove("/tmp/test_bgscan_learn.bgscan")
except:
pass
+
+def test_bgscan_learn_beacon_loss(dev, apdev):
+ """bgscan_simple and beacon loss"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="learn:1:-20:2")
+ hapd.set("ext_mgmt_frame_handling", "1")
+ if "OK" not in hapd.request("STOP_AP"):
+ raise Exception("Failed to stop AP")
+ ev = dev[0].wait_event(["CTRL-EVENT-BEACON-LOSS"], timeout=10)
+ if ev is None:
+ raise Exception("Beacon loss not reported")
+
+def test_bgscan_learn_scan_failure(dev, apdev):
+ """bgscan_learn and scan failure"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="learn:1:-20:2")
+ with alloc_fail(dev[0], 1,
+ "wpa_supplicant_trigger_scan;bgscan_learn_timeout"):
+ ev = dev[0].wait_event(["CTRL-EVENT-SCAN-FAILED"], timeout=10)
+ if ev is None:
+ raise Exception("No scan failure reported")
+ ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], 10)
+ if ev is None:
+ raise Exception("Scanning not continued after failure")
+
+def test_bgscan_learn_oom(dev, apdev):
+ """bgscan_learn OOM"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ with alloc_fail(dev[0], 1, "bgscan_learn_init"):
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="learn:1:-20:2")
+
+def test_bgscan_learn_driver_conf_failure(dev, apdev):
+ """bgscan_learn driver configuration failure"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+
+ with fail_test(dev[0], 1, "bgscan_learn_init"):
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="learn:1:-20:2")
+
+def test_bgscan_unknown_module(dev, apdev):
+ """bgscan init failing due to unknown module"""
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "bgscan" })
+ dev[0].connect("bgscan", key_mgmt="NONE", scan_freq="2412",
+ bgscan="unknown:-20:2")