Browse Source

tests: Make pmksa_cache_on_roam_back more robust

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>
Jouni Malinen 10 years ago
parent
commit
c126cb4d1c
3 changed files with 17 additions and 5 deletions
  1. 9 1
      tests/hwsim/test_pmksa_cache.py
  2. 4 4
      tests/hwsim/test_wpas_ctrl.py
  3. 4 0
      tests/hwsim/wpasupplicant.py

+ 9 - 1
tests/hwsim/test_pmksa_cache.py

@@ -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:

+ 4 - 4
tests/hwsim/test_wpas_ctrl.py

@@ -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]:

+ 4 - 0
tests/hwsim/wpasupplicant.py

@@ -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):