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 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 59 | dont_do_dsym_test = False |
| 60 | dont_do_dwarf_test = False |
| 61 | dont_do_dwo_test = False |
| 62 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 63 | # The list of categories we said we care about |
| 64 | categoriesList = None |
| 65 | # set to true if we are going to use categories for cherry-picking test cases |
| 66 | useCategories = False |
| 67 | # Categories we want to skip |
| 68 | skipCategories = [] |
| 69 | # use this to track per-category failures |
| 70 | failuresPerCategory = {} |
| 71 | |
| 72 | # The path to LLDB.framework is optional. |
| 73 | lldbFrameworkPath = None |
| 74 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 75 | # Test suite repeat count. Can be overwritten with '-# count'. |
| 76 | count = 1 |
| 77 | |
Zachary Turner | d865c6b | 2015-12-08 22:15:48 +0000 | [diff] [blame] | 78 | # The 'archs' and 'compilers' can be specified via command line. The corresponding |
| 79 | # options can be specified more than once. For example, "-A x86_64 -A i386" |
| 80 | # => archs=['x86_64', 'i386'] and "-C gcc -C clang" => compilers=['gcc', 'clang']. |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 81 | archs = None # Must be initialized after option parsing |
| 82 | compilers = None # Must be initialized after option parsing |
| 83 | |
| 84 | # The arch might dictate some specific CFLAGS to be passed to the toolchain to build |
| 85 | # the inferior programs. The global variable cflags_extras provides a hook to do |
| 86 | # just that. |
| 87 | cflags_extras = '' |
| 88 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 89 | # The filters (testclass.testmethod) used to admit tests into our test suite. |
| 90 | filters = [] |
| 91 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 92 | # By default, we skip long running test case. Use '-l' option to override. |
| 93 | skip_long_running_test = True |
| 94 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 95 | # Parsable mode silences headers, and any other output this script might generate, and instead |
| 96 | # prints machine-readable output similar to what clang tests produce. |
| 97 | parsable = False |
| 98 | |
| 99 | # The regular expression pattern to match against eligible filenames as our test cases. |
| 100 | regexp = None |
| 101 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 102 | # By default, recorded session info for errored/failed test are dumped into its |
| 103 | # own file under a session directory named after the timestamp of the test suite |
| 104 | # run. Use '-s session-dir-name' to specify a specific dir name. |
| 105 | sdir_name = None |
| 106 | |
| 107 | # Set this flag if there is any session info dumped during the test run. |
| 108 | sdir_has_content = False |
| 109 | |
| 110 | # svn_info stores the output from 'svn info lldb.base.dir'. |
| 111 | svn_info = '' |
| 112 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 113 | # Default verbosity is 0. |
Todd Fiala | 07206ea | 2015-12-10 23:14:24 +0000 | [diff] [blame] | 114 | verbose = 0 |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 115 | |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 116 | # By default, search from the script directory. |
| 117 | # We can't use sys.path[0] to determine the script directory |
| 118 | # because it doesn't work under a debugger |
| 119 | testdirs = [ os.path.dirname(os.path.realpath(__file__)) ] |
| 120 | |
| 121 | # Separator string. |
| 122 | separator = '-' * 70 |
| 123 | |
| 124 | failed = False |
| 125 | |
| 126 | # LLDB Remote platform setting |
| 127 | lldb_platform_name = None |
| 128 | lldb_platform_url = None |
| 129 | lldb_platform_working_dir = None |
| 130 | |
| 131 | # Parallel execution settings |
| 132 | is_inferior_test_runner = False |
| 133 | multiprocess_test_subdir = None |
| 134 | num_threads = None |
Zachary Turner | 606e3a5 | 2015-12-08 01:15:30 +0000 | [diff] [blame] | 135 | no_multiprocess_test_runner = False |
| 136 | test_runner_name = None |
| 137 | |
| 138 | # Test results handling globals |
| 139 | results_filename = None |
| 140 | results_port = None |
| 141 | results_formatter_name = None |
| 142 | results_formatter_object = None |
| 143 | results_formatter_options = None |
| 144 | test_result = None |
| 145 | |
| 146 | # The names of all tests. Used to assert we don't have two tests with the same base name. |
| 147 | all_tests = set() |
| 148 | |
| 149 | # safe default |
| 150 | setCrashInfoHook = lambda x : None |
Zachary Turner | b4733e6 | 2015-12-08 01:15:44 +0000 | [diff] [blame] | 151 | |
| 152 | def shouldSkipBecauseOfCategories(test_categories): |
| 153 | if useCategories: |
| 154 | if len(test_categories) == 0 or len(categoriesList & set(test_categories)) == 0: |
| 155 | return True |
| 156 | |
| 157 | for category in skipCategories: |
| 158 | if category in test_categories: |
| 159 | return True |
| 160 | |
| 161 | return False |