From 7e9efc3cdf8ce54c7e1e5b04ac6f0b72c5994f1e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 4 Nov 2023 09:53:58 +0200 Subject: [PATCH] tests: Handle race condition in eap_proto_md5_server UML time travel allows the deauthentication event to be processed more quickly than the delivery of EAP-Success to the client through the test script, so accept either sequence here. Signed-off-by: Jouni Malinen --- tests/hwsim/test_eap_proto.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/hwsim/test_eap_proto.py b/tests/hwsim/test_eap_proto.py index 4254620b4..5e42c4443 100644 --- a/tests/hwsim/test_eap_proto.py +++ b/tests/hwsim/test_eap_proto.py @@ -1646,9 +1646,10 @@ def start_md5_assoc(dev, hapd): proxy_msg(dev, hapd) # NAK proxy_msg(hapd, dev) # MD5 Request -def stop_md5_assoc(dev, hapd): +def stop_md5_assoc(dev, hapd, wait=True): dev.request("REMOVE_NETWORK all") - dev.wait_disconnected() + if wait: + dev.wait_disconnected() dev.dump_monitor() hapd.dump_monitor() @@ -1667,10 +1668,14 @@ def test_eap_proto_md5_server(dev, apdev): start_md5_assoc(dev[0], hapd) proxy_msg(dev[0], hapd) # MD5 Response proxy_msg(hapd, dev[0]) # EAP-Success - ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=5) + # Accept both EAP-Success and disconnection indication since it is possible + # for disconnection from the AP (due to EAP-MD5 not deriving keys) to be + # processed more quickly. + ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS", + "CTRL-EVENT-DISCONNECTED"], timeout=5) if ev is None: raise Exception("No EAP-Success reported") - stop_md5_assoc(dev[0], hapd) + stop_md5_assoc(dev[0], hapd, wait="CTRL-EVENT-EAP-SUCCESS" in ev) start_md5_assoc(dev[0], hapd) resp = rx_msg(dev[0])