This is meant to be used as a generic notification to autotests. For
now 'no-roam-candidates' is the only event being sent. The idea
is to extend these events to signal conditions that are otherwise
undiscoverable in autotesting.
---
src/station.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/station.c b/src/station.c
index 408ae887..d3482e2c 100644
--- a/src/station.c
+++ b/src/station.c
@@ -153,6 +153,24 @@ static bool station_is_autoconnecting(struct station *station)
station->state == STATION_STATE_AUTOCONNECT_QUICK;
}
+static bool station_debug_event(struct station *station, const char *name)
+{
+ struct l_dbus_message *signal;
+
+ if (!iwd_is_developer_mode())
+ return true;
+
+ l_debug("StationDebug.Event(%s)", name);
+
+ signal = l_dbus_message_new_signal(dbus_get_bus(),
+ netdev_get_path(station->netdev),
+ IWD_STATION_DEBUG_INTERFACE, "Event");
+
+ l_dbus_message_set_arguments(signal, "sav", name, 0);
+
+ return l_dbus_send(dbus_get_bus(), signal) != 0;
+}
+
static void station_property_set_scanning(struct station *station,
bool scanning)
{
@@ -1938,8 +1956,10 @@ next:
goto fail_free_bss;
/* See if we have anywhere to roam to */
- if (!best_bss || scan_bss_addr_eq(best_bss, station->connected_bss))
+ if (!best_bss || scan_bss_addr_eq(best_bss, station->connected_bss)) {
+ station_debug_event(station, "no-roam-candidates");
goto fail_free_bss;
+ }
bss = network_bss_find_by_addr(network, best_bss->addr);
if (bss) {
@@ -3991,6 +4011,8 @@ static void station_setup_debug_interface(
station_debug_scan, "", "aq",
"frequencies");
+ l_dbus_interface_signal(interface, "Event", 0, "sav",
"name", "data");
+
l_dbus_interface_property(interface, "AutoConnect", 0, "b",
station_property_get_autoconnect,
station_property_set_autoconnect);
--
2.31.1
Show replies by date
Hi James,
On 8/13/21 2:47 PM, James Prestwood wrote:
This is meant to be used as a generic notification to autotests. For
now 'no-roam-candidates' is the only event being sent. The idea
is to extend these events to signal conditions that are otherwise
undiscoverable in autotesting.
---
src/station.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
All applied, thanks.
Regards,
-Denis
Adds a new wait_for_event API which waits for a StationDebug.Event.
---
autotests/util/iwd.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index b5546bcd..36b8f6f9 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -233,9 +233,17 @@ class StationDebug(IWDDBusAbstract):
def __init__(self, *args, **kwargs):
self._debug_props = None
self._debug_iface = None
+ self._last_event = None
+ self._last_event_data = []
IWDDBusAbstract.__init__(self, *args, **kwargs)
+ self._iface.connect_to_signal("Event", self._event_handler)
+
+ def _event_handler(self, event, data):
+ self._last_event = event
+ self._last_event_data = data
+
@property
def autoconnect(self):
return self._properties['AutoConnect']
@@ -244,6 +252,21 @@ class StationDebug(IWDDBusAbstract):
frequencies = dbus.Array([dbus.UInt16(f) for f in frequencies])
self._iface.Scan(frequencies)
+ def wait_for_event(self, event, timeout=10):
+ try:
+ if self._last_event is not None:
+ return self._last_event_data
+
+ ctx.non_block_wait(lambda s, e : s._last_event == e, timeout, self, event,
+ exception=TimeoutError("waiting for
StationDebug.Event"))
+
+ return self._last_event_data
+ finally:
+ # Consume the event
+ self._last_event_data = None
+ self._last_event = None
+
+
class Device(IWDDBusAbstract):
'''
Class represents a network device object: net.connman.iwd.Device
@@ -596,6 +619,12 @@ class Device(IWDDBusAbstract):
self._station_debug.scan(frequencies)
+ def wait_for_event(self, event, timeout=10):
+ if not self._station_debug:
+ self._station_debug = StationDebug(self._object_path)
+
+ self._station_debug.wait_for_event(event, timeout)
+
def __str__(self, prefix = ''):
return prefix + 'Device: ' + self.device_path + '\n'\
+ prefix + '\tName:\t\t' + self.name + '\n'\
--
2.31.1
This test took quite a while to execute (~2 minutes on my machine)
because there was simply no other way to test this scenario but
waiting. Now the no-roam-candidates condition can be waited for
rather than just sleeping for 20 seconds. Additionally the default
RoamRetryInterval was being used which is 60 seconds. Instead
main.conf can set this to 5 seconds and really cut down on the time
to wait.
Part of a comment was also removed due to being incorrect. Even
with neighbor reports IWD still must scan, its just that the
scan is more limited and, in theory, faster.
---
autotests/testRoamRetry/fast_retry_test.py | 7 +++----
autotests/testRoamRetry/main.conf | 2 ++
autotests/testRoamRetry/stop_retry_test.py | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
create mode 100644 autotests/testRoamRetry/main.conf
diff --git a/autotests/testRoamRetry/fast_retry_test.py
b/autotests/testRoamRetry/fast_retry_test.py
index d6324c31..e8b5455d 100644
--- a/autotests/testRoamRetry/fast_retry_test.py
+++ b/autotests/testRoamRetry/fast_retry_test.py
@@ -82,7 +82,7 @@ class Test(unittest.TestCase):
# schedule another attempt for 60 seconds later
rule0.signal = -8000
- wd.wait(20)
+ device.wait_for_event('no-roam-candidates')
self.assertEqual(device.state, iwd.DeviceState.connected)
self.assertTrue(bss_hostapd[0].list_sta())
@@ -99,13 +99,12 @@ class Test(unittest.TestCase):
wd.wait(1)
# Assert low signal for BSS 0, check that iwd starts transition to BSS 1
- # in less than 10 seconds. Because of the neighbor report a scan should
- # not be necessary.
+ # in less than 10 seconds.
rule0.signal = -8000
rule1.signal = -2000
condition = 'obj.state == DeviceState.roaming'
- wd.wait_for_object_condition(device, condition, max_wait=10)
+ wd.wait_for_object_condition(device, condition, max_wait=15)
# Check that iwd is on BSS 1 once out of roaming state and doesn't
# go through 'disconnected', 'autoconnect', 'connecting'
in between
diff --git a/autotests/testRoamRetry/main.conf b/autotests/testRoamRetry/main.conf
new file mode 100644
index 00000000..f0d1c0f4
--- /dev/null
+++ b/autotests/testRoamRetry/main.conf
@@ -0,0 +1,2 @@
+[General]
+RoamRetryInterval=5
diff --git a/autotests/testRoamRetry/stop_retry_test.py
b/autotests/testRoamRetry/stop_retry_test.py
index be9776a5..3bf166d8 100644
--- a/autotests/testRoamRetry/stop_retry_test.py
+++ b/autotests/testRoamRetry/stop_retry_test.py
@@ -99,7 +99,7 @@ class Test(unittest.TestCase):
condition = 'obj.state == DeviceState.roaming'
self.assertRaises(TimeoutError, wd.wait_for_object_condition, device,
- condition, max_wait=70)
+ condition, max_wait=10)
device.disconnect()
--
2.31.1