Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 1 | """Test lldb help command.""" |
| 2 | |
Johnny Chen | cb9b857 | 2010-06-29 23:10:39 +0000 | [diff] [blame^] | 3 | import os |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 4 | import lldb |
| 5 | import unittest |
| 6 | |
| 7 | class TestHelpCommand(unittest.TestCase): |
| 8 | |
| 9 | def setUp(self): |
Johnny Chen | cb9b857 | 2010-06-29 23:10:39 +0000 | [diff] [blame^] | 10 | # Save old working directory. |
| 11 | self.oldcwd = os.getcwd() |
| 12 | # Change current working directory if ${LLDB_TEST} is defined. |
| 13 | if ("LLDB_TEST" in os.environ): |
| 14 | os.chdir(os.path.join(os.environ["LLDB_TEST"], "help")); |
| 15 | self.dbg = lldb.SBDebugger.Create() |
| 16 | self.dbg.SetAsync(False) |
| 17 | self.ci = self.dbg.GetCommandInterpreter() |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 18 | if not self.ci: |
| 19 | raise Exception('Could not get the command interpreter') |
| 20 | |
| 21 | def tearDown(self): |
Johnny Chen | cb9b857 | 2010-06-29 23:10:39 +0000 | [diff] [blame^] | 22 | # Restore old working directory. |
| 23 | os.chdir(self.oldcwd) |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 24 | |
| 25 | def test_simplehelp(self): |
| 26 | """A simple test of 'help' command and its output.""" |
| 27 | res = lldb.SBCommandReturnObject() |
Johnny Chen | 7e363f5 | 2010-06-28 20:55:57 +0000 | [diff] [blame] | 28 | self.ci.HandleCommand("help", res) |
| 29 | self.assertTrue(res.Succeeded()) |
| 30 | self.assertTrue(res.GetOutput().startswith( |
| 31 | 'The following is a list of built-in, permanent debugger commands')) |
Johnny Chen | 7e363f5 | 2010-06-28 20:55:57 +0000 | [diff] [blame] | 32 | |
| 33 | def test_help_should_not_hang_emacsshell(self): |
| 34 | """'set term-width 0' should not hang the help command.""" |
| 35 | res = lldb.SBCommandReturnObject() |
| 36 | self.ci.HandleCommand("set term-width 0", res) |
| 37 | self.assertTrue(res.Succeeded()) |
| 38 | self.ci.HandleCommand("help", res) |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 39 | self.assertTrue(res.Succeeded()) |
| 40 | self.assertTrue(res.GetOutput().startswith( |
| 41 | 'The following is a list of built-in, permanent debugger commands')) |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | if __name__ == '__main__': |
Johnny Chen | 4657be6 | 2010-06-29 19:44:16 +0000 | [diff] [blame] | 45 | lldb.SBDebugger.Initialize() |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 46 | unittest.main() |
Johnny Chen | 4657be6 | 2010-06-29 19:44:16 +0000 | [diff] [blame] | 47 | lldb.SBDebugger.Terminate() |