2 Test some lldb help commands.
4 See also CommandInterpreter::OutputFormattedHelpText().
7 from __future__ import print_function
13 from lldbsuite.test.lldbtest import *
15 class HelpCommandTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
20 def test_simplehelp(self):
21 """A simple test of 'help' command and its output."""
23 startstr = 'Debugger commands:')
25 self.expect("help -a", matching=False,
28 self.expect("help", matching=True,
32 def test_help_on_help(self):
33 """Testing the help on the help facility."""
34 self.expect("help help", matching=True,
35 substrs = ['--hide-aliases',
36 '--hide-user-commands'])
39 def version_number_string(self):
40 """Helper function to find the version number string of lldb."""
41 plist = os.path.join(os.environ["LLDB_SRC"], "resources", "LLDB-Info.plist")
43 CFBundleVersionSegFound = False
44 with open(plist, 'r') as f:
46 if CFBundleVersionSegFound:
47 version_line = line.strip()
49 m = re.match("<string>(.*)</string>", version_line)
54 # Unsuccessful, let's juts break out of the for loop.
57 if line.find("<key>CFBundleVersion</key>") != -1:
58 # Found our match. The next line contains our version
59 # string, for example:
62 CFBundleVersionSegFound = True
70 # Use None to signify that we are not able to grok the version number.
74 def test_help_arch(self):
75 """Test 'help arch' which should list of supported architectures."""
76 self.expect("help arch",
77 substrs = ['arm', 'x86_64', 'i386'])
80 def test_help_version(self):
81 """Test 'help version' and 'version' commands."""
82 self.expect("help version",
83 substrs = ['Show version of LLDB debugger.'])
84 version_str = self.version_number_string()
86 match = re.match('[0-9]+', version_str)
87 if sys.platform.startswith("darwin"):
88 search_regexp = ['lldb-' + (version_str if match else '[0-9]+')]
90 search_regexp = ['lldb version (\d|\.)+.*$']
92 self.expect("version",
93 patterns = search_regexp)
96 def test_help_should_not_crash_lldb(self):
97 """Command 'help disasm' should not crash lldb."""
98 self.runCmd("help disasm", check=False)
99 self.runCmd("help unsigned-integer")
102 def test_help_should_not_hang_emacsshell(self):
103 """Command 'settings set term-width 0' should not hang the help command."""
104 self.expect("settings set term-width 0",
105 COMMAND_FAILED_AS_EXPECTED, error=True,
106 substrs = ['error: 0 is out of range, valid values must be between'])
107 # self.runCmd("settings set term-width 0")
109 startstr = 'Debugger commands:')
112 def test_help_breakpoint_set(self):
113 """Test that 'help breakpoint set' does not print out redundant lines of:
114 'breakpoint set [-s <shlib-name>] ...'."""
115 self.expect("help breakpoint set", matching=False,
116 substrs = ['breakpoint set [-s <shlib-name>]'])
119 def test_help_image_dump_symtab_should_not_crash(self):
120 """Command 'help image dump symtab' should not crash lldb."""
121 # 'image' is an alias for 'target modules'.
122 self.expect("help image dump symtab",
123 substrs = ['dump symtab',
127 def test_help_image_du_sym_is_ambiguous(self):
128 """Command 'help image du sym' is ambiguous and spits out the list of candidates."""
129 self.expect("help image du sym",
130 COMMAND_FAILED_AS_EXPECTED, error=True,
131 substrs = ['error: ambiguous command image du sym',
136 def test_help_image_du_line_should_work(self):
137 """Command 'help image du line-table' is not ambiguous and should work."""
138 # 'image' is an alias for 'target modules'.
139 self.expect("help image du line",
140 substrs = ['Dump the line table for one or more compilation units'])
143 def test_help_target_variable_syntax(self):
144 """Command 'help target variable' should display <variable-name> ..."""
145 self.expect("help target variable",
146 substrs = ['<variable-name> [<variable-name> [...]]'])
149 def test_help_watchpoint_and_its_args(self):
150 """Command 'help watchpoint', 'help watchpt-id', and 'help watchpt-id-list' should work."""
151 self.expect("help watchpoint",
152 substrs = ['delete', 'disable', 'enable', 'list'])
153 self.expect("help watchpt-id",
154 substrs = ['<watchpt-id>'])
155 self.expect("help watchpt-id-list",
156 substrs = ['<watchpt-id-list>'])
159 def test_help_watchpoint_set(self):
160 """Test that 'help watchpoint set' prints out 'expression' and 'variable'
161 as the possible subcommands."""
162 self.expect("help watchpoint set",
163 substrs = ['The following subcommands are supported:'],
164 patterns = ['expression +--',