brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 1058157 Raw
89 lines · python
1"""2Test lldb-dap breakpointLocations request3"""4 5 6import dap_server7import shutil8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11import lldbdap_testcase12import os13 14 15class TestDAP_breakpointLocations(lldbdap_testcase.DAPTestCaseBase):16    def setUp(self):17        lldbdap_testcase.DAPTestCaseBase.setUp(self)18 19        self.main_basename = "main-copy.cpp"20        self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename))21 22    @skipIfWindows23    def test_column_breakpoints(self):24        """Test retrieving the available breakpoint locations."""25        program = self.getBuildArtifact("a.out")26        self.build_and_launch(program, stopOnEntry=True)27        loop_line = line_number(self.main_path, "// break loop")28        self.dap_server.request_continue()29 30        # Ask for the breakpoint locations based only on the line number31        response = self.dap_server.request_breakpointLocations(32            self.main_path, loop_line33        )34        self.assertTrue(response["success"])35        self.assertEqual(36            response["body"]["breakpoints"],37            [38                {"line": loop_line, "column": 9},39                {"line": loop_line, "column": 13},40                {"line": loop_line, "column": 20},41                {"line": loop_line, "column": 23},42                {"line": loop_line, "column": 25},43                {"line": loop_line, "column": 34},44                {"line": loop_line, "column": 37},45                {"line": loop_line, "column": 39},46                {"line": loop_line, "column": 51},47            ],48        )49 50        # Ask for the breakpoint locations for a column range51        response = self.dap_server.request_breakpointLocations(52            self.main_path,53            loop_line,54            column=24,55            end_column=46,56        )57        self.assertTrue(response["success"])58        self.assertEqual(59            response["body"]["breakpoints"],60            [61                {"line": loop_line, "column": 25},62                {"line": loop_line, "column": 34},63                {"line": loop_line, "column": 37},64                {"line": loop_line, "column": 39},65            ],66        )67 68        # Ask for the breakpoint locations for a range of line numbers69        response = self.dap_server.request_breakpointLocations(70            self.main_path,71            line=loop_line,72            end_line=loop_line + 2,73            column=39,74        )75        self.maxDiff = None76        self.assertTrue(response["success"])77        # On some systems, there is an additional breakpoint available78        # at line 41, column 3, i.e. at the end of the loop. To make this79        # test more portable, only check that all expected breakpoints are80        # presented, but also accept additional breakpoints.81        expected_breakpoints = [82            {"column": 39, "line": 40},83            {"column": 51, "line": 40},84            {"column": 3, "line": 42},85            {"column": 18, "line": 42},86        ]87        for bp in expected_breakpoints:88            self.assertIn(bp, response["body"]["breakpoints"])89