1""" 2Test completion for multiline expressions. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test.lldbpexpect import PExpectTest 9 10class MultilineCompletionTest(PExpectTest): 11 12 def start_expression_editor(self): 13 """ Starts the multiline expression editor. """ 14 self.child.send("expression\n") 15 self.child.expect_exact("terminate with an empty line to evaluate") 16 17 def exit_expression_editor(self): 18 """ Exits the multiline expression editor. """ 19 # Send a newline to finish the current line. The second newline will 20 # finish the new empty line which will exit the editor. The space at the 21 # start prevents that the first newline already exits the editor (in 22 # case the current line of the editor is already empty when this 23 # function is called). 24 self.child.send(" \n\n") 25 self.expect_prompt() 26 27 # PExpect uses many timeouts internally and doesn't play well 28 # under ASAN on a loaded machine.. 29 @skipIfAsan 30 @skipIfEditlineSupportMissing 31 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr49408') 32 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) 33 def test_basic_completion(self): 34 """Test that we can complete a simple multiline expression""" 35 self.build() 36 37 self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500)) 38 self.expect("b main", substrs=["Breakpoint 1", "address ="]) 39 self.expect("run", substrs=["stop reason = breakpoint 1"]) 40 41 self.start_expression_editor() 42 self.child.send("to_\t") 43 # editline might move the cursor back to the start of the line via \r 44 # and then back to its original position. 45 self.child.expect(re.compile(b"to_(\r" + self.cursor_forward_escape_seq(len(" 1: to_")) + b")?complete")) 46 self.exit_expression_editor() 47 48 # Check that completion empty input in a function with only one 49 # local variable works. 50 self.expect("breakpoint set -p 'break in single_local_func'", 51 substrs=["Breakpoint 2"]) 52 self.expect("continue", substrs=["stop reason = breakpoint 2"]) 53 self.start_expression_editor() 54 self.child.send("\t") 55 # Only one local, so this will directly insert 'only_local' with a 56 # trailing space to signal a final completion. 57 self.child.expect_exact("only_local ") 58 self.exit_expression_editor() 59 60 self.quit() 61