brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 0065258 Raw
52 lines · python
1"""2Test lldb-dap output events3"""4 5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7import lldbdap_testcase8 9 10class TestDAP_output(lldbdap_testcase.DAPTestCaseBase):11    @skipIfWindows12    def test_output(self):13        """14        Test output handling for the running process.15        """16        program = self.getBuildArtifact("a.out")17        self.build_and_launch(18            program,19            disconnectAutomatically=False,20            exitCommands=[21                # Ensure that output produced by lldb itself is not consumed by the OutputRedirector.22                "?script print('out\\0\\0', end='\\r\\n', file=sys.stdout)",23                "?script print('err\\0\\0', end='\\r\\n', file=sys.stderr)",24            ],25        )26        source = "main.c"27        lines = [line_number(source, "// breakpoint 1")]28        breakpoint_ids = self.set_source_breakpoints(source, lines)29        self.continue_to_breakpoints(breakpoint_ids)30 31        # Ensure partial messages are still sent.32        output = self.collect_stdout(pattern="abcdef")33        self.assertTrue(output and len(output) > 0, "expect program stdout")34 35        self.continue_to_exit()36 37        # Disconnecting from the server to ensure any pending IO is flushed.38        self.dap_server.request_disconnect()39 40        output += self.get_stdout()41        self.assertTrue(output and len(output) > 0, "expect program stdout")42        self.assertIn(43            "abcdefghi\r\nhello world\r\nfinally\0\0",44            output,45            "full stdout not found in: " + repr(output),46        )47        console = self.get_console()48        self.assertTrue(console and len(console) > 0, "expect dap messages")49        self.assertIn(50            "out\0\0\r\nerr\0\0\r\n", console, f"full console message not found"51        )52