1from __future__ import print_function 2from __future__ import absolute_import 3 4# System modules 5import argparse 6import sys 7import os 8import textwrap 9 10# LLDB modules 11from . import configuration 12 13 14def create_parser(): 15 parser = argparse.ArgumentParser( 16 description='description', 17 prefix_chars='+-', 18 add_help=False) 19 group = None 20 21 # Helper function for boolean options (group will point to the current 22 # group when executing X) 23 X = lambda optstr, helpstr, **kwargs: group.add_argument( 24 optstr, help=helpstr, action='store_true', **kwargs) 25 26 group = parser.add_argument_group('Help') 27 group.add_argument( 28 '-h', 29 '--help', 30 dest='h', 31 action='store_true', 32 help="Print this help message and exit. Add '-v' for more detailed help.") 33 34 # C and Python toolchain options 35 group = parser.add_argument_group('Toolchain options') 36 group.add_argument( 37 '-A', 38 '--arch', 39 metavar='arch', 40 dest='arch', 41 help=textwrap.dedent('''Specify the architecture(s) to test. This option can be specified more than once''')) 42 group.add_argument('-C', '--compiler', metavar='compiler', dest='compiler', help=textwrap.dedent( 43 '''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.''')) 44 if sys.platform == 'darwin': 45 group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="macosx", help=textwrap.dedent( 46 '''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.''')) 47 # FIXME? This won't work for different extra flags according to each arch. 48 group.add_argument( 49 '-E', 50 metavar='extra-flags', 51 help=textwrap.dedent('''Specify the extra flags to be passed to the toolchain when building the inferior programs to be debugged 52 suggestions: do not lump the "-A arch1 -A arch2" together such that the -E option applies to only one of the architectures''')) 53 54 group.add_argument('--dsymutil', metavar='dsymutil', dest='dsymutil', help=textwrap.dedent('Specify which dsymutil to use.')) 55 56 group.add_argument('--filecheck', metavar='filecheck', dest='filecheck', help=textwrap.dedent('Specify which FileCheck binary to use.')) 57 58 # Test filtering options 59 group = parser.add_argument_group('Test filtering options') 60 group.add_argument( 61 '-f', 62 metavar='filterspec', 63 action='append', 64 help=('Specify a filter, which looks like "TestModule.TestClass.test_name". '+ 65 'You may also use shortened filters, such as '+ 66 '"TestModule.TestClass", "TestClass.test_name", or just "test_name".')) 67 group.add_argument( 68 '-p', 69 metavar='pattern', 70 help='Specify a regexp filename pattern for inclusion in the test suite') 71 group.add_argument('--excluded', metavar='exclusion-file', action='append', help=textwrap.dedent( 72 '''Specify a file for tests to exclude. File should contain lists of regular expressions for test files or methods, 73 with each list under a matching header (xfail files, xfail methods, skip files, skip methods)''')) 74 group.add_argument( 75 '-G', 76 '--category', 77 metavar='category', 78 action='append', 79 dest='categoriesList', 80 help=textwrap.dedent('''Specify categories of test cases of interest. Can be specified more than once.''')) 81 group.add_argument( 82 '--skip-category', 83 metavar='category', 84 action='append', 85 dest='skipCategories', 86 help=textwrap.dedent('''Specify categories of test cases to skip. Takes precedence over -G. Can be specified more than once.''')) 87 88 # Configuration options 89 group = parser.add_argument_group('Configuration options') 90 group.add_argument( 91 '--framework', 92 metavar='framework-path', 93 help='The path to LLDB.framework') 94 group.add_argument( 95 '--executable', 96 metavar='executable-path', 97 help='The path to the lldb executable') 98 group.add_argument( 99 '--server', 100 metavar='server-path', 101 help='The path to the debug server executable to use') 102 group.add_argument( 103 '--out-of-tree-debugserver', 104 dest='out_of_tree_debugserver', 105 action='store_true', 106 help='A flag to indicate an out-of-tree debug server is being used') 107 group.add_argument( 108 '--dwarf-version', 109 metavar='dwarf_version', 110 dest='dwarf_version', 111 type=int, 112 help='Override the DWARF version.') 113 group.add_argument( 114 '-s', 115 metavar='name', 116 help='Specify the name of the dir created to store the session files of tests with errored or failed status. If not specified, the test driver uses the timestamp as the session dir name') 117 group.add_argument( 118 '-S', 119 '--session-file-format', 120 default=configuration.session_file_format, 121 metavar='format', 122 help='Specify session file name format. See configuration.py for a description.') 123 group.add_argument( 124 '-y', 125 type=int, 126 metavar='count', 127 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.") 128 group.add_argument( 129 '-#', 130 type=int, 131 metavar='sharp', 132 dest='sharp', 133 help='Repeat the test suite for a specified number of times') 134 group.add_argument('--channel', metavar='channel', dest='channels', action='append', help=textwrap.dedent( 135 "Specify the log channels (and optional categories) e.g. 'lldb all' or 'gdb-remote packets' if no categories are specified, 'default' is used")) 136 group.add_argument( 137 '--log-success', 138 dest='log_success', 139 action='store_true', 140 help="Leave logs/traces even for successful test runs (useful for creating reference log files during debugging.)") 141 group.add_argument( 142 '--codesign-identity', 143 metavar='Codesigning identity', 144 default='lldb_codesign', 145 help='The codesigning identity to use') 146 group.add_argument( 147 '--build-dir', 148 dest='test_build_dir', 149 metavar='Test build directory', 150 default='lldb-test-build.noindex', 151 help='The root build directory for the tests. It will be removed before running.') 152 group.add_argument( 153 '--lldb-module-cache-dir', 154 dest='lldb_module_cache_dir', 155 metavar='The clang module cache directory used by LLDB', 156 help='The clang module cache directory used by LLDB. Defaults to <test build directory>/module-cache-lldb.') 157 group.add_argument( 158 '--clang-module-cache-dir', 159 dest='clang_module_cache_dir', 160 metavar='The clang module cache directory used by Clang', 161 help='The clang module cache directory used in the Make files by Clang while building tests. Defaults to <test build directory>/module-cache-clang.') 162 163 # Configuration options 164 group = parser.add_argument_group('Remote platform options') 165 group.add_argument( 166 '--platform-name', 167 dest='lldb_platform_name', 168 metavar='platform-name', 169 help='The name of a remote platform to use') 170 group.add_argument( 171 '--platform-url', 172 dest='lldb_platform_url', 173 metavar='platform-url', 174 help='A LLDB platform URL to use when connecting to a remote platform to run the test suite') 175 group.add_argument( 176 '--platform-working-dir', 177 dest='lldb_platform_working_dir', 178 metavar='platform-working-dir', 179 help='The directory to use on the remote platform.') 180 181 # Test-suite behaviour 182 group = parser.add_argument_group('Runtime behaviour options') 183 X('-d', 'Suspend the process after launch to wait indefinitely for a debugger to attach') 184 X('-t', 'Turn on tracing of lldb command and other detailed test executions') 185 group.add_argument( 186 '-u', 187 dest='unset_env_varnames', 188 metavar='variable', 189 action='append', 190 help='Specify an environment variable to unset before running the test cases. e.g., -u DYLD_INSERT_LIBRARIES -u MallocScribble') 191 group.add_argument( 192 '--env', 193 dest='set_env_vars', 194 metavar='variable', 195 action='append', 196 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') 197 group.add_argument( 198 '--inferior-env', 199 dest='set_inferior_env_vars', 200 metavar='variable', 201 action='append', 202 help='Specify an environment variable to set to the given value for the inferior.') 203 X('-v', 'Do verbose mode of unittest framework (print out each test case invocation)') 204 group.add_argument( 205 '--enable-crash-dialog', 206 dest='disable_crash_dialog', 207 action='store_false', 208 help='(Windows only) When LLDB crashes, display the Windows crash dialog.') 209 group.set_defaults(disable_crash_dialog=True) 210 211 # Test results support. 212 group = parser.add_argument_group('Test results options') 213 group.add_argument( 214 '--results-file', 215 action='store', 216 help=('Specifies the file where test results will be written ' 217 'according to the results-formatter class used')) 218 group.add_argument( 219 '--results-formatter', 220 action='store', 221 help=('Specifies the full package/module/class name used to translate ' 222 'test events into some kind of meaningful report, written to ' 223 'the designated output results file-like object')) 224 group.add_argument( 225 '--results-formatter-option', 226 '-O', 227 action='append', 228 dest='results_formatter_options', 229 help=('Specify an option to pass to the formatter. ' 230 'Use --results-formatter-option="--option1=val1" ' 231 'syntax. Note the "=" is critical, don\'t include whitespace.')) 232 233 # Re-run related arguments 234 group = parser.add_argument_group('Test Re-run Options') 235 group.add_argument( 236 '--rerun-all-issues', 237 action='store_true', 238 help=('Re-run all issues that occurred during the test run ' 239 'irrespective of the test method\'s marking as flakey. ' 240 'Default behavior is to apply re-runs only to flakey ' 241 'tests that generate issues.')) 242 243 # Remove the reference to our helper function 244 del X 245 246 group = parser.add_argument_group('Test directories') 247 group.add_argument( 248 'args', 249 metavar='test-dir', 250 nargs='*', 251 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.') 252 253 return parser 254