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