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# The overriden dwarf verison. 47dwarf_version = 0 48 49# Path to the FileCheck testing tool. Not optional. 50filecheck = None 51 52# The arch might dictate some specific CFLAGS to be passed to the toolchain to build 53# the inferior programs. The global variable cflags_extras provides a hook to do 54# just that. 55cflags_extras = '' 56 57# The filters (testclass.testmethod) used to admit tests into our test suite. 58filters = [] 59 60# By default, we skip long running test case. Use '-l' option to override. 61skip_long_running_test = True 62 63# Parsable mode silences headers, and any other output this script might generate, and instead 64# prints machine-readable output similar to what clang tests produce. 65parsable = False 66 67# The regular expression pattern to match against eligible filenames as 68# our test cases. 69regexp = None 70 71# Sets of tests which are excluded at runtime 72skip_tests = None 73xfail_tests = None 74 75# By default, recorded session info for errored/failed test are dumped into its 76# own file under a session directory named after the timestamp of the test suite 77# run. Use '-s session-dir-name' to specify a specific dir name. 78sdir_name = None 79 80# Valid options: 81# f - test file name (without extension) 82# n - test class name 83# m - test method name 84# a - architecture 85# c - compiler path 86# The default is to write all fields. 87session_file_format = 'fnmac' 88 89# Set this flag if there is any session info dumped during the test run. 90sdir_has_content = False 91 92# svn_info stores the output from 'svn info lldb.base.dir'. 93svn_info = '' 94 95# Default verbosity is 0. 96verbose = 0 97 98# By default, search from the script directory. 99# We can't use sys.path[0] to determine the script directory 100# because it doesn't work under a debugger 101testdirs = [os.path.dirname(os.path.realpath(__file__))] 102 103# Separator string. 104separator = '-' * 70 105 106failed = False 107 108# LLDB Remote platform setting 109lldb_platform_name = None 110lldb_platform_url = None 111lldb_platform_working_dir = None 112 113# The base directory in which the tests are being built. 114test_build_dir = None 115 116# The only directory to scan for tests. If multiple test directories are 117# specified, and an exclusive test subdirectory is specified, the latter option 118# takes precedence. 119exclusive_test_subdir = None 120 121# Test results handling globals 122results_filename = None 123results_port = None 124results_formatter_name = None 125results_formatter_object = None 126results_formatter_options = None 127test_result = None 128 129# Test rerun configuration vars 130rerun_all_issues = False 131rerun_max_file_threhold = 0 132 133# The names of all tests. Used to assert we don't have two tests with the 134# same base name. 135all_tests = set() 136 137def shouldSkipBecauseOfCategories(test_categories): 138 if useCategories: 139 if len(test_categories) == 0 or len( 140 categoriesList & set(test_categories)) == 0: 141 return True 142 143 for category in skipCategories: 144 if category in test_categories: 145 return True 146 147 return False 148 149 150def get_absolute_path_to_exclusive_test_subdir(): 151 """ 152 If an exclusive test subdirectory is specified, return its absolute path. 153 Otherwise return None. 154 """ 155 test_directory = os.path.dirname(os.path.realpath(__file__)) 156 157 if not exclusive_test_subdir: 158 return 159 160 if len(exclusive_test_subdir) > 0: 161 test_subdir = os.path.join(test_directory, exclusive_test_subdir) 162 if os.path.isdir(test_subdir): 163 return test_subdir 164 165 print('specified test subdirectory {} is not a valid directory\n' 166 .format(test_subdir)) 167 168 169def get_absolute_path_to_root_test_dir(): 170 """ 171 If an exclusive test subdirectory is specified, return its absolute path. 172 Otherwise, return the absolute path of the root test directory. 173 """ 174 test_subdir = get_absolute_path_to_exclusive_test_subdir() 175 if test_subdir: 176 return test_subdir 177 178 return os.path.dirname(os.path.realpath(__file__)) 179 180 181def get_filecheck_path(): 182 """ 183 Get the path to the FileCheck testing tool. 184 """ 185 if filecheck and os.path.lexists(filecheck): 186 return filecheck 187