From 97f7f9ce9bcc2789110e9e2297a27374d20bff5f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 10 Dec 2023 10:50:32 +0200 Subject: [PATCH] tests: Make dpp_two_initiators more robust This test case has a race condition between the first and second initiated DPP exchange. New kernel scheduling with UML time-travel is making the first exchange complete before the first one can be started. Making this fully robust would likely need ext_mgmt_frame_handling=1 and more complex test script, but as an initial workaround, split URI parsing from dev[2] to happen before dev[1] is started so that only a single DPP_AUTH_INIT command is needed during the race window. In addition, detect the race condition and SKIP the test instead of reporting FAIL. Signed-off-by: Jouni Malinen --- tests/hwsim/test_dpp.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 2626e2ffe..767b43b99 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -5488,13 +5488,21 @@ def test_dpp_two_initiators(dev, apdev): id = dev[0].dpp_bootstrap_gen(chan="81/1", mac=True) uri = dev[0].request("DPP_BOOTSTRAP_GET_URI %d" % id) dev[0].dpp_listen(2412) + peer = dev[2].dpp_qr_code(uri) dev[1].dpp_auth_init(uri=uri) ev = dev[0].wait_event(["DPP-RX"], timeout=5) if ev is None: raise Exeption("No DPP Authentication Request seen") - dev[2].dpp_auth_init(uri=uri) - wait_dpp_fail(dev[0], - "DPP-FAIL Already in DPP authentication exchange - ignore new one") + dev[2].dpp_auth_init(uri=uri, peer=peer) + ev = dev[0].wait_event(["DPP-FAIL"], timeout=5) + if ev is None: + raise Exception("Failure not reported") + skip = False + if "Configurator rejected configuration" in ev: + # Race condition prevented real test from being executed + skip = True + elif "DPP-FAIL Already in DPP authentication exchange - ignore new one" not in ev: + raise Exception("Unexpected result: " + ev) ev = dev[0].wait_event(["DPP-CONF-FAILED"], timeout=2) if ev is None: @@ -5507,6 +5515,9 @@ def test_dpp_two_initiators(dev, apdev): dev[1].request("DPP_STOP_LISTEN") dev[2].request("DPP_STOP_LISTEN") + if skip: + raise HwsimSkip("dpp_two_initiators not fully executed due to race condition") + def test_dpp_conf_file_update(dev, apdev, params): """DPP provisioning updating wpa_supplicant configuration file""" config = os.path.join(params['logdir'], 'dpp_conf_file_update.conf')