brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 97d91d1 Raw
71 lines · python
1from lldbsuite.test.decorators import *2from lldbsuite.test.lldbpexpect import PExpectTest3from lldbsuite.test.lldbtest import *4 5 6class TestCase(PExpectTest):7    def expect_repl(self, expr, substrs=[]):8        """Evaluates the expression in the REPL and verifies that the list9        of substrs is in the REPL output."""10        # Only single line expressions supported.11        self.assertNotIn("\n", expr)12        self.child.send(expr + "\n")13        for substr in substrs:14            self.child.expect_exact(substr)15        # Look for the start of the next REPL input line.16        self.current_repl_line_number += 117        self.child.expect_exact(str(self.current_repl_line_number) + ">")18 19    def start_repl(self):20        self.build()21        self.current_repl_line_number = 122 23        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 500))24        # Try launching the REPL before we have a running target.25        self.expect(26            "expression --repl -l c --",27            substrs=["REPL requires a running target process."],28        )29 30        self.expect("b main", substrs=["Breakpoint 1", "address ="])31        self.expect("run", substrs=["stop reason = breakpoint 1"])32 33        # Start the REPL.34        self.child.send("expression --repl -l c --\n")35        self.child.expect_exact("1>")36 37    # PExpect uses many timeouts internally and doesn't play well38    # under ASAN on a loaded machine..39    @skipIfAsan40    @skipIf(oslist=["linux"], archs=["arm$", "aarch64"])  # Randomly fails on buildbot41    @skipIfEditlineSupportMissing42    def test_basic_completion(self):43        """Test that we can complete a simple multiline expression"""44        self.start_repl()45        # Try evaluating a simple expression.46        self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])47 48        # Try declaring a persistent variable.49        self.expect_repl(50            "long $persistent = 7; 5",51            substrs=["(int) $1 = 5", "(long) $persistent = 7"],52        )53 54        # Try using the persistent variable from before.55        self.expect_repl("$persistent + 10", substrs=["(long) $2 = 17"])56 57        self.quit()58 59    # PExpect uses many timeouts internally and doesn't play well60    # under ASAN on a loaded machine..61    @skipIfAsan62    @skipIf(oslist=["linux"], archs=["arm$", "aarch64"])  # Randomly fails on buildbot63    @skipIfEditlineSupportMissing64    def test_completion_with_space_only_line(self):65        """Test that we don't crash when completing lines with spaces only"""66        self.start_repl()67 68        self.child.send("   ")69        self.child.send("\t")70        self.expect_repl("3 + 3", substrs=["(int) $0 = 6"])71