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