From 1c86327029788fb9bc61a3c420ea35ee6b472b05 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Tue, 19 Oct 2021 11:19:05 -0700 Subject: [PATCH] auto-t: SAQuery-spoofing replace sleep with condition wait By sleeping for 4 seconds IWD had plenty of time to fully disconnect and reconnect in time to pass the final "connected" check. Instead use wait_for_object_condition to wait for disconnected and expect this to fail. This will let the test fail if IWD disconnects. --- autotests/testSAQuery-spoofing/connection_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autotests/testSAQuery-spoofing/connection_test.py b/autotests/testSAQuery-spoofing/connection_test.py index f64a93f7..0ff0615f 100644 --- a/autotests/testSAQuery-spoofing/connection_test.py +++ b/autotests/testSAQuery-spoofing/connection_test.py @@ -51,8 +51,10 @@ class Test(unittest.TestCase): # Spoof a disassociate frame. This will kick off SA Query procedure. hwsim.spoof_disassociate(radio, hostapd.frequency, device.address) - # sleep to ensure hostapd responds and SA Query does not timeout - sleep(4) + # ensure hostapd responds and SA Query does not timeout + with self.assertRaises(TimeoutError): + condition = 'obj.state == DeviceState.disconnected' + wd.wait_for_object_condition(device, condition, 4) # Since disassociate was spoofed we should still be connected condition = 'obj.state == DeviceState.connected'