]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/configuration.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / configuration.py
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
27 def __setCrashInfoHook_Mac(text):
28     from . import crashinfo
29     crashinfo.setCrashReporterDescription(text)
30
31
32 def setupCrashInfoHook():
33     if platform.system() == "Darwin":
34         from . import lock
35         test_dir = os.environ['LLDB_TEST']
36         if not test_dir or not os.path.exists(test_dir):
37             return
38         dylib_lock = os.path.join(test_dir, "crashinfo.lock")
39         dylib_src = os.path.join(test_dir, "crashinfo.c")
40         dylib_dst = os.path.join(test_dir, "crashinfo.so")
41         try:
42             compile_lock = lock.Lock(dylib_lock)
43             compile_lock.acquire()
44             if not os.path.isfile(dylib_dst) or os.path.getmtime(
45                     dylib_dst) < os.path.getmtime(dylib_src):
46                 # we need to compile
47                 cmd = "SDKROOT= xcrun clang %s -o %s -framework Python -Xlinker -dylib -iframework /System/Library/Frameworks/ -Xlinker -F /System/Library/Frameworks/" % (
48                     dylib_src, dylib_dst)
49                 if subprocess.call(
50                         cmd, shell=True) != 0 or not os.path.isfile(dylib_dst):
51                     raise Exception('command failed: "{}"'.format(cmd))
52         finally:
53             compile_lock.release()
54             del compile_lock
55
56         setCrashInfoHook = __setCrashInfoHook_Mac
57
58     else:
59         pass
60
61 # The test suite.
62 suite = unittest2.TestSuite()
63
64 # The list of categories we said we care about
65 categoriesList = None
66 # set to true if we are going to use categories for cherry-picking test cases
67 useCategories = False
68 # Categories we want to skip
69 skipCategories = []
70 # use this to track per-category failures
71 failuresPerCategory = {}
72
73 # The path to LLDB.framework is optional.
74 lldbFrameworkPath = None
75
76 # Test suite repeat count.  Can be overwritten with '-# count'.
77 count = 1
78
79 # The 'archs' and 'compilers' can be specified via command line.  The corresponding
80 # options can be specified more than once. For example, "-A x86_64 -A i386"
81 # => archs=['x86_64', 'i386'] and "-C gcc -C clang" => compilers=['gcc', 'clang'].
82 archs = None        # Must be initialized after option parsing
83 compilers = None    # Must be initialized after option parsing
84
85 # The arch might dictate some specific CFLAGS to be passed to the toolchain to build
86 # the inferior programs.  The global variable cflags_extras provides a hook to do
87 # just that.
88 cflags_extras = ''
89
90 # The filters (testclass.testmethod) used to admit tests into our test suite.
91 filters = []
92
93 # By default, we skip long running test case.  Use '-l' option to override.
94 skip_long_running_test = True
95
96 # Parsable mode silences headers, and any other output this script might generate, and instead
97 # prints machine-readable output similar to what clang tests produce.
98 parsable = False
99
100 # The regular expression pattern to match against eligible filenames as
101 # our test cases.
102 regexp = None
103
104 # Sets of tests which are excluded at runtime
105 skip_tests = None
106 xfail_tests = None
107
108 # By default, recorded session info for errored/failed test are dumped into its
109 # own file under a session directory named after the timestamp of the test suite
110 # run.  Use '-s session-dir-name' to specify a specific dir name.
111 sdir_name = None
112
113 # Valid options:
114 # f - test file name (without extension)
115 # n - test class name
116 # m - test method name
117 # a - architecture
118 # c - compiler path
119 # The default is to write all fields.
120 session_file_format = 'fnmac'
121
122 # Set this flag if there is any session info dumped during the test run.
123 sdir_has_content = False
124
125 # svn_info stores the output from 'svn info lldb.base.dir'.
126 svn_info = ''
127
128 # Default verbosity is 0.
129 verbose = 0
130
131 # By default, search from the script directory.
132 # We can't use sys.path[0] to determine the script directory
133 # because it doesn't work under a debugger
134 testdirs = [os.path.dirname(os.path.realpath(__file__))]
135
136 # Separator string.
137 separator = '-' * 70
138
139 failed = False
140
141 # LLDB Remote platform setting
142 lldb_platform_name = None
143 lldb_platform_url = None
144 lldb_platform_working_dir = None
145
146 # Parallel execution settings
147 is_inferior_test_runner = False
148 multiprocess_test_subdir = None
149 num_threads = None
150 no_multiprocess_test_runner = False
151 test_runner_name = None
152
153 # Test results handling globals
154 results_filename = None
155 results_port = None
156 results_formatter_name = None
157 results_formatter_object = None
158 results_formatter_options = None
159 test_result = None
160
161 # Test rerun configuration vars
162 rerun_all_issues = False
163 rerun_max_file_threhold = 0
164
165 # The names of all tests. Used to assert we don't have two tests with the
166 # same base name.
167 all_tests = set()
168
169 # safe default
170 setCrashInfoHook = lambda x: None
171
172
173 def shouldSkipBecauseOfCategories(test_categories):
174     if useCategories:
175         if len(test_categories) == 0 or len(
176                 categoriesList & set(test_categories)) == 0:
177             return True
178
179     for category in skipCategories:
180         if category in test_categories:
181             return True
182
183     return False