From: Jouni Malinen Date: Fri, 23 Jan 2026 15:22:42 +0000 (+0200) Subject: tests: Avoid a race condition in dpp_hostapd_enrollee_gas_proto X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91e7785fb46d3f3b4ebc1d661a947f20d5298598;p=thirdparty%2Fhostap.git tests: Avoid a race condition in dpp_hostapd_enrollee_gas_proto A GAS frame from the previous iteration could have been processed when the last step of the test case was supposed to process DPP Authentication messages. Add a short wait to make that less likely. In addition, explicitly check that the processed frame is indeed of expected type to make the error cases on race conditions more obvious. Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 668478ac0..c63ceed4d 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -3242,9 +3242,13 @@ def test_dpp_hostapd_enrollee_gas_timeout_comeback(dev, apdev): if "result=TIMEOUT" not in ev: raise Exception("GAS timeout not reported") -def process_dpp_frames(dev, count=3): +def process_dpp_frames(dev, count=3, only_dpp_action=False): for i in range(count): msg = dev.mgmt_rx() + payload = msg['payload'] + categ, action = struct.unpack('BB', payload[0:2]) + if only_dpp_action and (categ != 4 or action != 9): + raise Exception("Unexpected Action frame: categ=%d action=%d" % (categ, action)) cmd = "MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(msg['freq'], msg['datarate'], msg['ssi_signal'], binascii.hexlify(msg['frame']).decode()) if "OK" not in dev.request(cmd): raise Exception("MGMT_RX_PROCESS failed") @@ -3319,7 +3323,9 @@ def test_dpp_hostapd_enrollee_gas_proto(dev, apdev): process_dpp_frames(dev[0], count=3) msg = dev[0].mgmt_rx() payload = msg['payload'] - dialog_token, = struct.unpack('B', payload[2:3]) + categ, action, dialog_token = struct.unpack('BBB', payload[0:3]) + if categ != 4 or action != 12: + raise Exception("Unexpected Action frame: categ=%d action=%d" % (categ, action)) hdr = struct.pack('