Skip to content

Commit

Permalink
tests: tolerate alternate orders of messages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DemiMarie committed Apr 1, 2024
1 parent c918563 commit 223361b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions qrexec/tests/socket/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
[
Expand Down

0 comments on commit 223361b

Please sign in to comment.