xref: /aosp_15_r20/external/libcxx/test/lit.cfg (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
2*58b9f456SAndroid Build Coastguard Worker# Configuration file for the 'lit' test runner.
3*58b9f456SAndroid Build Coastguard Workerimport os
4*58b9f456SAndroid Build Coastguard Workerimport site
5*58b9f456SAndroid Build Coastguard Worker
6*58b9f456SAndroid Build Coastguard Workersite.addsitedir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'utils'))
7*58b9f456SAndroid Build Coastguard Worker
8*58b9f456SAndroid Build Coastguard Worker
9*58b9f456SAndroid Build Coastguard Worker# Tell pylint that we know config and lit_config exist somewhere.
10*58b9f456SAndroid Build Coastguard Workerif 'PYLINT_IMPORT' in os.environ:
11*58b9f456SAndroid Build Coastguard Worker    config = object()
12*58b9f456SAndroid Build Coastguard Worker    lit_config = object()
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker# name: The name of this test suite.
15*58b9f456SAndroid Build Coastguard Workerconfig.name = 'libc++'
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Worker# suffixes: A list of file extensions to treat as test files.
18*58b9f456SAndroid Build Coastguard Workerconfig.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp']
19*58b9f456SAndroid Build Coastguard Worker
20*58b9f456SAndroid Build Coastguard Worker# test_source_root: The root path where tests are located.
21*58b9f456SAndroid Build Coastguard Workerconfig.test_source_root = os.path.dirname(__file__)
22*58b9f456SAndroid Build Coastguard Worker
23*58b9f456SAndroid Build Coastguard Workerloaded_site_cfg = getattr(config, 'loaded_site_config', False)
24*58b9f456SAndroid Build Coastguard Workerif not loaded_site_cfg:
25*58b9f456SAndroid Build Coastguard Worker    import libcxx.test.config
26*58b9f456SAndroid Build Coastguard Worker    libcxx.test.config.loadSiteConfig(lit_config, config, 'libcxx_site_config',
27*58b9f456SAndroid Build Coastguard Worker                                      'LIBCXX_SITE_CONFIG')
28*58b9f456SAndroid Build Coastguard Worker
29*58b9f456SAndroid Build Coastguard Worker# Infer the test_exec_root from the libcxx_object root.
30*58b9f456SAndroid Build Coastguard Workerobj_root = getattr(config, 'libcxx_obj_root', None)
31*58b9f456SAndroid Build Coastguard Worker
32*58b9f456SAndroid Build Coastguard Worker# Check that the test exec root is known.
33*58b9f456SAndroid Build Coastguard Workerif obj_root is None:
34*58b9f456SAndroid Build Coastguard Worker    obj_root = getattr(config, 'libcxx_obj_root', None)
35*58b9f456SAndroid Build Coastguard Worker    if obj_root is None:
36*58b9f456SAndroid Build Coastguard Worker        import tempfile
37*58b9f456SAndroid Build Coastguard Worker        obj_root = tempfile.mkdtemp(prefix='libcxx-testsuite-')
38*58b9f456SAndroid Build Coastguard Worker        lit_config.warning('Creating temporary directory for object root: %s' %
39*58b9f456SAndroid Build Coastguard Worker                           obj_root)
40*58b9f456SAndroid Build Coastguard Worker
41*58b9f456SAndroid Build Coastguard Workerconfig.test_exec_root = os.path.join(obj_root, 'test')
42*58b9f456SAndroid Build Coastguard Worker
43*58b9f456SAndroid Build Coastguard Workercfg_variant = getattr(config, 'configuration_variant', 'libcxx')
44*58b9f456SAndroid Build Coastguard Workerif cfg_variant:
45*58b9f456SAndroid Build Coastguard Worker    lit_config.note('Using configuration variant: %s' % cfg_variant)
46*58b9f456SAndroid Build Coastguard Worker
47*58b9f456SAndroid Build Coastguard Worker# Load the Configuration class from the module name <cfg_variant>.test.config.
48*58b9f456SAndroid Build Coastguard Workerconfig_module_name = '.'.join([cfg_variant, 'test', 'config'])
49*58b9f456SAndroid Build Coastguard Workerconfig_module = __import__(config_module_name, fromlist=['Configuration'])
50*58b9f456SAndroid Build Coastguard Worker
51*58b9f456SAndroid Build Coastguard Workerconfiguration = config_module.Configuration(lit_config, config)
52*58b9f456SAndroid Build Coastguard Workerconfiguration.configure()
53*58b9f456SAndroid Build Coastguard Workerconfiguration.print_config_info()
54*58b9f456SAndroid Build Coastguard Workerconfig.test_format = configuration.get_test_format()
55