llunak updated this revision to Diff 282543. llunak edited the summary of this revision. llunak added a comment.
Removed use of curses python module, lldbexpect hardcodes TERM=vt100, so the escape sequence should be actually hardcoded too. The previous version didn't work e.g. in Linux console. Repository: rLLDB LLDB CHANGES SINCE LAST ACTION https://reviews.llvm.org/D85107/new/ https://reviews.llvm.org/D85107 Files: lldb/test/API/commands/gui/breakpoints/Makefile lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py lldb/test/API/commands/gui/breakpoints/main.c Index: lldb/test/API/commands/gui/breakpoints/main.c =================================================================== --- /dev/null +++ lldb/test/API/commands/gui/breakpoints/main.c @@ -0,0 +1,6 @@ +int main(int argc, char **argv) { + int var1 = 1; // First break here + int var2 = 2; + int var3 = 3; + return var1 + var2 + var3; +} Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py =================================================================== --- /dev/null +++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py @@ -0,0 +1,75 @@ +""" +Test the 'gui' shortcut 'b' (toggle breakpoint). +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbpexpect import PExpectTest + +class TestGuiBasicDebugCommandTest(PExpectTest): + + mydir = TestBase.compute_mydir(__file__) + + # PExpect uses many timeouts internally and doesn't play well + # under ASAN on a loaded machine.. + @skipIfAsan + @skipIfCursesSupportMissing + @skipIfRemote # "run" command will not work correctly for remote debug + def test_gui(self): + self.build() + + self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500)) + self.expect('br set -o true -f main.c -p "// First break here"', substrs=["Breakpoint 1", "address ="]) + self.expect("run", substrs=["stop reason ="]) + + self.child.sendline("breakpoint list") + self.child.expect_exact("No breakpoints currently set.") + + escape_key = chr(27).encode() + down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets TERM=vt100) + + # Start the GUI and close the welcome window. + self.child.sendline("gui") + self.child.send(escape_key) + self.child.expect_exact("Sources") # wait for gui + + # Go to next line, set a breakpoint. + self.child.send(down_key) + self.child.send('b') + self.child.send(escape_key) + self.expect_prompt() + self.child.sendline("breakpoint list") + self.child.expect("2: file = '[^']*main.c', line = 3,.*") + self.child.sendline("gui") + self.child.expect_exact("Sources") + + # Go two lines down ("gui" resets position), set a breakpoint. + self.child.send(down_key) + self.child.send(down_key) + self.child.send('b') + self.child.send(escape_key) + self.expect_prompt() + self.child.sendline("breakpoint list") + self.child.expect("2: file = '[^']*main.c', line = 3,") + self.child.expect("3: file = '[^']*main.c', line = 4,") + self.child.sendline("gui") + self.child.expect_exact("Sources") + + # Toggle both the breakpoints (remove them). + self.child.send(down_key) + self.child.send('b') + self.child.send(down_key) + self.child.send('b') + self.child.send(escape_key) + self.expect_prompt() + self.child.sendline("breakpoint list") + self.child.expect_exact("No breakpoints currently set.") + self.child.sendline("gui") + self.child.expect_exact("Sources") + + # Press escape to quit the gui + self.child.send(escape_key) + + self.expect_prompt() + self.quit() Index: lldb/test/API/commands/gui/breakpoints/Makefile =================================================================== --- /dev/null +++ lldb/test/API/commands/gui/breakpoints/Makefile @@ -0,0 +1,2 @@ +C_SOURCES := main.c +include Makefile.rules
Index: lldb/test/API/commands/gui/breakpoints/main.c =================================================================== --- /dev/null +++ lldb/test/API/commands/gui/breakpoints/main.c @@ -0,0 +1,6 @@ +int main(int argc, char **argv) { + int var1 = 1; // First break here + int var2 = 2; + int var3 = 3; + return var1 + var2 + var3; +} Index: lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py =================================================================== --- /dev/null +++ lldb/test/API/commands/gui/breakpoints/TestGuiBreakpoints.py @@ -0,0 +1,75 @@ +""" +Test the 'gui' shortcut 'b' (toggle breakpoint). +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test.lldbpexpect import PExpectTest + +class TestGuiBasicDebugCommandTest(PExpectTest): + + mydir = TestBase.compute_mydir(__file__) + + # PExpect uses many timeouts internally and doesn't play well + # under ASAN on a loaded machine.. + @skipIfAsan + @skipIfCursesSupportMissing + @skipIfRemote # "run" command will not work correctly for remote debug + def test_gui(self): + self.build() + + self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500)) + self.expect('br set -o true -f main.c -p "// First break here"', substrs=["Breakpoint 1", "address ="]) + self.expect("run", substrs=["stop reason ="]) + + self.child.sendline("breakpoint list") + self.child.expect_exact("No breakpoints currently set.") + + escape_key = chr(27).encode() + down_key = chr(27)+'OB' # for vt100 terminal (lldbexpect sets TERM=vt100) + + # Start the GUI and close the welcome window. + self.child.sendline("gui") + self.child.send(escape_key) + self.child.expect_exact("Sources") # wait for gui + + # Go to next line, set a breakpoint. + self.child.send(down_key) + self.child.send('b') + self.child.send(escape_key) + self.expect_prompt() + self.child.sendline("breakpoint list") + self.child.expect("2: file = '[^']*main.c', line = 3,.*") + self.child.sendline("gui") + self.child.expect_exact("Sources") + + # Go two lines down ("gui" resets position), set a breakpoint. + self.child.send(down_key) + self.child.send(down_key) + self.child.send('b') + self.child.send(escape_key) + self.expect_prompt() + self.child.sendline("breakpoint list") + self.child.expect("2: file = '[^']*main.c', line = 3,") + self.child.expect("3: file = '[^']*main.c', line = 4,") + self.child.sendline("gui") + self.child.expect_exact("Sources") + + # Toggle both the breakpoints (remove them). + self.child.send(down_key) + self.child.send('b') + self.child.send(down_key) + self.child.send('b') + self.child.send(escape_key) + self.expect_prompt() + self.child.sendline("breakpoint list") + self.child.expect_exact("No breakpoints currently set.") + self.child.sendline("gui") + self.child.expect_exact("Sources") + + # Press escape to quit the gui + self.child.send(escape_key) + + self.expect_prompt() + self.quit() Index: lldb/test/API/commands/gui/breakpoints/Makefile =================================================================== --- /dev/null +++ lldb/test/API/commands/gui/breakpoints/Makefile @@ -0,0 +1,2 @@ +C_SOURCES := main.c +include Makefile.rules
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits