]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Make country code clearing in dbus_interface more robust
authorJouni Malinen <j@w1.fi>
Sat, 21 Dec 2024 20:31:07 +0000 (22:31 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 21 Dec 2024 20:31:07 +0000 (22:31 +0200)
Wait for the specific CTRL-EVENT-REGDOM-CHANGE events to try to avoid
test failures due to some race conditions and the US country code being
left effective at the end of the test case.

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

index b2eca83ea1893af98c4ec9857644599cf8d6bfd2..ab535a3ef01d5be0166550afea46fe797dbcaa37 100644 (file)
@@ -2017,17 +2017,32 @@ def test_dbus_interface(dev, apdev):
     finally:
         # Need to force P2P channel list update since the 'lo' interface
         # with driver=none ends up configuring default dualband channels.
+        dev[0].dump_monitor()
         dev[0].request("SET country US")
         ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
         if ev is None:
             ev = dev[0].wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"],
                                           timeout=1)
+        if ev is None or "alpha2=US" not in ev:
+            ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
+            ev = dev[0].wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"],
+                                          timeout=1)
+        dev[0].dump_monitor()
+
         dev[0].request("SET country 00")
         ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
         if ev is None:
             ev = dev[0].wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"],
                                           timeout=1)
+        if ev is None or "type=WORLD" not in ev:
+            ev = dev[0].wait_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=1)
+            ev = dev[0].wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"],
+                                          timeout=1)
+
         subprocess.call(['iw', 'reg', 'set', '00'])
+        cc = dev[0].get_driver_status_field("country")
+        if cc != '00':
+            logger.info("Country code not cleared to 00: " + cc)
 
 def _test_dbus_interface(dev, apdev):
     (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])