2 from lldbsuite
.test
.decorators
import *
3 from lldbsuite
.test
.lldbtest
import *
4 from lldbsuite
.test
.lldbpexpect
import PExpectTest
7 class TestCase(PExpectTest
):
8 def expect_repl(self
, expr
, substrs
=[]):
9 """Evaluates the expression in the REPL and verifies that the list
10 of substrs is in the REPL output."""
11 # Only single line expressions supported.
12 self
.assertNotIn("\n", expr
)
13 self
.child
.send(expr
+ "\n")
14 for substr
in substrs
:
15 self
.child
.expect_exact(substr
)
16 # Look for the start of the next REPL input line.
17 self
.current_repl_line_number
+= 1
18 self
.child
.expect_exact(str(self
.current_repl_line_number
) + ">")
20 # PExpect uses many timeouts internally and doesn't play well
21 # under ASAN on a loaded machine..
23 @skipIf(oslist
=["linux"], archs
=["arm", "aarch64"]) # Randomly fails on buildbot
24 @skipIfEditlineSupportMissing
25 def test_basic_completion(self
):
26 """Test that we can complete a simple multiline expression"""
28 self
.current_repl_line_number
= 1
30 self
.launch(executable
=self
.getBuildArtifact("a.out"), dimensions
=(100, 500))
31 # Try launching the REPL before we have a running target.
33 "expression --repl -l c --",
34 substrs
=["REPL requires a running target process."],
37 self
.expect("b main", substrs
=["Breakpoint 1", "address ="])
38 self
.expect("run", substrs
=["stop reason = breakpoint 1"])
41 self
.child
.send("expression --repl -l c --\n")
42 self
.child
.expect_exact("1>")
44 # Try evaluating a simple expression.
45 self
.expect_repl("3 + 3", substrs
=["(int) $0 = 6"])
47 # Try declaring a persistent variable.
49 "long $persistent = 7; 5",
50 substrs
=["(int) $1 = 5", "(long) $persistent = 7"],
53 # Try using the persistent variable from before.
54 self
.expect_repl("$persistent + 10", substrs
=["(long) $2 = 17"])