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