llvm-project
173 строки · 5.0 Кб
1# -*- Python -*-
2
3import os4import platform5import re6import subprocess7import locale8
9import lit.formats10import lit.util11
12from lit.llvm import llvm_config13
14# Configuration file for the 'lit' test runner.
15
16# name: The name of this test suite.
17config.name = "lld"18
19# testFormat: The test format to use to interpret tests.
20#
21# For now we require '&&' between commands, until they get globally killed and the test runner updated.
22config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)23
24# suffixes: A list of file extensions to treat as test files.
25config.suffixes = [".ll", ".s", ".test", ".yaml", ".objtxt"]26
27# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
28# subdirectories contain auxiliary inputs for various tests in their parent
29# directories.
30config.excludes = ["Inputs"]31
32# test_source_root: The root path where tests are located.
33config.test_source_root = os.path.dirname(__file__)34
35config.test_exec_root = os.path.join(config.lld_obj_root, "test")36
37llvm_config.use_default_substitutions()38llvm_config.use_lld()39
40tool_patterns = [41"llc",42"llvm-as",43"llvm-mc",44"llvm-nm",45"llvm-objdump",46"llvm-otool",47"llvm-pdbutil",48"llvm-profdata",49"llvm-dwarfdump",50"llvm-readelf",51"llvm-readobj",52"obj2yaml",53"yaml2obj",54"opt",55"llvm-dis",56]
57
58llvm_config.add_tool_substitutions(tool_patterns)59
60# LLD tests tend to be flaky on NetBSD, so add some retries.
61# We don't do this on other platforms because it's slower.
62if platform.system() in ["NetBSD"]:63config.test_retry_attempts = 264
65# When running under valgrind, we mangle '-vg' onto the end of the triple so we
66# can check it with XFAIL and XTARGET.
67if lit_config.useValgrind:68config.target_triple += "-vg"69
70llvm_config.feature_config(71[72(73"--targets-built",74{75"AArch64": "aarch64",76"AMDGPU": "amdgpu",77"ARM": "arm",78"AVR": "avr",79"Hexagon": "hexagon",80"LoongArch": "loongarch",81"Mips": "mips",82"MSP430": "msp430",83"PowerPC": "ppc",84"RISCV": "riscv",85"Sparc": "sparc",86"SystemZ": "systemz",87"WebAssembly": "wasm",88"X86": "x86",89},90),91("--assertion-mode", {"ON": "asserts"}),92]93)
94
95# Set a fake constant version so that we get consistent output.
96config.environment["LLD_VERSION"] = "LLD 1.0"97
98# LLD_IN_TEST determines how many times `main` is run inside each process, which
99# lets us test that it's cleaning up after itself and resetting global state
100# correctly (which is important for usage as a library).
101run_lld_main_twice = lit_config.params.get("RUN_LLD_MAIN_TWICE", False)102if not run_lld_main_twice:103config.environment["LLD_IN_TEST"] = "1"104else:105config.environment["LLD_IN_TEST"] = "2"106# Many ELF tests fail in this mode.107config.excludes.append("ELF")108# Some old Mach-O backend tests fail, and it's due for removal anyway.109config.excludes.append("mach-o")110# Some new Mach-O backend tests fail; give them a way to mark themselves111# unsupported in this mode.112config.available_features.add("main-run-twice")113
114# Indirectly check if the mt.exe Microsoft utility exists by searching for
115# cvtres, which always accompanies it. Alternatively, check if we can use
116# libxml2 to merge manifests.
117if lit.util.which("cvtres", config.environment["PATH"]) or config.have_libxml2:118config.available_features.add("manifest_tool")119
120if config.enable_backtrace:121config.available_features.add("backtrace")122
123if config.have_libxml2:124config.available_features.add("libxml2")125
126if config.have_dia_sdk:127config.available_features.add("diasdk")128
129if config.sizeof_void_p == 8:130config.available_features.add("llvm-64-bits")131
132if config.has_plugins:133config.available_features.add("plugins")134
135if config.build_examples:136config.available_features.add("examples")137
138if config.linked_bye_extension:139config.substitutions.append(("%loadbye", ""))140config.substitutions.append(("%loadnewpmbye", ""))141else:142config.substitutions.append(143(144"%loadbye",145"-load={}/Bye{}".format(config.llvm_shlib_dir, config.llvm_shlib_ext),146)147)148config.substitutions.append(149(150"%loadnewpmbye",151"-load-pass-plugin={}/Bye{}".format(152config.llvm_shlib_dir, config.llvm_shlib_ext153),154)155)156
157tar_executable = lit.util.which("tar", config.environment["PATH"])158if tar_executable:159env = os.environ160env["LANG"] = "C"161tar_version = subprocess.Popen(162[tar_executable, "--version"],163stdout=subprocess.PIPE,164stderr=subprocess.PIPE,165env=env,166)167sout, _ = tar_version.communicate()168if "GNU tar" in sout.decode():169config.available_features.add("gnutar")170
171# ELF tests expect the default target for ld.lld to be ELF.
172if config.ld_lld_default_mingw:173config.excludes.append("ELF")174