From cd18e2ea3f4e87f8804a7d6661d5596ef1f07b81 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 21 Jul 2022 16:51:54 +0200 Subject: [PATCH] [lldb/test] Fix flakyness in TestNonStop.test_stdio The test was assuming that the output will come in two messages. The truth is that it will come in **at least** two messages. --- .../test/API/tools/lldb-server/TestNonStop.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lldb/test/API/tools/lldb-server/TestNonStop.py b/lldb/test/API/tools/lldb-server/TestNonStop.py index 0031f1885e88..ff3407dcfa8a 100644 --- a/lldb/test/API/tools/lldb-server/TestNonStop.py +++ b/lldb/test/API/tools/lldb-server/TestNonStop.py @@ -320,24 +320,23 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase): "send packet: %Stop:W00#00", ], True) ret = self.expect_gdbremote_sequence() - self.assertIn(ret["O_content"], b"message 1\r\n") - # Now, this is somewhat messy. expect_gdbremote_sequence() will - # automatically consume output packets, so we just send vStdio, - # assume the first reply was consumed, send another one and expect - # a non-consumable "OK" reply. + # We know there will be at least two messages, but there may be more. + # Loop until we have everything. The first message waiting for us in the + # packet queue. + count = 1 + output = self._server.get_raw_output_packet() + while not (b"message 2\r\n" in output): + self._server.send_packet(b"vStdio") + output += self._server.get_raw_output_packet() + count += 1 + self.assertGreaterEqual(count, 2) + self.reset_test_sequence() self.test_sequence.add_log_lines( ["read packet: $vStdio#00", - "read packet: $vStdio#00", "send packet: $OK#00", - ], True) - ret = self.expect_gdbremote_sequence() - self.assertIn(ret["O_content"], b"message 2\r\n") - - self.reset_test_sequence() - self.test_sequence.add_log_lines( - ["read packet: $vStopped#00", + "read packet: $vStopped#00", "send packet: $OK#00", ], True) self.expect_gdbremote_sequence()