brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 1cff7f1 Raw
58 lines · python
1"""2Tests target.expr-error-limit.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class TestCase(TestBase):12    @no_debug_info_test13    def test(self):14        # FIXME: The only reason this test needs to create a real target is because15        # the settings of the dummy target can't be changed with `settings set`.16        self.build()17        target = self.createTestTarget()18 19        # Our test expression that is just several lines of malformed20        # integer literals (with a 'yerror' integer suffix). Every error21        # has its own unique string (1, 2, 3, 4) and is on its own line22        # that we can later find it when Clang prints the respective source23        # code for each error to the error output.24        # For example, in the error output below we would look for the25        # unique `1yerror` string:26        #     error: <expr>:1:2: invalid suffix 'yerror' on integer constant27        #     1yerror28        #     ^29        expr = "1yerror;\n2yerror;\n3yerror;\n4yerror;"30 31        options = lldb.SBExpressionOptions()32        options.SetAutoApplyFixIts(False)33 34        # Evaluate the expression and check that only the first 2 errors are35        # emitted.36        self.runCmd("settings set target.expr-error-limit 2")37        eval_result = target.EvaluateExpression(expr, options)38        self.assertIn("1yerror", str(eval_result.GetError()))39        self.assertIn("2yerror", str(eval_result.GetError()))40        self.assertNotIn("3yerror", str(eval_result.GetError()))41        self.assertNotIn("4yerror", str(eval_result.GetError()))42 43        # Change to a 3 errors and check again which errors are emitted.44        self.runCmd("settings set target.expr-error-limit 3")45        eval_result = target.EvaluateExpression(expr, options)46        self.assertIn("1yerror", str(eval_result.GetError()))47        self.assertIn("2yerror", str(eval_result.GetError()))48        self.assertIn("3yerror", str(eval_result.GetError()))49        self.assertNotIn("4yerror", str(eval_result.GetError()))50 51        # Disable the error limit and make sure all errors are emitted.52        self.runCmd("settings set target.expr-error-limit 0")53        eval_result = target.EvaluateExpression(expr, options)54        self.assertIn("1yerror", str(eval_result.GetError()))55        self.assertIn("2yerror", str(eval_result.GetError()))56        self.assertIn("3yerror", str(eval_result.GetError()))57        self.assertIn("4yerror", str(eval_result.GetError()))58