1""" 2Test lldb data formatter subsystem. 3""" 4 5 6 7import lldb 8from lldbsuite.test.lldbtest import * 9import lldbsuite.test.lldbutil as lldbutil 10 11 12class EnumFormatTestCase(TestBase): 13 14 def setUp(self): 15 # Call super's setUp(). 16 TestBase.setUp(self) 17 # Find the line number to break at. 18 self.line = line_number('main.cpp', '// Set break point at this line.') 19 20 def test_with_run_command(self): 21 """Test that that file and class static variables display correctly.""" 22 self.build() 23 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 24 25 lldbutil.run_break_set_by_file_and_line( 26 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 27 28 self.runCmd("run", RUN_SUCCEEDED) 29 30 # The stop reason of the thread should be breakpoint. 31 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 32 substrs=['stopped', 33 'stop reason = breakpoint']) 34 35 self.expect("frame variable", 36 substrs=['(Foo) f = Case45', 37 '(int) x = 1', 38 '(int) y = 45', 39 '(int) z = 43' 40 ]) 41 42 # This is the function to remove the custom formats in order to have a 43 # clean slate for the next test case. 44 def cleanup(): 45 self.runCmd('type format clear', check=False) 46 self.runCmd('type summary clear', check=False) 47 48 # Execute the cleanup function during test case tear down. 49 self.addTearDownHook(cleanup) 50 51 self.runCmd("type format add --type Foo int") 52 53 # The type format list should show our custom formats. 54 self.expect("type format list -w default", 55 substrs=['int: as type Foo']) 56 57 self.expect("frame variable", 58 substrs=['(Foo) f = Case45', 59 '(int) x = Case1', 60 '(int) y = Case45', 61 '(int) z = 43' 62 ]) 63