The TestDAP_ouput test is flaky due to the order of events during shutdown. We were stopping the output and error handle redirection after we finished the disconnect request, which can cause us to miss output events due to timing. Moving when we stop the redirection to ensure we have consistent output prior to disconnect responding. Fixes #128567
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""
|
|
Test lldb-dap output events
|
|
"""
|
|
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
import lldbdap_testcase
|
|
|
|
|
|
class TestDAP_output(lldbdap_testcase.DAPTestCaseBase):
|
|
@skipIfWindows
|
|
def test_output(self):
|
|
"""
|
|
Test output handling for the running process.
|
|
"""
|
|
program = self.getBuildArtifact("a.out")
|
|
self.build_and_launch(
|
|
program,
|
|
disconnectAutomatically=False,
|
|
exitCommands=[
|
|
# Ensure that output produced by lldb itself is not consumed by the OutputRedirector.
|
|
"?script print('out\\0\\0', end='\\r\\n', file=sys.stdout)",
|
|
"?script print('err\\0\\0', end='\\r\\n', file=sys.stderr)",
|
|
],
|
|
)
|
|
source = "main.c"
|
|
lines = [line_number(source, "// breakpoint 1")]
|
|
breakpoint_ids = self.set_source_breakpoints(source, lines)
|
|
self.continue_to_breakpoints(breakpoint_ids)
|
|
|
|
# Ensure partial messages are still sent.
|
|
output = self.collect_stdout(timeout_secs=1.0, pattern="abcdef")
|
|
self.assertTrue(output and len(output) > 0, "expect program stdout")
|
|
|
|
self.continue_to_exit()
|
|
|
|
# Disconnecting from the server to ensure any pending IO is flushed.
|
|
self.dap_server.request_disconnect()
|
|
|
|
output += self.get_stdout(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
|
|
self.assertTrue(output and len(output) > 0, "expect program stdout")
|
|
self.assertIn(
|
|
"abcdefghi\r\nhello world\r\nfinally\0\0out\0\0\r\nerr\0\0",
|
|
output,
|
|
"full stdout not found in: " + repr(output),
|
|
)
|