1""" 2Test that the 'gui' displays long lines/names correctly without overruns. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test.lldbpexpect import PExpectTest 9 10class GuiViewLargeCommandTest(PExpectTest): 11 12 mydir = TestBase.compute_mydir(__file__) 13 14 # PExpect uses many timeouts internally and doesn't play well 15 # under ASAN on a loaded machine.. 16 @skipIfAsan 17 @skipIfCursesSupportMissing 18 @skipIfRemote # "run" command will not work correctly for remote debug 19 @expectedFailureNetBSD 20 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) 21 def test_gui(self): 22 self.build() 23 24 # Limit columns to 80, so that long lines will not be displayed completely. 25 self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,80)) 26 self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="]) 27 self.expect("run", substrs=["stop reason ="]) 28 29 escape_key = chr(27).encode() 30 left_key = chr(27)+'OD' # for vt100 terminal (lldbexpect sets TERM=vt100) 31 right_key = chr(27)+'OC' 32 ctrl_l = chr(12) 33 34 # Start the GUI and close the welcome window. 35 self.child.sendline("gui") 36 self.child.send(escape_key) 37 38 # Check the sources window. 39 self.child.expect_exact("Sources") 40 # The string is copy&pasted from a 80-columns terminal. It will be followed by some 41 # kind of an escape sequence (color, frame, etc.). 42 self.child.expect_exact("int a_variable_with_a_very_looooooooooooooooooooooooooo"+chr(27)) 43 # The escape here checks that there's no content drawn by the previous line. 44 self.child.expect_exact("int shortvar = 1;"+chr(27)) 45 # Check the triggered breakpoint marker on a long line. 46 self.child.expect_exact("<<< Thread 1: breakpoint 1.1"+chr(27)) 47 48 # Check the variable window. 49 self.child.expect_exact("Variables") 50 self.child.expect_exact("(int) a_variable_with_a_very_looooooooooooooooooooooooooooooo"+chr(27)) 51 self.child.expect_exact("(int) shortvar = 1"+chr(27)) 52 53 # Scroll the sources view twice to the right. 54 self.child.send(right_key) 55 self.child.send(right_key) 56 # Force a redraw, otherwise curses will optimize the drawing to not draw all 'o'. 57 self.child.send(ctrl_l) 58 # The source code is indented by two spaces, so there'll be just two extra 'o' on the right. 59 self.child.expect_exact("int a_variable_with_a_very_looooooooooooooooooooooooooooo"+chr(27)) 60 61 # And scroll back to the left. 62 self.child.send(left_key) 63 self.child.send(left_key) 64 self.child.send(ctrl_l) 65 self.child.expect_exact("int a_variable_with_a_very_looooooooooooooooooooooooooo"+chr(27)) 66 67 # Press escape to quit the gui 68 self.child.send(escape_key) 69 70 self.expect_prompt() 71 self.quit() 72