]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make pmksa_cache_on_roam_back more robust
authorJouni Malinen <j@w1.fi>
Tue, 13 May 2014 21:12:40 +0000 (00:12 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 15 May 2014 13:56:45 +0000 (16:56 +0300)
The single channel scan while associated to another AP and immediately
after starting the second AP can miss the Probe Response frame
especially under heavy CPU load. Avoid false error reports by allowing
multiple scan rounds to be performed. wpas_ctrl_bssid_filter is also
modified to take into account different get_bss() behavior.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_pmksa_cache.py
tests/hwsim/test_wpas_ctrl.py
tests/hwsim/wpasupplicant.py

index 7819ad8ee7f6edf22b21595a21f8d510b071de0a..183992c03b4af73df76b6c7bfb11df83fbc1914a 100644 (file)
@@ -33,7 +33,15 @@ def test_pmksa_cache_on_roam_back(dev, apdev):
 
     dev[0].dump_monitor()
     logger.info("Roam to AP2")
-    dev[0].scan(freq="2412")
+    # It can take some time for the second AP to become ready to reply to Probe
+    # Request frames especially under heavy CPU load, so allow couple of rounds
+    # of scanning to avoid reporting errors incorrectly just because of scans
+    # not having seen the target AP.
+    for i in range(0, 10):
+        dev[0].scan(freq="2412")
+        if dev[0].get_bss(bssid2) is not None:
+            break
+        logger.info("Scan again to find target AP")
     dev[0].request("ROAM " + bssid2)
     ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=10)
     if ev is None:
index 4e13b37b3f422a51136e8930f8674562945e8cee..ca656ba146ab01de117d3bb16e7c221eec1f5fde 100644 (file)
@@ -584,18 +584,18 @@ def test_wpas_ctrl_bssid_filter(dev, apdev):
         hostapd.add_ap(apdev[1]['ifname'], params)
         dev[2].scan(freq="2412")
         bss = dev[2].get_bss(apdev[0]['bssid'])
-        if len(bss) == 0:
+        if bss is None or len(bss) == 0:
             raise Exception("Missing BSS data")
         bss = dev[2].get_bss(apdev[1]['bssid'])
-        if len(bss) != 0:
+        if bss and len(bss) != 0:
             raise Exception("Unexpected BSS data")
         dev[2].request("SET bssid_filter ")
         dev[2].scan(freq="2412")
         bss = dev[2].get_bss(apdev[0]['bssid'])
-        if len(bss) == 0:
+        if bss is None or len(bss) == 0:
             raise Exception("Missing BSS data")
         bss = dev[2].get_bss(apdev[1]['bssid'])
-        if len(bss) == 0:
+        if bss is None or len(bss) == 0:
             raise Exception("Missing BSS data(2)")
         res = dev[2].request("SCAN_RESULTS").splitlines()
         if "test" not in res[1] or "test" not in res[2]:
index bd69c97b69486003c96f96a38f6ae54ea97f494a..e0a87daaaae0453888ea1ef12c1ac4ee09f2a423 100644 (file)
@@ -779,11 +779,15 @@ class WpaSupplicant:
 
     def get_bss(self, bssid):
         res = self.request("BSS " + bssid)
+        if "FAIL" in res:
+            return None
         lines = res.splitlines()
         vals = dict()
         for l in lines:
             [name,value] = l.split('=', 1)
             vals[name] = value
+        if len(vals) == 0:
+            return None
         return vals
 
     def get_pmksa(self, bssid):