aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2016-12-10 15:04:08 (GMT)
committerJouni Malinen <j@w1.fi>2016-12-10 15:04:08 (GMT)
commit79124c7ba15b681216cca308951ac6830321171d (patch)
tree7458b3a88ffdd340a7bca87d9f7a7a5895320d7c
parent71ac934530116b26930481d92ccac1e6e91b2898 (diff)
downloadhostap-79124c7ba15b681216cca308951ac6830321171d.zip
hostap-79124c7ba15b681216cca308951ac6830321171d.tar.gz
hostap-79124c7ba15b681216cca308951ac6830321171d.tar.bz2
tests: Scan and only_new=1 multiple times
Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--tests/hwsim/test_scan.py34
-rw-r--r--tests/hwsim/wpasupplicant.py4
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/hwsim/test_scan.py b/tests/hwsim/test_scan.py
index 9a370da..8dbfdcc 100644
--- a/tests/hwsim/test_scan.py
+++ b/tests/hwsim/test_scan.py
@@ -1228,3 +1228,37 @@ def test_scan_chan_switch(dev, apdev):
dev[0].dump_monitor()
run_scan(dev[0], bssid, 2412)
dev[0].dump_monitor()
+
+def test_scan_new_only(dev, apdev):
+ """Scan and only_new=1 multiple times"""
+ try:
+ _test_scan_new_only(dev, apdev)
+ finally:
+ dev[0].set("ignore_old_scan_res", "0")
+def _test_scan_new_only(dev, apdev):
+ dev[0].flush_scan_cache()
+ hapd = hostapd.add_ap(apdev[0], { "ssid": "test-scan" })
+ dev[0].set("ignore_old_scan_res", "1")
+ # Get the BSS added to cfg80211 BSS list
+ bssid = hapd.own_addr()
+ dev[0].scan_for_bss(bssid, freq=2412)
+ bss = dev[0].get_bss(bssid)
+ idx1 = bss['update_idx']
+ dev[0].scan_for_bss(bssid, freq=2412, force_scan=True)
+ dev[0].scan_for_bss(bssid, freq=2412, force_scan=True)
+ bss = dev[0].get_bss(bssid)
+ idx2 = bss['update_idx']
+ if int(idx2) <= int(idx1):
+ raise Exception("Scan result update_idx did not increase")
+ # Disable AP to ensure there are no new scan results after this.
+ hapd.disable()
+
+ # Try to scan multiple times to verify that old scan results do not get
+ # accepted as new.
+ for i in range(10):
+ dev[0].scan(freq=2412)
+ bss = dev[0].get_bss(bssid)
+ if bss:
+ idx = bss['update_idx']
+ if int(idx) > int(idx2):
+ raise Exception("Unexpected update_idx increase")
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index 23cb395..73046e6 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -250,6 +250,10 @@ class WpaSupplicant:
if not self.ping():
logger.info("No PING response from " + self.ifname + " after reset")
+ def set(self, field, value):
+ if not "OK" in self.request("SET " + field + " " + value):
+ raise Exception("Failed to set wpa_supplicant parameter " + field)
+
def add_network(self):
id = self.request("ADD_NETWORK")
if "FAIL" in id: