68 lines · python
1"""2Test that the user can input a format but it will not prevail over summary format's choices.3"""4 5 6import lldb7from lldbsuite.test.lldbtest import *8import lldbsuite.test.lldbutil as lldbutil9 10 11class UserFormatVSSummaryTestCase(TestBase):12 def setUp(self):13 # Call super's setUp().14 TestBase.setUp(self)15 # Find the line number to break at.16 self.line = line_number("main.cpp", "// Set break point at this line.")17 18 def test_with_run_command(self):19 """Test that the user can input a format but it will not prevail over summary format's choices."""20 self.build()21 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)22 23 lldbutil.run_break_set_by_file_and_line(24 self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True25 )26 27 self.runCmd("run", RUN_SUCCEEDED)28 29 # The stop reason of the thread should be breakpoint.30 self.expect(31 "thread list",32 STOPPED_DUE_TO_BREAKPOINT,33 substrs=["stopped", "stop reason = breakpoint"],34 )35 36 self.expect("frame variable p1", substrs=["(Pair) p1 = (x = 3, y = -3)"])37 38 # This is the function to remove the custom formats in order to have a39 # clean slate for the next test case.40 def cleanup():41 self.runCmd("type format clear", check=False)42 self.runCmd("type summary clear", check=False)43 44 # Execute the cleanup function during test case tear down.45 self.addTearDownHook(cleanup)46 47 self.runCmd('type summary add Pair -s "x=${var.x%d},y=${var.y%u}"')48 49 self.expect("frame variable p1", substrs=["(Pair) p1 = x=3,y=4294967293"])50 self.expect(51 "frame variable -f x p1",52 substrs=["(Pair) p1 = x=0x00000003,y=0xfffffffd"],53 matching=False,54 )55 self.expect(56 "frame variable -f d p1", substrs=["(Pair) p1 = x=3,y=-3"], matching=False57 )58 self.expect("frame variable p1", substrs=["(Pair) p1 = x=3,y=4294967293"])59 60 self.runCmd('type summary add Pair -s "x=${var.x%x},y=${var.y%u}"')61 62 self.expect(63 "frame variable p1", substrs=["(Pair) p1 = x=0x00000003,y=4294967293"]64 )65 self.expect(66 "frame variable -f d p1", substrs=["(Pair) p1 = x=3,y=-3"], matching=False67 )68