llunak created this revision. llunak added a reviewer: clayborg. llunak requested review of this revision.
The test needs the python curses module, to get the proper escape sequence to send the down key event. I'm not sure if it's ok to just use the module, or if some check for it should be added too. Repository: rLLDB LLDB 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,77 @@ +""" +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 +from curses import * + +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() + setupterm() # curses + down_key = tigetstr("kcud1") + + # 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,77 @@ +""" +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 +from curses import * + +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() + setupterm() # curses + down_key = tigetstr("kcud1") + + # 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