brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · a018456 Raw
68 lines · python
1"""2Test lldb-dap send-event integration.3"""4 5import json6 7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9import lldbdap_testcase10 11 12class TestDAP_sendEvent(lldbdap_testcase.DAPTestCaseBase):13    @skipIfWindows14    def test_send_event(self):15        """16        Test sending a custom event.17        """18        program = self.getBuildArtifact("a.out")19        source = "main.c"20        breakpoint_line = line_number(source, "// breakpoint")21        custom_event_body = {22            "key": 321,23            "arr": [True],24        }25        self.build_and_launch(26            program,27            stopCommands=[28                "lldb-dap send-event my-custom-event-no-body",29                "lldb-dap send-event my-custom-event '{}'".format(30                    json.dumps(custom_event_body)31                ),32            ],33        )34        self.set_source_breakpoints(source, [breakpoint_line])35        self.continue_to_next_stop()36 37        custom_event = self.dap_server.wait_for_event(38            filter=["my-custom-event-no-body"]39        )40        self.assertEqual(custom_event["event"], "my-custom-event-no-body")41        self.assertIsNone(custom_event.get("body", None))42 43        custom_event = self.dap_server.wait_for_event(filter=["my-custom-event"])44        self.assertEqual(custom_event["event"], "my-custom-event")45        self.assertEqual(custom_event["body"], custom_event_body)46 47    @skipIfWindows48    def test_send_internal_event(self):49        """50        Test sending an internal event produces an error.51        """52        program = self.getBuildArtifact("a.out")53        source = "main.c"54        self.build_and_launch(program)55 56        breakpoint_line = line_number(source, "// breakpoint")57 58        self.set_source_breakpoints(source, [breakpoint_line])59        self.continue_to_next_stop()60 61        resp = self.dap_server.request_evaluate(62            "`lldb-dap send-event stopped", context="repl"63        )64        self.assertRegex(65            resp["body"]["result"],66            r"Invalid use of lldb-dap send-event, event \"stopped\" should be handled by lldb-dap internally.",67        )68