]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make flush_scan_cache() more robust
authorJouni Malinen <quic_jouni@quicinc.com>
Wed, 20 Dec 2023 16:21:10 +0000 (18:21 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 20 Dec 2023 16:21:10 +0000 (18:21 +0200)
Handle the cases where the first attempt to start scan fails due to an
ongoing scan. Stop such scan and try again instead of failing the test
case immediately.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
tests/hwsim/wpasupplicant.py

index af57bc6ed2cf6be8b45d584ac5dc1393f116471c..ae728a034c1a37723f122c3b1dd70d89dea07ba6 100644 (file)
@@ -1196,8 +1196,15 @@ class WpaSupplicant:
         raise Exception("Could not find BSS " + bssid + " in scan")
 
     def flush_scan_cache(self, freq=2417):
-        self.request("BSS_FLUSH 0")
-        self.scan(freq=freq, only_new=True)
+        for i in range(3):
+            self.request("BSS_FLUSH 0")
+            try:
+                self.scan(freq=freq, only_new=True)
+            except Exception as e:
+                if i < 2:
+                    logger.info("flush_scan_cache: Failed to start scan: " + str(e))
+                    self.request("ABORT_SCAN")
+                    time.sleep(0.1)
         res = self.request("SCAN_RESULTS")
         if len(res.splitlines()) > 1:
             logger.debug("Scan results remaining after first attempt to flush the results:\n" + res)