brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 5ff6fd9 Raw
66 lines · python
1"""2Test lldb data formatter subsystem.3"""4 5 6import lldb7from lldbsuite.test.lldbtest import *8from lldbsuite.test.decorators import *9import lldbsuite.test.lldbutil as lldbutil10 11 12class GlobalsDataFormatterTestCase(TestBase):13    def setUp(self):14        # Call super's setUp().15        TestBase.setUp(self)16        # Find the line number to break at.17        self.line = line_number("main.cpp", "// Set break point at this line.")18 19    def test_with_run_command(self):20        """Test that that file and class static variables display correctly."""21        self.build()22        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)23 24        lldbutil.run_break_set_by_file_and_line(25            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True26        )27 28        # This is the function to remove the custom formats in order to have a29        # clean slate for the next test case.30        def cleanup():31            self.runCmd("type format clear", check=False)32            self.runCmd("type summary clear", check=False)33 34        # Execute the cleanup function during test case tear down.35        self.addTearDownHook(cleanup)36 37        self.runCmd('type summary add --summary-string "JustATest" Point')38 39        # Simply check we can get at global variables40        self.expect("target variable g_point", substrs=["JustATest"])41 42        self.expect(43            "target variable g_point_pointer", substrs=["(Point *) g_point_pointer ="]44        )45 46        # Print some information about the variables47        # (we ignore the actual values)48        self.runCmd('type summary add --summary-string "(x=${var.x},y=${var.y})" Point')49 50        self.expect("target variable g_point", substrs=["x=", "y="])51 52        self.expect(53            "target variable g_point_pointer", substrs=["(Point *) g_point_pointer ="]54        )55 56        # Test Python code on resulting SBValue57        self.runCmd(58            "type summary add --python-script \"return 'x=' + str(valobj.GetChildMemberWithName('x').GetValue());\" Point"59        )60 61        self.expect("target variable g_point", substrs=["x="])62 63        self.expect(64            "target variable g_point_pointer", substrs=["(Point *) g_point_pointer ="]65        )66