]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Scan and only_new=1 multiple times
authorJouni Malinen <j@w1.fi>
Sat, 10 Dec 2016 15:04:08 +0000 (17:04 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 10 Dec 2016 15:04:08 +0000 (17:04 +0200)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_scan.py
tests/hwsim/wpasupplicant.py

index 9a370daa143f2e333124e38a2040df42fcffe7ab..8dbfdcc926c9e45cdfe95d019db88fd1860d5437 100644 (file)
@@ -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")
index 23cb395daf84f7c991be3e2279fe8e77bda7bf28..73046e61ee73209aad47fcfc67ece8c02357c3b1 100644 (file)
@@ -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: