65 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 PyObjectSynthProviderTestCase(TestBase):13 NO_DEBUG_INFO_TESTCASE = True14 15 def test_print_array(self):16 """Test that expr -Z works"""17 self.build()18 self.provider_data_formatter_commands()19 20 def setUp(self):21 # Call super's setUp().22 TestBase.setUp(self)23 # Find the line number to break at.24 self.line = line_number("main.cpp", "break here")25 26 def provider_data_formatter_commands(self):27 """Test that the PythonObjectSyntheticChildProvider helper class works"""28 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)29 30 lldbutil.run_break_set_by_file_and_line(31 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True32 )33 34 self.runCmd("run", RUN_SUCCEEDED)35 36 # The stop reason of the thread should be breakpoint.37 self.expect(38 "thread list",39 STOPPED_DUE_TO_BREAKPOINT,40 substrs=["stopped", "stop reason = breakpoint"],41 )42 43 # This is the function to remove the custom formats in order to have a44 # clean slate for the next test case.45 def cleanup():46 self.runCmd("type format clear", check=False)47 self.runCmd("type summary clear", check=False)48 self.runCmd("type synth clear", check=False)49 50 # Execute the cleanup function during test case tear down.51 self.addTearDownHook(cleanup)52 53 self.runCmd("command script import provider.py")54 self.runCmd(55 "type synthetic add Foo --python-class provider.SyntheticChildrenProvider"56 )57 self.expect("frame variable f.Name", substrs=['"Enrico"'])58 self.expect(59 "frame variable f",60 substrs=["ID = 123456", 'Name = "Enrico"', "Rate = 1.25"],61 )62 self.expect(63 "expression f", substrs=["ID = 123456", 'Name = "Enrico"', "Rate = 1.25"]64 )65