xref: /llvm-project/bolt/test/lit.cfg.py (revision 340da8f294e521f2438fb60b297f286d350cf9ff)
1# -*- Python -*-
2
3import os
4import platform
5import re
6import subprocess
7import tempfile
8
9import lit.formats
10import lit.util
11
12from lit.llvm import llvm_config
13from lit.llvm.subst import ToolSubst
14from lit.llvm.subst import FindTool
15
16# Configuration file for the 'lit' test runner.
17
18# name: The name of this test suite.
19config.name = 'BOLT'
20
21# testFormat: The test format to use to interpret tests.
22#
23# For now we require '&&' between commands, until they get globally killed and
24# the test runner updated.
25config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
26
27# suffixes: A list of file extensions to treat as test files.
28config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu',
29                   '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs']
30
31# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
32# subdirectories contain auxiliary inputs for various tests in their parent
33# directories.
34config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
35
36# test_source_root: The root path where tests are located.
37config.test_source_root = os.path.dirname(__file__)
38
39# test_exec_root: The root path where tests should be run.
40config.test_exec_root = os.path.join(config.bolt_obj_root, 'test')
41
42llvm_config.use_default_substitutions()
43
44config.substitutions.append(('%host_cc', config.host_cc))
45
46tool_dirs = [config.llvm_tools_dir,
47             config.test_source_root]
48
49linker_tool = llvm_config.use_llvm_tool('ld', required=True)
50tools = [
51    ToolSubst('llvm-bolt', unresolved='fatal'),
52    ToolSubst('perf2bolt', unresolved='fatal'),
53    ToolSubst('yaml2obj', unresolved='fatal'),
54    ToolSubst('llvm-mc', unresolved='fatal'),
55    ToolSubst('linker', command=linker_tool, unresolved='fatal'),
56    ToolSubst('link_fdata', command=FindTool('link_fdata.sh'), unresolved='fatal'),
57]
58llvm_config.add_tool_substitutions(tools, tool_dirs)
59
60# Propagate path to symbolizer for ASan/MSan.
61llvm_config.with_system_environment(
62    ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
63
64config.substitutions.append(('%PATH%', config.environment['PATH']))
65
66# Plugins (loadable modules)
67# TODO: This should be supplied by Makefile or autoconf.
68if sys.platform in ['win32', 'cygwin']:
69    has_plugins = config.enable_shared
70else:
71    has_plugins = True
72
73if has_plugins and config.llvm_plugin_ext:
74    config.available_features.add('plugins')
75
76def calculate_arch_features(arch_string):
77    features = []
78    for arch in arch_string.split():
79        features.append(arch.lower() + '-registered-target')
80    return features
81
82
83llvm_config.feature_config(
84    [('--assertion-mode', {'ON': 'asserts'}),
85     ('--cxxflags', {r'-D_GLIBCXX_DEBUG\b': 'libstdcxx-safe-mode'}),
86        ('--targets-built', calculate_arch_features)
87     ])
88
89if config.enable_backtrace:
90    config.available_features.add('backtrace')
91
92# Check if we should allow outputs to console.
93run_console_tests = int(lit_config.params.get('enable_console', '0'))
94if run_console_tests != 0:
95    config.available_features.add('console')
96