[PATCH v2] tests: give some operations more time

Johannes Berg johannes at sipsolutions.net
Fri Nov 24 12:25:18 PST 2023


From: Johannes Berg <johannes.berg at intel.com>

With more channels now available in some regulatory
domains, some scan operations can take longer. Give
them more time to complete in tests.

For two cases this required adding a timeout parameter
to connect(), which is then passed through.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
v2: increase timeout also in wpas_ap_dfs test
---
 tests/hwsim/test_dfs.py      |  2 +-
 tests/hwsim/test_scan.py     |  4 ++--
 tests/hwsim/test_wpas_ap.py  |  2 +-
 tests/hwsim/wpasupplicant.py | 13 ++++++++-----
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py
index c5876539ffc6..49374dd96d23 100644
--- a/tests/hwsim/test_dfs.py
+++ b/tests/hwsim/test_dfs.py
@@ -109,7 +109,7 @@ def test_dfs(dev, apdev):
         if freq != "5260":
             raise Exception("Unexpected frequency")
 
-        dev[0].connect("dfs", key_mgmt="NONE")
+        dev[0].connect("dfs", key_mgmt="NONE", timeout=30)
         dev[0].wait_regdom(country_ie=True)
         hwsim_utils.test_connectivity(dev[0], hapd)
 
diff --git a/tests/hwsim/test_scan.py b/tests/hwsim/test_scan.py
index 15acfe3cad3c..80c6d4cc7ad8 100644
--- a/tests/hwsim/test_scan.py
+++ b/tests/hwsim/test_scan.py
@@ -695,7 +695,7 @@ def test_scan_setband(dev, apdev):
                 d.request("SCAN only_new=1")
 
             for d in devs:
-                ev = d.wait_event(["CTRL-EVENT-SCAN-RESULTS"], 15)
+                ev = d.wait_event(["CTRL-EVENT-SCAN-RESULTS"], 30)
                 if ev is None:
                     raise Exception("Scan timed out")
 
@@ -1031,7 +1031,7 @@ def _test_scan_dfs(dev, apdev, params):
 
     if "OK" not in dev[0].request("SCAN"):
         raise Exception("SCAN command failed")
-    ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=15)
+    ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=30)
     if ev is None:
         raise Exception("Scan did not complete")
 
diff --git a/tests/hwsim/test_wpas_ap.py b/tests/hwsim/test_wpas_ap.py
index 20604e890bbc..98c80ca51c5b 100644
--- a/tests/hwsim/test_wpas_ap.py
+++ b/tests/hwsim/test_wpas_ap.py
@@ -391,7 +391,7 @@ def _test_wpas_ap_dfs(dev):
     if ev is None:
         raise Exception("AP failed to start")
 
-    dev[1].connect("wpas-ap-dfs", key_mgmt="NONE")
+    dev[1].connect("wpas-ap-dfs", key_mgmt="NONE", timeout=30)
     dev[1].wait_regdom(country_ie=True)
     dev[0].request("DISCONNECT")
     dev[1].disconnect_and_stop_scan()
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index a9ca6c1b64a2..b9764baffb63 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -1069,7 +1069,7 @@ class WpaSupplicant:
         if tspecs:
             raise Exception("DELTS failed (still in tspec list)")
 
-    def connect(self, ssid=None, ssid2=None, **kwargs):
+    def connect(self, ssid=None, ssid2=None, timeout=None, **kwargs):
         logger.info("Connect STA " + self.ifname + " to AP")
         id = self.add_network()
         if ssid:
@@ -1121,6 +1121,12 @@ class WpaSupplicant:
             if field in kwargs and kwargs[field]:
                 self.set_network(id, field, kwargs[field])
 
+        if timeout is None:
+            if "eap" in kwargs:
+                timeout=20
+            else:
+                timeout=15
+
         known_args = {"raw_psk", "password_hex", "peerkey", "okc", "ocsp",
                       "only_add_network", "wait_connect", "raw_identity"}
         unknown = set(kwargs.keys())
@@ -1145,10 +1151,7 @@ class WpaSupplicant:
         if "only_add_network" in kwargs and kwargs['only_add_network']:
             return id
         if "wait_connect" not in kwargs or kwargs['wait_connect']:
-            if "eap" in kwargs:
-                self.connect_network(id, timeout=20)
-            else:
-                self.connect_network(id, timeout=15)
+            self.connect_network(id, timeout=timeout)
         else:
             self.dump_monitor()
             self.select_network(id)
-- 
2.42.0




More information about the Hostap mailing list