brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · e6aeef2 Raw
90 lines · python
1"""2Test lldb data formatter subsystem.3"""4 5 6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11 12class DataFormatterDisablingTestCase(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        """Check that we can properly disable all data formatter categories."""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        self.runCmd("run", RUN_SUCCEEDED)29 30        # The stop reason of the thread should be breakpoint.31        self.expect(32            "thread list",33            STOPPED_DUE_TO_BREAKPOINT,34            substrs=["stopped", "stop reason = breakpoint"],35        )36 37        # This is the function to remove the custom formats in order to have a38        # clean slate for the next test case.39        def cleanup():40            self.runCmd("type category enable *", check=False)41 42        # Execute the cleanup function during test case tear down.43        self.addTearDownHook(cleanup)44 45        self.expect(46            "type category list",47            substrs=[48                "system",49                "enabled",50            ],51        )52 53        self.expect("frame variable numbers", substrs=["[0] = 1", "[3] = 1234"])54 55        self.expect("frame variable string1", substrs=["hello world"])56 57        # now disable them all and check that nothing is formatted58        self.runCmd("type category disable *")59 60        self.expect(61            "frame variable numbers", matching=False, substrs=["[0] = 1", "[3] = 1234"]62        )63 64        self.expect("frame variable string1", matching=False, substrs=["hello world"])65 66        self.expect("type summary list", substrs=["Category: system (disabled)"])67 68        self.expect(69            "type category list",70            substrs=[71                "system",72                "disabled",73            ],74        )75 76        # now enable and check that we are back to normal77        self.runCmd("type category enable *")78 79        self.expect("type category list", substrs=["system", "enabled"])80 81        self.expect("frame variable numbers", substrs=["[0] = 1", "[3] = 1234"])82 83        self.expect("frame variable string1", substrs=["hello world"])84 85        self.expect("type category list", substrs=["system", "enabled"])86 87        # last check - our cleanup will re-enable everything88        self.runCmd("type category disable *")89        self.expect("type category list", substrs=["system", "disabled"])90