diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py index 7819ad8ee..183992c03 100644 --- a/tests/hwsim/test_pmksa_cache.py +++ b/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: diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index 4e13b37b3..ca656ba14 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/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]: diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index bd69c97b6..e0a87daaa 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/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):