[NFC][MLIR][Linalg] Refactor linalg.matmul tablegen ODS and related C++ code. (#116377)
[llvm-project.git] / bolt / test / lit.cfg.py
blobda3ae34ba3bddb9db15fe71ed02159cf8618bd9c
1 # -*- Python -*-
3 import os
4 import platform
5 import re
6 import subprocess
7 import tempfile
9 import lit.formats
10 import lit.util
12 from lit.llvm import llvm_config
13 from lit.llvm.subst import ToolSubst
14 from lit.llvm.subst import FindTool
16 # Configuration file for the 'lit' test runner.
18 # name: The name of this test suite.
19 config.name = "BOLT"
21 # testFormat: The test format to use to interpret tests.
23 # For now we require '&&' between commands, until they get globally killed and
24 # the test runner updated.
25 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
27 # suffixes: A list of file extensions to treat as test files.
28 config.suffixes = [
29 ".c",
30 ".cpp",
31 ".cppm",
32 ".m",
33 ".mm",
34 ".cu",
35 ".ll",
36 ".cl",
37 ".s",
38 ".S",
39 ".modulemap",
40 ".test",
41 ".rs",
44 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
45 # subdirectories contain auxiliary inputs for various tests in their parent
46 # directories.
47 config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt"]
49 # test_source_root: The root path where tests are located.
50 config.test_source_root = os.path.dirname(__file__)
52 # test_exec_root: The root path where tests should be run.
53 config.test_exec_root = os.path.join(config.bolt_obj_root, "test")
55 # checking if maxIndividualTestTime is available on the platform and sets
56 # it to 60sec if so, declares lit-max-individual-test-time feature for
57 # further checking by tests.
58 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
59 if supported:
60 config.available_features.add("lit-max-individual-test-time")
61 lit_config.maxIndividualTestTime = 60
62 else:
63 lit_config.warning(
64 "Setting a timeout per test not supported. "
65 + errormsg
66 + " Some tests will be skipped."
69 if config.bolt_enable_runtime:
70 config.available_features.add("bolt-runtime")
72 if config.gnu_ld:
73 config.available_features.add("gnu_ld")
75 if lit.util.which("fuser"):
76 config.available_features.add("fuser")
78 llvm_config.use_default_substitutions()
80 llvm_config.config.environment["CLANG"] = config.bolt_clang
81 llvm_config.use_clang()
83 llvm_config.config.environment["LD_LLD"] = config.bolt_lld
84 ld_lld = llvm_config.use_llvm_tool("ld.lld", required=True, search_env="LD_LLD")
85 llvm_config.config.available_features.add("ld.lld")
86 llvm_config.add_tool_substitutions([ToolSubst(r"ld\.lld", command=ld_lld)])
88 config.substitutions.append(("%cflags", ""))
89 config.substitutions.append(("%cxxflags", ""))
91 link_fdata_cmd = os.path.join(config.test_source_root, "link_fdata.py")
93 tool_dirs = [config.llvm_tools_dir, config.test_source_root]
95 llvm_bolt_args = []
97 if config.libbolt_rt_instr:
98 llvm_bolt_args.append(f"--runtime-instrumentation-lib={config.libbolt_rt_instr}")
100 if config.libbolt_rt_hugify:
101 llvm_bolt_args.append(f"--runtime-hugify-lib={config.libbolt_rt_hugify}")
103 tools = [
104 ToolSubst("llc", unresolved="fatal"),
105 ToolSubst("llvm-dwarfdump", unresolved="fatal"),
106 ToolSubst(
107 "llvm-bolt",
108 unresolved="fatal",
109 extra_args=llvm_bolt_args,
111 ToolSubst("llvm-boltdiff", unresolved="fatal"),
112 ToolSubst("llvm-bolt-heatmap", unresolved="fatal"),
113 ToolSubst("llvm-bat-dump", unresolved="fatal"),
114 ToolSubst("perf2bolt", unresolved="fatal"),
115 ToolSubst("yaml2obj", unresolved="fatal"),
116 ToolSubst("llvm-mc", unresolved="fatal"),
117 ToolSubst("llvm-nm", unresolved="fatal"),
118 ToolSubst("llvm-objdump", unresolved="fatal"),
119 ToolSubst("llvm-objcopy", unresolved="fatal"),
120 ToolSubst("llvm-strings", unresolved="fatal"),
121 ToolSubst("llvm-strip", unresolved="fatal"),
122 ToolSubst("llvm-readelf", unresolved="fatal"),
123 ToolSubst(
124 "link_fdata",
125 command=sys.executable,
126 unresolved="fatal",
127 extra_args=[link_fdata_cmd],
129 ToolSubst("merge-fdata", unresolved="fatal"),
130 ToolSubst("llvm-readobj", unresolved="fatal"),
131 ToolSubst("llvm-dwp", unresolved="fatal"),
132 ToolSubst("split-file", unresolved="fatal"),
134 llvm_config.add_tool_substitutions(tools, tool_dirs)
137 def calculate_arch_features(arch_string):
138 features = []
139 for arch in arch_string.split():
140 features.append(arch.lower() + "-registered-target")
141 return features
144 llvm_config.feature_config(
146 ("--assertion-mode", {"ON": "asserts"}),
147 ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
148 ("--targets-built", calculate_arch_features),
152 config.targets = frozenset(config.targets_to_build.split(";"))