[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / bolt / test / lit.cfg.py
blob3a6da210e01f080e8cba8cb0d3ecda57f3acaa71
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 tools = [
96 ToolSubst("llc", unresolved="fatal"),
97 ToolSubst("llvm-dwarfdump", unresolved="fatal"),
98 ToolSubst("llvm-bolt", unresolved="fatal"),
99 ToolSubst("llvm-boltdiff", unresolved="fatal"),
100 ToolSubst("llvm-bolt-heatmap", unresolved="fatal"),
101 ToolSubst("llvm-bat-dump", unresolved="fatal"),
102 ToolSubst("perf2bolt", unresolved="fatal"),
103 ToolSubst("yaml2obj", unresolved="fatal"),
104 ToolSubst("llvm-mc", unresolved="fatal"),
105 ToolSubst("llvm-nm", unresolved="fatal"),
106 ToolSubst("llvm-objdump", unresolved="fatal"),
107 ToolSubst("llvm-objcopy", unresolved="fatal"),
108 ToolSubst("llvm-strings", unresolved="fatal"),
109 ToolSubst("llvm-strip", unresolved="fatal"),
110 ToolSubst("llvm-readelf", unresolved="fatal"),
111 ToolSubst(
112 "link_fdata",
113 command=sys.executable,
114 unresolved="fatal",
115 extra_args=[link_fdata_cmd],
117 ToolSubst("merge-fdata", unresolved="fatal"),
118 ToolSubst("llvm-readobj", unresolved="fatal"),
119 ToolSubst("llvm-dwp", unresolved="fatal"),
120 ToolSubst("split-file", unresolved="fatal"),
122 llvm_config.add_tool_substitutions(tools, tool_dirs)
125 def calculate_arch_features(arch_string):
126 features = []
127 for arch in arch_string.split():
128 features.append(arch.lower() + "-registered-target")
129 return features
132 llvm_config.feature_config(
134 ("--assertion-mode", {"ON": "asserts"}),
135 ("--cxxflags", {r"-D_GLIBCXX_DEBUG\b": "libstdcxx-safe-mode"}),
136 ("--targets-built", calculate_arch_features),
140 config.targets = frozenset(config.targets_to_build.split(";"))