]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Handle race condition in eap_proto_md5_server
authorJouni Malinen <j@w1.fi>
Sat, 4 Nov 2023 07:53:58 +0000 (09:53 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 4 Nov 2023 07:53:58 +0000 (09:53 +0200)
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 <j@w1.fi>
tests/hwsim/test_eap_proto.py

index 4254620b48f17e9c919a69d6fcbc50c15cb592d6..5e42c444397b522288852e2af49939f891d10984 100644 (file)
@@ -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])