]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/help/TestHelp.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / help / TestHelp.py
1 """
2 Test some lldb help commands.
3
4 See also CommandInterpreter::OutputFormattedHelpText().
5 """
6
7 from __future__ import print_function
8
9
10
11 import os, time
12 import lldb
13 from lldbsuite.test.lldbtest import *
14
15 class HelpCommandTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     @no_debug_info_test
20     def test_simplehelp(self):
21         """A simple test of 'help' command and its output."""
22         self.expect("help",
23             startstr = 'Debugger commands:')
24
25         self.expect("help -a", matching=False,
26                     substrs = ['next'])
27         
28         self.expect("help", matching=True,
29                     substrs = ['next'])
30     
31     @no_debug_info_test
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'])
37
38     @no_debug_info_test
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")
42         try:
43             CFBundleVersionSegFound = False
44             with open(plist, 'r') as f:
45                 for line in f:
46                     if CFBundleVersionSegFound:
47                         version_line = line.strip()
48                         import re
49                         m = re.match("<string>(.*)</string>", version_line)
50                         if m:
51                             version = m.group(1)
52                             return version
53                         else:
54                             # Unsuccessful, let's juts break out of the for loop.
55                             break
56
57                     if line.find("<key>CFBundleVersion</key>") != -1:
58                         # Found our match.  The next line contains our version
59                         # string, for example:
60                         # 
61                         #     <string>38</string>
62                         CFBundleVersionSegFound = True
63
64         except:
65             # Just fallthrough...
66             import traceback
67             traceback.print_exc()
68             pass
69
70         # Use None to signify that we are not able to grok the version number.
71         return None
72
73     @no_debug_info_test
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'])
78
79     @no_debug_info_test
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()
85         import re
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]+')]
89         else:
90             search_regexp = ['lldb version (\d|\.)+.*$']
91
92         self.expect("version",
93             patterns = search_regexp)
94
95     @no_debug_info_test
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")
100
101     @no_debug_info_test
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")
108         self.expect("help",
109             startstr = 'Debugger commands:')
110
111     @no_debug_info_test
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>]'])
117
118     @no_debug_info_test
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',
124                        'sort-order'])
125
126     @no_debug_info_test
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',
132                        'symfile',
133                        'symtab'])
134
135     @no_debug_info_test
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'])
141
142     @no_debug_info_test
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> [...]]'])
147
148     @no_debug_info_test
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>'])
157
158     @no_debug_info_test
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 +--',
165                         'variable +--'])