brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · ce0357e Raw
71 lines · python
1# encoding: utf-82"""3Test lldb data formatter subsystem.4"""5 6 7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase13 14 15class ObjCDataFormatterExpr(ObjCDataFormatterTestCase):16    def test_expr_with_run_command(self):17        """Test common cases of expression parser <--> formatters interaction."""18        self.build()19        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(20            self, "// Set break point at this line.", lldb.SBFileSpec("main.m", False)21        )22 23        # The stop reason of the thread should be breakpoint.24        self.expect(25            "thread list",26            STOPPED_DUE_TO_BREAKPOINT,27            substrs=["stopped", "stop reason = breakpoint"],28        )29 30        self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")31 32        # This is the function to remove the custom formats in order to have a33        # clean slate for the next test case.34        def cleanup():35            self.runCmd("type format clear", check=False)36            self.runCmd("type summary clear", check=False)37            self.runCmd("type synth clear", check=False)38 39        # Execute the cleanup function during test case tear down.40        self.addTearDownHook(cleanup)41 42        # check that the formatters are able to deal safely and correctly43        # with ValueObjects that the expression parser returns44        self.expect(45            'expression ((id)@"Hello for long enough to avoid short string types")',46            matching=False,47            substrs=["Hello for long enough to avoid short string types"],48        )49 50        self.expect(51            'expression -d run -- ((id)@"Hello for long enough to avoid short string types")',52            substrs=["Hello for long enough to avoid short string types"],53        )54 55        self.expect("expr -d run -- label1", substrs=["Process Name"])56 57        self.expect(58            'expr -d run -- @"Hello for long enough to avoid short string types"',59            substrs=["Hello for long enough to avoid short string types"],60        )61 62        self.expect(63            'expr -d run --object-description -- @"Hello for long enough to avoid short string types"',64            substrs=["Hello for long enough to avoid short string types"],65        )66        self.expect(67            'expr -d run --object-description -- @"Hello"',68            matching=False,69            substrs=['@"Hello" Hello'],70        )71