commit 1fca13f07a188a32770ec3f149fff3cca3a456a4
parent a773aa6a072d4a23ab52026d19f8f3992100ef9c
Author: James Prestwood <prestwoj@gmail.com>
Date: Wed, 30 Mar 2022 13:23:12 -0700
auto-t: testutil: wait for operstate
Depending on timing the operstate may not be set even when IWD shows
as connected. Instead wait for the operstate to become set.
Diffstat:
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/autotests/util/testutil.py b/autotests/util/testutil.py
@@ -134,10 +134,7 @@ SIOCGIFADDR = 0x8915
IFF_UP = 1 << 0
IFF_RUNNING = 1 << 6
-def test_iface_operstate(intf=None):
- if not intf:
- intf = iwd.IWD.get_instance().list_devices()[0].name
-
+def _test_operstate(intf):
sock = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
try:
@@ -146,10 +143,19 @@ def test_iface_operstate(intf=None):
# IFF_LOWER_UP and IFF_DORMANT not returned by SIOCGIFFLAGS
if flags & (IFF_UP | IFF_RUNNING) != IFF_UP | IFF_RUNNING:
- raise Exception(intf + ' operstate wrong')
+ return False
+
+ return True
finally:
sock.close()
+def test_iface_operstate(intf=None):
+ if not intf:
+ intf = iwd.IWD.get_instance().list_devices()[0].name
+
+ ctx.non_block_wait(_test_operstate, 10, intf,
+ exception=Exception(intf + ' operstate wrong'))
+
def test_ip_address_match(intf, ip):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)