From: Jouni Malinen Date: Tue, 12 Dec 2023 18:14:15 +0000 (+0200) Subject: tests: Work around a race condition in p2p_device_grpform_timeout_go X-Git-Tag: hostap_2_11~677 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e020a989692b878b1cb9dd9d92131a5ce2e52534;p=thirdparty%2Fhostap.git tests: Work around a race condition in p2p_device_grpform_timeout_go Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_p2p_device.py b/tests/hwsim/test_p2p_device.py index fa31b7fe9..aeece31b6 100644 --- a/tests/hwsim/test_p2p_device.py +++ b/tests/hwsim/test_p2p_device.py @@ -351,13 +351,22 @@ def test_p2p_device_grpform_timeout_go(dev, apdev): del wpas raise HwsimSkip("Did not manage to cancel group formation") dev[0].dump_monitor() - ev = wpas.wait_global_event(["WPS-SUCCESS"], timeout=10) + # There is a race condition on WPS-SUCCESS being reported on the GO + # since the P2P_CANCEL command above might actually stop the WPS + # exchange before the WSC_Done is sent to the GO and processed there. + # It would be possible for the GO to receive a disconnection event + # first. + ev = wpas.wait_global_event(["WPS-SUCCESS", + "P2P-GROUP-FORMATION-FAILURE"], + timeout=30) if ev is None: raise Exception("WPS did not succeed (GO)") dev[0].dump_monitor() - ev = wpas.wait_global_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=20) - if ev is None: - raise Exception("Group formation timeout not seen on GO") + if "P2P-GROUP-FORMATION-FAILURE" not in ev: + ev = wpas.wait_global_event(["P2P-GROUP-FORMATION-FAILURE"], + timeout=20) + if ev is None: + raise Exception("Group formation timeout not seen on GO") ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=5) if ev is None: raise Exception("Group removal not seen on GO")