blob: 56ec504ff65dd2c1a616dc05a00a9007315821d1 [file] [log] [blame]
Johnny Chen9320d4a2010-06-25 23:15:47 +00001"""Test lldb help command."""
2
Johnny Chencb9b8572010-06-29 23:10:39 +00003import os
Johnny Chen9320d4a2010-06-25 23:15:47 +00004import lldb
5import unittest
6
7class TestHelpCommand(unittest.TestCase):
8
9 def setUp(self):
Johnny Chencb9b8572010-06-29 23:10:39 +000010 # 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 Chen9320d4a2010-06-25 23:15:47 +000018 if not self.ci:
19 raise Exception('Could not get the command interpreter')
20
21 def tearDown(self):
Johnny Chencb9b8572010-06-29 23:10:39 +000022 # Restore old working directory.
23 os.chdir(self.oldcwd)
Johnny Chen9320d4a2010-06-25 23:15:47 +000024
25 def test_simplehelp(self):
26 """A simple test of 'help' command and its output."""
27 res = lldb.SBCommandReturnObject()
Johnny Chen7e363f52010-06-28 20:55:57 +000028 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 Chen7e363f52010-06-28 20:55:57 +000032
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 Chen9320d4a2010-06-25 23:15:47 +000039 self.assertTrue(res.Succeeded())
40 self.assertTrue(res.GetOutput().startswith(
41 'The following is a list of built-in, permanent debugger commands'))
Johnny Chen9320d4a2010-06-25 23:15:47 +000042
43
44if __name__ == '__main__':
Johnny Chen4657be62010-06-29 19:44:16 +000045 lldb.SBDebugger.Initialize()
Johnny Chen9320d4a2010-06-25 23:15:47 +000046 unittest.main()
Johnny Chen4657be62010-06-29 19:44:16 +000047 lldb.SBDebugger.Terminate()