1""" 2Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 3See https://llvm.org/LICENSE.txt for license information. 4SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 6Provides the configuration class, which holds all information related to 7how this invocation of the test suite should be run. 8""" 9 10from __future__ import absolute_import 11from __future__ import print_function 12 13# System modules 14import os 15 16 17# Third-party modules 18import unittest2 19 20# LLDB Modules 21import lldbsuite 22 23 24# The test suite. 25suite = unittest2.TestSuite() 26 27# The list of categories we said we care about 28categoriesList = None 29# set to true if we are going to use categories for cherry-picking test cases 30useCategories = False 31# Categories we want to skip 32skipCategories = ["darwin-log"] 33# use this to track per-category failures 34failuresPerCategory = {} 35 36# The path to LLDB.framework is optional. 37lldbFrameworkPath = None 38 39# Test suite repeat count. Can be overwritten with '-# count'. 40count = 1 41 42# The 'arch' and 'compiler' can be specified via command line. 43arch = None # Must be initialized after option parsing 44compiler = None # Must be initialized after option parsing 45 46# Path to the FileCheck testing tool. Not optional. 47filecheck = None 48 49# The arch might dictate some specific CFLAGS to be passed to the toolchain to build 50# the inferior programs. The global variable cflags_extras provides a hook to do 51# just that. 52cflags_extras = '' 53 54# The filters (testclass.testmethod) used to admit tests into our test suite. 55filters = [] 56 57# By default, we skip long running test case. Use '-l' option to override. 58skip_long_running_test = True 59 60# Parsable mode silences headers, and any other output this script might generate, and instead 61# prints machine-readable output similar to what clang tests produce. 62parsable = False 63 64# The regular expression pattern to match against eligible filenames as 65# our test cases. 66regexp = None 67 68# Sets of tests which are excluded at runtime 69skip_tests = None 70xfail_tests = None 71 72# By default, recorded session info for errored/failed test are dumped into its 73# own file under a session directory named after the timestamp of the test suite 74# run. Use '-s session-dir-name' to specify a specific dir name. 75sdir_name = None 76 77# Valid options: 78# f - test file name (without extension) 79# n - test class name 80# m - test method name 81# a - architecture 82# c - compiler path 83# The default is to write all fields. 84session_file_format = 'fnmac' 85 86# Set this flag if there is any session info dumped during the test run. 87sdir_has_content = False 88 89# svn_info stores the output from 'svn info lldb.base.dir'. 90svn_info = '' 91 92# Default verbosity is 0. 93verbose = 0 94 95# By default, search from the script directory. 96# We can't use sys.path[0] to determine the script directory 97# because it doesn't work under a debugger 98testdirs = [os.path.dirname(os.path.realpath(__file__))] 99 100# Separator string. 101separator = '-' * 70 102 103failed = False 104 105# LLDB Remote platform setting 106lldb_platform_name = None 107lldb_platform_url = None 108lldb_platform_working_dir = None 109 110# The base directory in which the tests are being built. 111test_build_dir = None 112 113# The only directory to scan for tests. If multiple test directories are 114# specified, and an exclusive test subdirectory is specified, the latter option 115# takes precedence. 116exclusive_test_subdir = None 117 118# Test results handling globals 119results_filename = None 120results_port = None 121results_formatter_name = None 122results_formatter_object = None 123results_formatter_options = None 124test_result = None 125 126# Test rerun configuration vars 127rerun_all_issues = False 128rerun_max_file_threhold = 0 129 130# The names of all tests. Used to assert we don't have two tests with the 131# same base name. 132all_tests = set() 133 134def shouldSkipBecauseOfCategories(test_categories): 135 if useCategories: 136 if len(test_categories) == 0 or len( 137 categoriesList & set(test_categories)) == 0: 138 return True 139 140 for category in skipCategories: 141 if category in test_categories: 142 return True 143 144 return False 145 146 147def get_absolute_path_to_exclusive_test_subdir(): 148 """ 149 If an exclusive test subdirectory is specified, return its absolute path. 150 Otherwise return None. 151 """ 152 test_directory = os.path.dirname(os.path.realpath(__file__)) 153 154 if not exclusive_test_subdir: 155 return 156 157 if len(exclusive_test_subdir) > 0: 158 test_subdir = os.path.join(test_directory, exclusive_test_subdir) 159 if os.path.isdir(test_subdir): 160 return test_subdir 161 162 print('specified test subdirectory {} is not a valid directory\n' 163 .format(test_subdir)) 164 165 166def get_absolute_path_to_root_test_dir(): 167 """ 168 If an exclusive test subdirectory is specified, return its absolute path. 169 Otherwise, return the absolute path of the root test directory. 170 """ 171 test_subdir = get_absolute_path_to_exclusive_test_subdir() 172 if test_subdir: 173 return test_subdir 174 175 return os.path.dirname(os.path.realpath(__file__)) 176 177 178def get_filecheck_path(): 179 """ 180 Get the path to the FileCheck testing tool. 181 """ 182 if filecheck and os.path.lexists(filecheck): 183 return filecheck 184