Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 1 | """ |
| 2 | The LLVM Compiler Infrastructure |
| 3 | |
| 4 | This file is distributed under the University of Illinois Open Source |
| 5 | License. See LICENSE.TXT for details. |
| 6 | |
| 7 | Provides the configuration class, which holds all information related to |
| 8 | how this invocation of the test suite should be run. |
| 9 | """ |
| 10 | |
| 11 | from __future__ import absolute_import |
| 12 | from __future__ import print_function |
| 13 | |
| 14 | # System modules |
| 15 | import os |
| 16 | import platform |
| 17 | import subprocess |
| 18 | |
| 19 | |
| 20 | # Third-party modules |
| 21 | import unittest2 |
| 22 | |
| 23 | # LLDB Modules |
| 24 | import lldbsuite |
| 25 | |
| 26 | def __setCrashInfoHook_Mac(text): |
| 27 | from . import crashinfo |
| 28 | crashinfo.setCrashReporterDescription(text) |
| 29 | |
Pavel Labath | 9cbf7dd | 2015-12-08 13:32:07 +0000 | [diff] [blame] | 30 | def setupCrashInfoHook(): |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 31 | if platform.system() == "Darwin": |
| 32 | from . import lock |
| 33 | test_dir = os.environ['LLDB_TEST'] |
| 34 | if not test_dir or not os.path.exists(test_dir): |
| 35 | return |
| 36 | dylib_lock = os.path.join(test_dir,"crashinfo.lock") |
| 37 | dylib_src = os.path.join(test_dir,"crashinfo.c") |
| 38 | dylib_dst = os.path.join(test_dir,"crashinfo.so") |
| 39 | try: |
| 40 | compile_lock = lock.Lock(dylib_lock) |
| 41 | compile_lock.acquire() |
| 42 | if not os.path.isfile(dylib_dst) or os.path.getmtime(dylib_dst) < os.path.getmtime(dylib_src): |
| 43 | # we need to compile |
| 44 | cmd = "SDKROOT= xcrun clang %s -o %s -framework Python -Xlinker -dylib -iframework /System/Library/Frameworks/ -Xlinker -F /System/Library/Frameworks/" % (dylib_src,dylib_dst) |
| 45 | if subprocess.call(cmd,shell=True) != 0 or not os.path.isfile(dylib_dst): |
| 46 | raise Exception('command failed: "{}"'.format(cmd)) |
| 47 | finally: |
| 48 | compile_lock.release() |
| 49 | del compile_lock |
| 50 | |
Pavel Labath | 9cbf7dd | 2015-12-08 13:32:07 +0000 | [diff] [blame] | 51 | setCrashInfoHook = __setCrashInfoHook_Mac |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 52 | |
| 53 | else: |
| 54 | pass |
| 55 | |
| 56 | # The test suite. |
| 57 | suite = unittest2.TestSuite() |
| 58 | |
| 59 | # By default, benchmarks tests are not run. |
| 60 | just_do_benchmarks_test = False |
| 61 | |
| 62 | dont_do_dsym_test = False |
| 63 | dont_do_dwarf_test = False |
| 64 | dont_do_dwo_test = False |
| 65 | |
| 66 | # The blacklist is optional (-b blacklistFile) and allows a central place to skip |
| 67 | # testclass's and/or testclass.testmethod's. |
| 68 | blacklist = None |
| 69 | |
| 70 | # The dictionary as a result of sourcing blacklistFile. |
| 71 | blacklistConfig = {} |
| 72 | |
| 73 | # The list of categories we said we care about |
| 74 | categoriesList = None |
| 75 | # set to true if we are going to use categories for cherry-picking test cases |
| 76 | useCategories = False |
| 77 | # Categories we want to skip |
| 78 | skipCategories = [] |
| 79 | # use this to track per-category failures |
| 80 | failuresPerCategory = {} |
| 81 | |
| 82 | # The path to LLDB.framework is optional. |
| 83 | lldbFrameworkPath = None |
| 84 | |
| 85 | # The config file is optional. |
| 86 | configFile = None |
| 87 | |
| 88 | # Test suite repeat count. Can be overwritten with '-# count'. |
| 89 | count = 1 |
| 90 | |
| 91 | # The dictionary as a result of sourcing configFile. |
| 92 | config = {} |
| 93 | # The pre_flight and post_flight functions come from reading a config file. |
| 94 | pre_flight = None |
| 95 | post_flight = None |
| 96 | # So do the lldbtest_remote_sandbox and lldbtest_remote_shell_template variables. |
| 97 | test_remote = False |
| 98 | lldbtest_remote_sandbox = None |
| 99 | lldbtest_remote_shell_template = None |
| 100 | |
| 101 | # The 'archs' and 'compilers' can be specified via either command line or configFile, |
| 102 | # with the command line overriding the configFile. The corresponding options can be |
| 103 | # specified more than once. For example, "-A x86_64 -A i386" => archs=['x86_64', 'i386'] |
| 104 | # and "-C gcc -C clang" => compilers=['gcc', 'clang']. |
| 105 | archs = None # Must be initialized after option parsing |
| 106 | compilers = None # Must be initialized after option parsing |
| 107 | |
| 108 | # The arch might dictate some specific CFLAGS to be passed to the toolchain to build |
| 109 | # the inferior programs. The global variable cflags_extras provides a hook to do |
| 110 | # just that. |
| 111 | cflags_extras = '' |
| 112 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 113 | # Full path of the benchmark executable, as specified by the '-e' option. |
| 114 | bmExecutable = None |
| 115 | # The breakpoint specification of bmExecutable, as specified by the '-x' option. |
| 116 | bmBreakpointSpec = None |
| 117 | # The benchmark iteration count, as specified by the '-y' option. |
| 118 | bmIterationCount = -1 |
| 119 | |
| 120 | # By default, don't exclude any directories. Use '-X' to add one excluded directory. |
| 121 | excluded = set(['.svn', '.git']) |
| 122 | |
| 123 | # By default, failfast is False. Use '-F' to overwrite it. |
| 124 | failfast = False |
| 125 | |
| 126 | # The filters (testclass.testmethod) used to admit tests into our test suite. |
| 127 | filters = [] |
| 128 | |
| 129 | # The runhooks is a list of lldb commands specifically for the debugger. |
| 130 | # Use '-k' to specify a runhook. |
| 131 | runHooks = [] |
| 132 | |
| 133 | # If '-g' is specified, the filterspec is not exclusive. If a test module does |
| 134 | # not contain testclass.testmethod which matches the filterspec, the whole test |
| 135 | # module is still admitted into our test suite. fs4all flag defaults to True. |
| 136 | fs4all = True |
| 137 | |
| 138 | # Ignore the build search path relative to this script to locate the lldb.py module. |
| 139 | ignore = False |
| 140 | |
| 141 | # By default, we do not skip build and cleanup. Use '-S' option to override. |
| 142 | skip_build_and_cleanup = False |
| 143 | |
| 144 | # By default, we skip long running test case. Use '-l' option to override. |
| 145 | skip_long_running_test = True |
| 146 | |
| 147 | # By default, we print the build dir, lldb version, and svn info. Use '-n' option to |
| 148 | # turn it off. |
| 149 | noHeaders = False |
| 150 | |
| 151 | # Parsable mode silences headers, and any other output this script might generate, and instead |
| 152 | # prints machine-readable output similar to what clang tests produce. |
| 153 | parsable = False |
| 154 | |
| 155 | # The regular expression pattern to match against eligible filenames as our test cases. |
| 156 | regexp = None |
| 157 | |
| 158 | # By default, tests are executed in place and cleanups are performed afterwards. |
| 159 | # Use '-r dir' option to relocate the tests and their intermediate files to a |
| 160 | # different directory and to forgo any cleanups. The directory specified must |
| 161 | # not exist yet. |
| 162 | rdir = None |
| 163 | |
| 164 | # By default, recorded session info for errored/failed test are dumped into its |
| 165 | # own file under a session directory named after the timestamp of the test suite |
| 166 | # run. Use '-s session-dir-name' to specify a specific dir name. |
| 167 | sdir_name = None |
| 168 | |
| 169 | # Set this flag if there is any session info dumped during the test run. |
| 170 | sdir_has_content = False |
| 171 | |
| 172 | # svn_info stores the output from 'svn info lldb.base.dir'. |
| 173 | svn_info = '' |
| 174 | |
| 175 | # svn_silent means do not try to obtain svn status |
| 176 | svn_silent = True |
| 177 | |
| 178 | # Default verbosity is 0. |
| 179 | verbose = 1 |
| 180 | |
| 181 | # Set to True only if verbose is 0 and LLDB trace mode is off. |
| 182 | progress_bar = False |
| 183 | |
| 184 | # By default, search from the script directory. |
| 185 | # We can't use sys.path[0] to determine the script directory |
| 186 | # because it doesn't work under a debugger |
| 187 | testdirs = [ os.path.dirname(os.path.realpath(__file__)) ] |
| 188 | |
| 189 | # Separator string. |
| 190 | separator = '-' * 70 |
| 191 | |
| 192 | failed = False |
| 193 | |
| 194 | # LLDB Remote platform setting |
| 195 | lldb_platform_name = None |
| 196 | lldb_platform_url = None |
| 197 | lldb_platform_working_dir = None |
| 198 | |
| 199 | # Parallel execution settings |
| 200 | is_inferior_test_runner = False |
| 201 | multiprocess_test_subdir = None |
| 202 | num_threads = None |
| 203 | output_on_success = False |
| 204 | no_multiprocess_test_runner = False |
| 205 | test_runner_name = None |
| 206 | |
| 207 | # Test results handling globals |
| 208 | results_filename = None |
| 209 | results_port = None |
| 210 | results_formatter_name = None |
| 211 | results_formatter_object = None |
| 212 | results_formatter_options = None |
| 213 | test_result = None |
| 214 | |
| 215 | # The names of all tests. Used to assert we don't have two tests with the same base name. |
| 216 | all_tests = set() |
| 217 | |
| 218 | # safe default |
| 219 | setCrashInfoHook = lambda x : None |
Zachary Turner | b4733e6 | 2015-12-08 01:15:44 +0000 | [diff] [blame] | 220 | |
| 221 | def shouldSkipBecauseOfCategories(test_categories): |
| 222 | if useCategories: |
| 223 | if len(test_categories) == 0 or len(categoriesList & set(test_categories)) == 0: |
| 224 | return True |
| 225 | |
| 226 | for category in skipCategories: |
| 227 | if category in test_categories: |
| 228 | return True |
| 229 | |
| 230 | return False |