1*c05d8e5dSAndroid Build Coastguard Worker# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: 2*c05d8e5dSAndroid Build Coastguard Worker 3*c05d8e5dSAndroid Build Coastguard Worker# Configuration file for the 'lit' test runner. 4*c05d8e5dSAndroid Build Coastguard Worker 5*c05d8e5dSAndroid Build Coastguard Worker 6*c05d8e5dSAndroid Build Coastguard Workerimport os 7*c05d8e5dSAndroid Build Coastguard Workerimport site 8*c05d8e5dSAndroid Build Coastguard Worker 9*c05d8e5dSAndroid Build Coastguard Workersite.addsitedir(os.path.dirname(__file__)) 10*c05d8e5dSAndroid Build Coastguard Worker 11*c05d8e5dSAndroid Build Coastguard Worker 12*c05d8e5dSAndroid Build Coastguard Worker# Tell pylint that we know config and lit_config exist somewhere. 13*c05d8e5dSAndroid Build Coastguard Workerif 'PYLINT_IMPORT' in os.environ: 14*c05d8e5dSAndroid Build Coastguard Worker config = object() 15*c05d8e5dSAndroid Build Coastguard Worker lit_config = object() 16*c05d8e5dSAndroid Build Coastguard Worker 17*c05d8e5dSAndroid Build Coastguard Worker# name: The name of this test suite. 18*c05d8e5dSAndroid Build Coastguard Workerconfig.name = 'libc++abi' 19*c05d8e5dSAndroid Build Coastguard Worker 20*c05d8e5dSAndroid Build Coastguard Worker# suffixes: A list of file extensions to treat as test files. 21*c05d8e5dSAndroid Build Coastguard Workerconfig.suffixes = ['.cpp', '.s'] 22*c05d8e5dSAndroid Build Coastguard Worker 23*c05d8e5dSAndroid Build Coastguard Worker# test_source_root: The root path where tests are located. 24*c05d8e5dSAndroid Build Coastguard Workerconfig.test_source_root = os.path.dirname(__file__) 25*c05d8e5dSAndroid Build Coastguard Worker 26*c05d8e5dSAndroid Build Coastguard Worker# Infer the libcxx_test_source_root for configuration import. 27*c05d8e5dSAndroid Build Coastguard Worker# If libcxx_source_root isn't specified in the config, assume that the libcxx 28*c05d8e5dSAndroid Build Coastguard Worker# and libcxxabi source directories are sibling directories. 29*c05d8e5dSAndroid Build Coastguard Workerlibcxx_src_root = getattr(config, 'libcxx_src_root', None) 30*c05d8e5dSAndroid Build Coastguard Workerif not libcxx_src_root: 31*c05d8e5dSAndroid Build Coastguard Worker libcxx_src_root = os.path.join(config.test_source_root, '../../libcxx') 32*c05d8e5dSAndroid Build Coastguard Workerlibcxx_test_src_root = os.path.join(libcxx_src_root, 'utils') 33*c05d8e5dSAndroid Build Coastguard Workerif os.path.isfile(os.path.join(libcxx_test_src_root, 'libcxx', '__init__.py')): 34*c05d8e5dSAndroid Build Coastguard Worker site.addsitedir(libcxx_test_src_root) 35*c05d8e5dSAndroid Build Coastguard Workerelse: 36*c05d8e5dSAndroid Build Coastguard Worker lit_config.fatal('Could not find libcxx test directory for test imports' 37*c05d8e5dSAndroid Build Coastguard Worker ' in: %s' % libcxx_test_src_root) 38*c05d8e5dSAndroid Build Coastguard Worker 39*c05d8e5dSAndroid Build Coastguard Worker# Infer the test_exec_root from the libcxx_object root. 40*c05d8e5dSAndroid Build Coastguard Workerobj_root = getattr(config, 'libcxxabi_obj_root', None) 41*c05d8e5dSAndroid Build Coastguard Worker 42*c05d8e5dSAndroid Build Coastguard Worker# Check that the test exec root is known. 43*c05d8e5dSAndroid Build Coastguard Workerif obj_root is None: 44*c05d8e5dSAndroid Build Coastguard Worker import libcxx.test.config 45*c05d8e5dSAndroid Build Coastguard Worker libcxx.test.config.loadSiteConfig( 46*c05d8e5dSAndroid Build Coastguard Worker lit_config, config, 'libcxxabi_site_config', 'LIBCXXABI_SITE_CONFIG') 47*c05d8e5dSAndroid Build Coastguard Worker obj_root = getattr(config, 'libcxxabi_obj_root', None) 48*c05d8e5dSAndroid Build Coastguard Worker if obj_root is None: 49*c05d8e5dSAndroid Build Coastguard Worker import tempfile 50*c05d8e5dSAndroid Build Coastguard Worker obj_root = tempfile.mkdtemp(prefix='libcxxabi-testsuite-') 51*c05d8e5dSAndroid Build Coastguard Worker lit_config.warning('Creating temporary directory for object root: %s' % 52*c05d8e5dSAndroid Build Coastguard Worker obj_root) 53*c05d8e5dSAndroid Build Coastguard Worker 54*c05d8e5dSAndroid Build Coastguard Workerconfig.test_exec_root = os.path.join(obj_root, 'test') 55*c05d8e5dSAndroid Build Coastguard Worker 56*c05d8e5dSAndroid Build Coastguard Workercfg_variant = getattr(config, 'configuration_variant', 'libcxxabi') 57*c05d8e5dSAndroid Build Coastguard Workerif cfg_variant: 58*c05d8e5dSAndroid Build Coastguard Worker lit_config.note('Using configuration variant: %s' % cfg_variant) 59*c05d8e5dSAndroid Build Coastguard Worker 60*c05d8e5dSAndroid Build Coastguard Worker# Load the Configuration class from the module name <cfg_variant>.test.config. 61*c05d8e5dSAndroid Build Coastguard Workerconfig_module_name = '.'.join([cfg_variant, 'test', 'config']) 62*c05d8e5dSAndroid Build Coastguard Workerconfig_module = __import__(config_module_name, fromlist=['Configuration']) 63*c05d8e5dSAndroid Build Coastguard Worker 64*c05d8e5dSAndroid Build Coastguard Workerconfiguration = config_module.Configuration(lit_config, config) 65*c05d8e5dSAndroid Build Coastguard Workerconfiguration.configure() 66*c05d8e5dSAndroid Build Coastguard Workerconfiguration.print_config_info() 67*c05d8e5dSAndroid Build Coastguard Workerconfig.test_format = configuration.get_test_format() 68