From 223361bb44793230c8e6ff61c70203eb85b6fe6c Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Sat, 30 Mar 2024 17:39:19 -0400 Subject: [PATCH] tests: tolerate alternate orders of messages It is possible that MSG_DATA_STDERR and/or MSG_DATA_EXIT_CODE might come before all stdout data is received. This fixes a failure under ASAN, which is presumably triggered by timing differences. --- qrexec/tests/socket/agent.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qrexec/tests/socket/agent.py b/qrexec/tests/socket/agent.py index f6c5be3e..7f7b8399 100644 --- a/qrexec/tests/socket/agent.py +++ b/qrexec/tests/socket/agent.py @@ -623,16 +623,20 @@ def test_buffer_stdin(self): f.write("end\n") f.flush() + messages = [] received_data = b"" while len(received_data) < data_size: message_type, message = target.recv_message() - self.assertEqual(message_type, qrexec.MSG_DATA_STDOUT) - received_data += message + if message_type != qrexec.MSG_DATA_STDOUT: + messages.append((message_type, message)) + else: + self.assertEqual(message_type, qrexec.MSG_DATA_STDOUT) + received_data += message self.assertEqual(len(received_data), data_size) self.assertEqual(received_data, data) - messages = target.recv_all_messages() + messages += target.recv_all_messages() self.assertListEqual( util.sort_messages(messages), [