[PATCH v5 7/8] auto-t: Fix test_ignore_candidate_list_quirk

Alexander Ganslandt <[email protected]> Fri, 28 Nov 2025 12:54:28 +0100
Newsgroups dev.linux.lists.iwd
Message-ID <[email protected]>
This test no longer triggers a full scan. Instead, we verify that it
doesn't scan the bad candidate channel, which is verified by not getting
"no-roam-candidates". Then we also verify that it roams to the other
available BSS, which it should do immediately because that BSS is on a
channel that's in the first subset of channels to be scanned. This means
it should roam directly without getting "no-roam-candidates" in-between.

To allow for this, add an optional "disallow" list of events to
wait_for_event(). This functionality already exists in hostapd.py, so
the same solution was copied to iwd.py.
---
 autotests/testAPRoam/bad_neighbor_report_test.py |  9 ++++-----
 autotests/util/iwd.py                            | 13 ++++++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/autotests/testAPRoam/bad_neighbor_report_test.py b/autotests/testAPRoam/bad_neighbor_report_test.py
index c8e4e45a..5a8be635 100644
--- a/autotests/testAPRoam/bad_neighbor_report_test.py
+++ b/autotests/testAPRoam/bad_neighbor_report_test.py
@@ -114,15 +114,14 @@ class Test(unittest.TestCase):
 
         self.initial_connection()
 
-        # Send with a candidate list (should be ignored)
+        # Send with a bad candidate list (should be ignored)
         self.bss_hostapd[0].send_bss_transition(
             self.device.address,
             [(self.bss_hostapd[1].bssid, "8f0000005105060603000000")]
         )
-        # IWD should ignore the list and trigger a full scan since we have not
-        # set any neighbors
-        self.device.wait_for_event("full-roam-scan")
-        self.device.wait_for_event("roaming", timeout=30)
+        # IWD should ignore the list and not try to scan the bad channel,
+        # so we shouldn't get no-roam-candidates before we roam
+        self.device.wait_for_event("roaming", timeout=30, disallow=["no-roam-candidates"])
         self.device.wait_for_event("connected")
 
     def setUp(self):
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 37eb4943..c79afc83 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -297,8 +297,11 @@ class StationDebug(IWDDBusAbstract):
         frequencies = dbus.Array([dbus.UInt16(f) for f in frequencies])
         self._iface.Scan(frequencies)
 
-    def _poll_event(self, event):
+    def _poll_event(self, event, disallow):
         for idx, e in enumerate(self._events):
+            for d in disallow:
+                if d in e:
+                    raise Exception('Event %s found while waiting for %s' % (d, event))
             if event == e[0]:
                 # Consume any older events
                 self._events = self._events[:idx]
@@ -309,8 +312,8 @@ class StationDebug(IWDDBusAbstract):
     def clear_events(self):
         self._events = []
 
-    def wait_for_event(self, event, timeout=10):
-        return ctx.non_block_wait(self._poll_event, timeout, event,
+    def wait_for_event(self, event, timeout=10, disallow=[]):
+        return ctx.non_block_wait(self._poll_event, timeout, event, disallow,
                                     exception=TimeoutError("waiting for event"))
 
     def event_ocurred(self, event):
@@ -886,8 +889,8 @@ class Device(IWDDBusAbstract):
     def debug_scan(self, frequencies):
         self._station_debug.scan(frequencies)
 
-    def wait_for_event(self, event, timeout=10):
-        self._station_debug.wait_for_event(event, timeout)
+    def wait_for_event(self, event, timeout=10, disallow=[]):
+        self._station_debug.wait_for_event(event, timeout, disallow)
 
     def clear_events(self):
         self._station_debug.clear_events()

-- 
2.39.5