blob: ef91fbb52e39cd14e42b3d942913c5f8f60c5b23 [file] [log] [blame]
Zachary Turner606e3a52015-12-08 01:15:30 +00001"""
2 The LLVM Compiler Infrastructure
3
4This file is distributed under the University of Illinois Open Source
5License. See LICENSE.TXT for details.
6
7Provides the configuration class, which holds all information related to
8how this invocation of the test suite should be run.
9"""
10
11from __future__ import absolute_import
12from __future__ import print_function
13
14# System modules
15import os
16import platform
17import subprocess
18
19
20# Third-party modules
21import unittest2
22
23# LLDB Modules
24import lldbsuite
25
26def __setCrashInfoHook_Mac(text):
27 from . import crashinfo
28 crashinfo.setCrashReporterDescription(text)
29
Pavel Labath9cbf7dd2015-12-08 13:32:07 +000030def setupCrashInfoHook():
Zachary Turner606e3a52015-12-08 01:15:30 +000031 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 Labath9cbf7dd2015-12-08 13:32:07 +000051 setCrashInfoHook = __setCrashInfoHook_Mac
Zachary Turner606e3a52015-12-08 01:15:30 +000052
53 else:
54 pass
55
56# The test suite.
57suite = unittest2.TestSuite()
58
59# By default, benchmarks tests are not run.
60just_do_benchmarks_test = False
61
62dont_do_dsym_test = False
63dont_do_dwarf_test = False
64dont_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.
68blacklist = None
69
70# The dictionary as a result of sourcing blacklistFile.
71blacklistConfig = {}
72
73# The list of categories we said we care about
74categoriesList = None
75# set to true if we are going to use categories for cherry-picking test cases
76useCategories = False
77# Categories we want to skip
78skipCategories = []
79# use this to track per-category failures
80failuresPerCategory = {}
81
82# The path to LLDB.framework is optional.
83lldbFrameworkPath = None
84
85# The config file is optional.
86configFile = None
87
88# Test suite repeat count. Can be overwritten with '-# count'.
89count = 1
90
91# The dictionary as a result of sourcing configFile.
92config = {}
93# The pre_flight and post_flight functions come from reading a config file.
94pre_flight = None
95post_flight = None
96# So do the lldbtest_remote_sandbox and lldbtest_remote_shell_template variables.
97test_remote = False
98lldbtest_remote_sandbox = None
99lldbtest_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'].
105archs = None # Must be initialized after option parsing
106compilers = 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.
111cflags_extras = ''
112
Zachary Turner606e3a52015-12-08 01:15:30 +0000113# Full path of the benchmark executable, as specified by the '-e' option.
114bmExecutable = None
115# The breakpoint specification of bmExecutable, as specified by the '-x' option.
116bmBreakpointSpec = None
117# The benchmark iteration count, as specified by the '-y' option.
118bmIterationCount = -1
119
120# By default, don't exclude any directories. Use '-X' to add one excluded directory.
121excluded = set(['.svn', '.git'])
122
123# By default, failfast is False. Use '-F' to overwrite it.
124failfast = False
125
126# The filters (testclass.testmethod) used to admit tests into our test suite.
127filters = []
128
129# The runhooks is a list of lldb commands specifically for the debugger.
130# Use '-k' to specify a runhook.
131runHooks = []
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.
136fs4all = True
137
138# Ignore the build search path relative to this script to locate the lldb.py module.
139ignore = False
140
141# By default, we do not skip build and cleanup. Use '-S' option to override.
142skip_build_and_cleanup = False
143
144# By default, we skip long running test case. Use '-l' option to override.
145skip_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.
149noHeaders = 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.
153parsable = False
154
155# The regular expression pattern to match against eligible filenames as our test cases.
156regexp = 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.
162rdir = 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.
167sdir_name = None
168
169# Set this flag if there is any session info dumped during the test run.
170sdir_has_content = False
171
172# svn_info stores the output from 'svn info lldb.base.dir'.
173svn_info = ''
174
175# svn_silent means do not try to obtain svn status
176svn_silent = True
177
178# Default verbosity is 0.
179verbose = 1
180
181# Set to True only if verbose is 0 and LLDB trace mode is off.
182progress_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
187testdirs = [ os.path.dirname(os.path.realpath(__file__)) ]
188
189# Separator string.
190separator = '-' * 70
191
192failed = False
193
194# LLDB Remote platform setting
195lldb_platform_name = None
196lldb_platform_url = None
197lldb_platform_working_dir = None
198
199# Parallel execution settings
200is_inferior_test_runner = False
201multiprocess_test_subdir = None
202num_threads = None
203output_on_success = False
204no_multiprocess_test_runner = False
205test_runner_name = None
206
207# Test results handling globals
208results_filename = None
209results_port = None
210results_formatter_name = None
211results_formatter_object = None
212results_formatter_options = None
213test_result = None
214
215# The names of all tests. Used to assert we don't have two tests with the same base name.
216all_tests = set()
217
218# safe default
219setCrashInfoHook = lambda x : None
Zachary Turnerb4733e62015-12-08 01:15:44 +0000220
221def 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