Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / packages / Python / lldbsuite / test / dotest_args.py
blob70a65078f1d3a88187c43aa5d4dc3b7918af1cb9
1 # System modules
2 import argparse
3 import sys
4 import os
5 import textwrap
7 # LLDB modules
8 from . import configuration
11 def create_parser():
12 parser = argparse.ArgumentParser(
13 description="description", prefix_chars="+-", add_help=False
15 group = None
17 # Helper function for boolean options (group will point to the current
18 # group when executing X)
19 X = lambda optstr, helpstr, **kwargs: group.add_argument(
20 optstr, help=helpstr, action="store_true", **kwargs
23 group = parser.add_argument_group("Help")
24 group.add_argument(
25 "-h",
26 "--help",
27 dest="h",
28 action="store_true",
29 help="Print this help message and exit. Add '-v' for more detailed help.",
32 # C and Python toolchain options
33 group = parser.add_argument_group("Toolchain options")
34 group.add_argument(
35 "-A",
36 "--arch",
37 metavar="arch",
38 dest="arch",
39 help=textwrap.dedent(
40 """Specify the architecture(s) to test. This option can be specified more than once"""
43 group.add_argument(
44 "-C",
45 "--compiler",
46 metavar="compiler",
47 dest="compiler",
48 help=textwrap.dedent(
49 """Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times."""
52 if sys.platform == "darwin":
53 group.add_argument(
54 "--apple-sdk",
55 metavar="apple_sdk",
56 dest="apple_sdk",
57 default="",
58 help=textwrap.dedent(
59 """Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK's toolchain."""
62 group.add_argument(
63 "--libcxx-include-dir",
64 help=textwrap.dedent(
65 "Specify the path to a custom libc++ include directory. Must be used in conjunction with --libcxx-library-dir."
68 group.add_argument(
69 "--libcxx-include-target-dir",
70 help=textwrap.dedent(
71 "Specify the path to a custom libc++ include target directory to use in addition to --libcxx-include-dir. Optional."
74 group.add_argument(
75 "--libcxx-library-dir",
76 help=textwrap.dedent(
77 "Specify the path to a custom libc++ library directory. Must be used in conjunction with --libcxx-include-dir."
80 # FIXME? This won't work for different extra flags according to each arch.
81 group.add_argument(
82 "-E",
83 metavar="extra-flags",
84 help=textwrap.dedent(
85 """Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged
86 suggestions: do not lump the "-A arch1 -A arch2" together such that the -E option applies to only one of the architectures"""
90 group.add_argument(
91 "--dsymutil",
92 metavar="dsymutil",
93 dest="dsymutil",
94 help=textwrap.dedent("Specify which dsymutil to use."),
96 group.add_argument(
97 "--llvm-tools-dir",
98 metavar="dir",
99 dest="llvm_tools_dir",
100 help=textwrap.dedent(
101 "The location of llvm tools used for testing (yaml2obj, FileCheck, etc.)."
105 # Test filtering options
106 group = parser.add_argument_group("Test filtering options")
107 group.add_argument(
108 "-f",
109 metavar="filterspec",
110 action="append",
111 help=(
112 'Specify a filter, which looks like "TestModule.TestClass.test_name". '
113 + "You may also use shortened filters, such as "
114 + '"TestModule.TestClass", "TestClass.test_name", or just "test_name".'
117 group.add_argument(
118 "-p",
119 metavar="pattern",
120 help="Specify a regexp filename pattern for inclusion in the test suite",
122 group.add_argument(
123 "--excluded",
124 metavar="exclusion-file",
125 action="append",
126 help=textwrap.dedent(
127 """Specify a file for tests to exclude. File should contain lists of regular expressions for test files or methods,
128 with each list under a matching header (xfail files, xfail methods, skip files, skip methods)"""
131 group.add_argument(
132 "-G",
133 "--category",
134 metavar="category",
135 action="append",
136 dest="categories_list",
137 help=textwrap.dedent(
138 """Specify categories of test cases of interest. Can be specified more than once."""
141 group.add_argument(
142 "--skip-category",
143 metavar="category",
144 action="append",
145 dest="skip_categories",
146 help=textwrap.dedent(
147 """Specify categories of test cases to skip. Takes precedence over -G. Can be specified more than once."""
150 group.add_argument(
151 "--xfail-category",
152 metavar="category",
153 action="append",
154 dest="xfail_categories",
155 help=textwrap.dedent(
156 """Specify categories of test cases that are expected to fail. Can be specified more than once."""
160 # Configuration options
161 group = parser.add_argument_group("Configuration options")
162 group.add_argument(
163 "--framework", metavar="framework-path", help="The path to LLDB.framework"
165 group.add_argument(
166 "--executable",
167 metavar="executable-path",
168 help="The path to the lldb executable",
170 group.add_argument(
171 "--out-of-tree-debugserver",
172 dest="out_of_tree_debugserver",
173 action="store_true",
174 help="A flag to indicate an out-of-tree debug server is being used",
176 group.add_argument(
177 "--dwarf-version",
178 metavar="dwarf_version",
179 dest="dwarf_version",
180 type=int,
181 help="Override the DWARF version.",
183 group.add_argument(
184 "--setting",
185 metavar="SETTING=VALUE",
186 dest="settings",
187 type=str,
188 nargs=1,
189 action="append",
190 help='Run "setting set SETTING VALUE" before executing any test.',
192 group.add_argument(
193 "-y",
194 type=int,
195 metavar="count",
196 help="Specify the iteration count used to collect our benchmarks. An example is the number of times to do 'thread step-over' to measure stepping speed.",
198 group.add_argument(
199 "-#",
200 type=int,
201 metavar="sharp",
202 dest="sharp",
203 help="Repeat the test suite for a specified number of times",
205 group.add_argument(
206 "--channel",
207 metavar="channel",
208 dest="channels",
209 action="append",
210 help=textwrap.dedent(
211 "Specify the log channels (and optional categories) e.g. 'lldb all' or 'gdb-remote packets' if no categories are specified, 'default' is used"
214 group.add_argument(
215 "--log-success",
216 dest="log_success",
217 action="store_true",
218 help="Leave logs/traces even for successful test runs (useful for creating reference log files during debugging.)",
220 group.add_argument(
221 "--codesign-identity",
222 metavar="Codesigning identity",
223 default="lldb_codesign",
224 help="The codesigning identity to use",
226 group.add_argument(
227 "--build-dir",
228 dest="test_build_dir",
229 metavar="Test build directory",
230 default="lldb-test-build.noindex",
231 help="The root build directory for the tests. It will be removed before running.",
233 group.add_argument(
234 "--lldb-module-cache-dir",
235 dest="lldb_module_cache_dir",
236 metavar="The clang module cache directory used by LLDB",
237 help="The clang module cache directory used by LLDB. Defaults to <test build directory>/module-cache-lldb.",
239 group.add_argument(
240 "--clang-module-cache-dir",
241 dest="clang_module_cache_dir",
242 metavar="The clang module cache directory used by Clang",
243 help="The clang module cache directory used in the Make files by Clang while building tests. Defaults to <test build directory>/module-cache-clang.",
245 group.add_argument(
246 "--lldb-libs-dir",
247 dest="lldb_libs_dir",
248 metavar="path",
249 help="The path to LLDB library directory (containing liblldb)",
251 group.add_argument(
252 "--enable-plugin",
253 dest="enabled_plugins",
254 action="append",
255 type=str,
256 metavar="A plugin whose tests will be enabled",
257 help="A plugin whose tests will be enabled. The only currently supported plugin is intel-pt.",
260 # Configuration options
261 group = parser.add_argument_group("Remote platform options")
262 group.add_argument(
263 "--platform-name",
264 dest="lldb_platform_name",
265 metavar="platform-name",
266 help="The name of a remote platform to use",
268 group.add_argument(
269 "--platform-url",
270 dest="lldb_platform_url",
271 metavar="platform-url",
272 help="A LLDB platform URL to use when connecting to a remote platform to run the test suite",
274 group.add_argument(
275 "--platform-working-dir",
276 dest="lldb_platform_working_dir",
277 metavar="platform-working-dir",
278 help="The directory to use on the remote platform.",
281 # Test-suite behaviour
282 group = parser.add_argument_group("Runtime behaviour options")
284 "-d",
285 "Suspend the process after launch to wait indefinitely for a debugger to attach",
287 X("-t", "Turn on tracing of lldb command and other detailed test executions")
288 group.add_argument(
289 "-u",
290 dest="unset_env_varnames",
291 metavar="variable",
292 action="append",
293 help="Specify an environment variable to unset before running the test cases. e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble",
295 group.add_argument(
296 "--env",
297 dest="set_env_vars",
298 metavar="variable",
299 action="append",
300 help="Specify an environment variable to set to the given value before running the test cases e.g.: --env CXXFLAGS=-O3 --env DYLD_INSERT_LIBRARIES",
302 group.add_argument(
303 "--inferior-env",
304 dest="set_inferior_env_vars",
305 metavar="variable",
306 action="append",
307 help="Specify an environment variable to set to the given value for the inferior.",
310 "-v",
311 "Do verbose mode of unittest framework (print out each test case invocation)",
313 group.add_argument(
314 "--enable-crash-dialog",
315 dest="disable_crash_dialog",
316 action="store_false",
317 help="(Windows only) When LLDB crashes, display the Windows crash dialog.",
319 group.set_defaults(disable_crash_dialog=True)
321 # Remove the reference to our helper function
322 del X
324 group = parser.add_argument_group("Test directories")
325 group.add_argument(
326 "args",
327 metavar="test-dir",
328 nargs="*",
329 help="Specify a list of directory names to search for test modules named after Test*.py (test discovery). If empty, search from the current working directory instead.",
332 return parser