blob: 2e4dd411f2f64096b42189c7bf5244ec79fa4070 [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
Zachary Turner606e3a52015-12-08 01:15:30 +000059# The list of categories we said we care about
60categoriesList = None
61# set to true if we are going to use categories for cherry-picking test cases
62useCategories = False
63# Categories we want to skip
64skipCategories = []
65# use this to track per-category failures
66failuresPerCategory = {}
67
68# The path to LLDB.framework is optional.
69lldbFrameworkPath = None
70
Zachary Turner606e3a52015-12-08 01:15:30 +000071# Test suite repeat count. Can be overwritten with '-# count'.
72count = 1
73
Zachary Turnerd865c6b2015-12-08 22:15:48 +000074# 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'].
Zachary Turner606e3a52015-12-08 01:15:30 +000077archs = None # Must be initialized after option parsing
78compilers = 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.
83cflags_extras = ''
84
Zachary Turner606e3a52015-12-08 01:15:30 +000085# The filters (testclass.testmethod) used to admit tests into our test suite.
86filters = []
87
Zachary Turner606e3a52015-12-08 01:15:30 +000088# By default, we skip long running test case. Use '-l' option to override.
89skip_long_running_test = True
90
Zachary Turner606e3a52015-12-08 01:15:30 +000091# 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.
93parsable = False
94
95# The regular expression pattern to match against eligible filenames as our test cases.
96regexp = None
97
Zachary Turner606e3a52015-12-08 01:15:30 +000098# 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.
101sdir_name = None
102
103# Set this flag if there is any session info dumped during the test run.
104sdir_has_content = False
105
106# svn_info stores the output from 'svn info lldb.base.dir'.
107svn_info = ''
108
Zachary Turner606e3a52015-12-08 01:15:30 +0000109# Default verbosity is 0.
Todd Fiala07206ea2015-12-10 23:14:24 +0000110verbose = 0
Zachary Turner606e3a52015-12-08 01:15:30 +0000111
Zachary Turner606e3a52015-12-08 01:15:30 +0000112# By default, search from the script directory.
113# We can't use sys.path[0] to determine the script directory
114# because it doesn't work under a debugger
115testdirs = [ os.path.dirname(os.path.realpath(__file__)) ]
116
117# Separator string.
118separator = '-' * 70
119
120failed = False
121
122# LLDB Remote platform setting
123lldb_platform_name = None
124lldb_platform_url = None
125lldb_platform_working_dir = None
126
127# Parallel execution settings
128is_inferior_test_runner = False
129multiprocess_test_subdir = None
130num_threads = None
Zachary Turner606e3a52015-12-08 01:15:30 +0000131no_multiprocess_test_runner = False
132test_runner_name = None
133
134# Test results handling globals
135results_filename = None
136results_port = None
137results_formatter_name = None
138results_formatter_object = None
139results_formatter_options = None
140test_result = None
141
Todd Fiala93153922015-12-12 19:26:56 +0000142# Test rerun configuration vars
143rerun_all_issues = False
144
Zachary Turner606e3a52015-12-08 01:15:30 +0000145# The names of all tests. Used to assert we don't have two tests with the same base name.
146all_tests = set()
147
148# safe default
149setCrashInfoHook = lambda x : None
Zachary Turnerb4733e62015-12-08 01:15:44 +0000150
151def shouldSkipBecauseOfCategories(test_categories):
152 if useCategories:
153 if len(test_categories) == 0 or len(categoriesList & set(test_categories)) == 0:
154 return True
155
156 for category in skipCategories:
157 if category in test_categories:
158 return True
159
160 return False