commit 88f23097968cb4d65993de16b8e51457d727f3bc
parent 8178ea17fd4d873862631c3710df6f860ba2078a
Author: James Prestwood <prestwoj@gmail.com>
Date: Tue, 4 Jan 2022 10:18:54 -0800
auto-t: wpas.py: add wait_for_result
Some wpa_cli utilities return some result which isn't possible to
get with wait_for_event unless you know what the result will be.
This adds wait_for_result which just returns the first event that
comes in.
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/autotests/util/wpas.py b/autotests/util/wpas.py
@@ -70,6 +70,9 @@ class Wpas:
while True:
context.iteration(may_block=True)
+ if not event and len(self._rx_data) >= 1:
+ return self._rx_data[0]
+
for e in self._rx_data:
if event in e:
GLib.source_remove(timeout)
@@ -78,6 +81,10 @@ class Wpas:
if self._wait_timed_out:
raise TimeoutError('waiting for wpas event timed out')
+ def wait_for_result(self, timeout=10):
+ self._rx_data = []
+ return self.wait_for_event(None, timeout=timeout)
+
def _event_parse(self, line):
# Unescape event parameter values in '', other escaping rules not implemented
key = None