12 from lit
.llvm
import llvm_config
14 # Configuration file for the 'lit' test runner.
16 # name: The name of this test suite.
19 # testFormat: The test format to use to interpret tests.
21 # For now we require '&&' between commands, until they get globally killed and the test runner updated.
22 config
.test_format
= lit
.formats
.ShTest(not llvm_config
.use_lit_shell
)
24 # suffixes: A list of file extensions to treat as test files.
25 config
.suffixes
= [".ll", ".s", ".test", ".yaml", ".objtxt"]
27 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
28 # subdirectories contain auxiliary inputs for various tests in their parent
30 config
.excludes
= ["Inputs"]
32 # test_source_root: The root path where tests are located.
33 config
.test_source_root
= os
.path
.dirname(__file__
)
35 config
.test_exec_root
= os
.path
.join(config
.lld_obj_root
, "test")
37 llvm_config
.use_default_substitutions()
59 llvm_config
.add_tool_substitutions(tool_patterns
)
61 # LLD tests tend to be flaky on NetBSD, so add some retries.
62 # We don't do this on other platforms because it's slower.
63 if platform
.system() in ["NetBSD"]:
64 config
.test_retry_attempts
= 2
66 # When running under valgrind, we mangle '-vg' onto the end of the triple so we
67 # can check it with XFAIL and XTARGET.
68 if lit_config
.useValgrind
:
69 config
.target_triple
+= "-vg"
71 llvm_config
.feature_config(
81 "LoongArch": "loongarch",
88 "WebAssembly": "wasm",
92 ("--assertion-mode", {"ON": "asserts"}),
96 # Set a fake constant version so that we get consistent output.
97 config
.environment
["LLD_VERSION"] = "LLD 1.0"
99 # LLD_IN_TEST determines how many times `main` is run inside each process, which
100 # lets us test that it's cleaning up after itself and resetting global state
101 # correctly (which is important for usage as a library).
102 run_lld_main_twice
= lit_config
.params
.get("RUN_LLD_MAIN_TWICE", False)
103 if not run_lld_main_twice
:
104 config
.environment
["LLD_IN_TEST"] = "1"
106 config
.environment
["LLD_IN_TEST"] = "2"
107 # Many ELF tests fail in this mode.
108 config
.excludes
.append("ELF")
109 # Some old Mach-O backend tests fail, and it's due for removal anyway.
110 config
.excludes
.append("mach-o")
111 # Some new Mach-O backend tests fail; give them a way to mark themselves
112 # unsupported in this mode.
113 config
.available_features
.add("main-run-twice")
115 # Indirectly check if the mt.exe Microsoft utility exists by searching for
116 # cvtres, which always accompanies it. Alternatively, check if we can use
117 # libxml2 to merge manifests.
118 if lit
.util
.which("cvtres", config
.environment
["PATH"]) or config
.have_libxml2
:
119 config
.available_features
.add("manifest_tool")
121 if config
.enable_backtrace
:
122 config
.available_features
.add("backtrace")
124 if config
.have_libxml2
:
125 config
.available_features
.add("libxml2")
127 if config
.have_dia_sdk
:
128 config
.available_features
.add("diasdk")
130 if config
.sizeof_void_p
== 8:
131 config
.available_features
.add("llvm-64-bits")
133 if config
.has_plugins
:
134 config
.available_features
.add("plugins")
136 if config
.build_examples
:
137 config
.available_features
.add("examples")
139 if config
.linked_bye_extension
:
140 config
.substitutions
.append(("%loadbye", ""))
141 config
.substitutions
.append(("%loadnewpmbye", ""))
143 config
.substitutions
.append(
146 "-load={}/Bye{}".format(config
.llvm_shlib_dir
, config
.llvm_shlib_ext
),
149 config
.substitutions
.append(
152 "-load-pass-plugin={}/Bye{}".format(
153 config
.llvm_shlib_dir
, config
.llvm_shlib_ext
158 tar_executable
= lit
.util
.which("tar", config
.environment
["PATH"])
162 tar_version
= subprocess
.Popen(
163 [tar_executable
, "--version"],
164 stdout
=subprocess
.PIPE
,
165 stderr
=subprocess
.PIPE
,
168 sout
, _
= tar_version
.communicate()
169 if "GNU tar" in sout
.decode():
170 config
.available_features
.add("gnutar")
172 # ELF tests expect the default target for ld.lld to be ELF.
173 if config
.ld_lld_default_mingw
:
174 config
.excludes
.append("ELF")