xref: /llvm-project/lldb/test/API/functionalities/data-formatter/compactvectors/TestCompactVectors.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test lldb data formatter subsystem.
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class CompactVectorsFormattingTestCase(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    @skipUnlessDarwin
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
29        self.runCmd("run", RUN_SUCCEEDED)
30
31        # The stop reason of the thread should be breakpoint.
32        self.expect(
33            "thread list",
34            STOPPED_DUE_TO_BREAKPOINT,
35            substrs=["stopped", "stop reason = breakpoint"],
36        )
37
38        # This is the function to remove the custom formats in order to have a
39        # clean slate for the next test case.
40        def cleanup():
41            self.runCmd("type summary clear", check=False)
42
43        # Execute the cleanup function during test case tear down.
44        self.addTearDownHook(cleanup)
45
46        self.expect(
47            "frame variable",
48            substrs=[
49                "(vFloat) valueFL = (1.25, 0, 0.25, 0)",
50                "(vDouble) valueDL = (1.25, 2.25)",
51                "(int16_t[8]) valueI16 = (1, 0, 4, 0, 0, 1, 0, 4)",
52                "(int32_t[4]) valueI32 = (1, 0, 4, 0)",
53                "(vUInt8) valueU8 = (0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)",
54                "(vUInt16) valueU16 = (1, 0, 4, 0, 0, 1, 0, 4)",
55                "(vUInt32) valueU32 = (1, 2, 3, 4)",
56                "(vSInt8) valueS8 = (1, 0, 4, 0, 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0)",
57                "(vSInt16) valueS16 = (1, 0, 4, 0, 0, 1, 0, 4)",
58                "(vSInt32) valueS32 = (4, 3, 2, 1)",
59                "(vBool32) valueBool32 = (0, 1, 0, 1)",
60            ],
61        )
62