150
|
1 # -*- Python -*-
|
|
2
|
|
3 import os
|
|
4 import platform
|
|
5 import re
|
|
6 import subprocess
|
|
7 import locale
|
|
8
|
|
9 import lit.formats
|
|
10 import lit.util
|
|
11
|
|
12 from lit.llvm import llvm_config
|
|
13
|
|
14 # Configuration file for the 'lit' test runner.
|
|
15
|
|
16 # name: The name of this test suite.
|
|
17 config.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
|
|
22 # the test runner updated.
|
|
23 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
|
24
|
|
25 # suffixes: A list of file extensions to treat as test files.
|
|
26 config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt']
|
|
27
|
|
28 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
|
|
29 # subdirectories contain auxiliary inputs for various tests in their parent
|
|
30 # directories.
|
|
31 config.excludes = ['Inputs']
|
|
32
|
|
33 # test_source_root: The root path where tests are located.
|
|
34 config.test_source_root = os.path.dirname(__file__)
|
|
35
|
|
36 config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
|
|
37
|
|
38 llvm_config.use_default_substitutions()
|
|
39 llvm_config.use_lld()
|
|
40
|
|
41 tool_patterns = [
|
|
42 'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-pdbutil',
|
|
43 'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
|
|
44 'opt', 'llvm-dis']
|
|
45
|
|
46 llvm_config.add_tool_substitutions(tool_patterns)
|
|
47
|
|
48 # LLD tests tend to be flaky on NetBSD, so add some retries.
|
|
49 # We don't do this on other platforms because it's slower.
|
|
50 if platform.system() in ['NetBSD']:
|
|
51 config.test_retry_attempts = 2
|
|
52
|
|
53 # When running under valgrind, we mangle '-vg' onto the end of the triple so we
|
|
54 # can check it with XFAIL and XTARGET.
|
|
55 if lit_config.useValgrind:
|
|
56 config.target_triple += '-vg'
|
|
57
|
|
58 # Running on ELF based *nix
|
|
59 if platform.system() in ['FreeBSD', 'NetBSD', 'Linux']:
|
|
60 config.available_features.add('system-linker-elf')
|
|
61
|
|
62 # Set if host-cxxabi's demangler can handle target's symbols.
|
|
63 if platform.system() not in ['Windows']:
|
|
64 config.available_features.add('demangler')
|
|
65
|
|
66 llvm_config.feature_config(
|
|
67 [('--build-mode', {'DEBUG': 'debug'}),
|
|
68 ('--assertion-mode', {'ON': 'asserts'}),
|
|
69 ('--targets-built', {'AArch64': 'aarch64',
|
|
70 'AMDGPU': 'amdgpu',
|
|
71 'ARM': 'arm',
|
|
72 'AVR': 'avr',
|
|
73 'Hexagon': 'hexagon',
|
|
74 'Mips': 'mips',
|
|
75 'MSP430': 'msp430',
|
|
76 'PowerPC': 'ppc',
|
|
77 'RISCV': 'riscv',
|
|
78 'Sparc': 'sparc',
|
|
79 'WebAssembly': 'wasm',
|
|
80 'X86': 'x86'})
|
|
81 ])
|
|
82
|
|
83 # Set a fake constant version so that we get consistent output.
|
|
84 config.environment['LLD_VERSION'] = 'LLD 1.0'
|
|
85 config.environment['LLD_IN_TEST'] = '1'
|
|
86
|
|
87 # Indirectly check if the mt.exe Microsoft utility exists by searching for
|
|
88 # cvtres, which always accompanies it. Alternatively, check if we can use
|
|
89 # libxml2 to merge manifests.
|
|
90 if (lit.util.which('cvtres', config.environment['PATH']) or
|
|
91 config.llvm_libxml2_enabled):
|
|
92 config.available_features.add('manifest_tool')
|
|
93
|
|
94 if config.llvm_libxml2_enabled:
|
|
95 config.available_features.add('libxml2')
|
|
96
|
|
97 if config.have_dia_sdk:
|
|
98 config.available_features.add("diasdk")
|
|
99
|
|
100 if config.sizeof_void_p == 8:
|
|
101 config.available_features.add("llvm-64-bits")
|
|
102
|
|
103 tar_executable = lit.util.which('tar', config.environment['PATH'])
|
|
104 if tar_executable:
|
|
105 tar_version = subprocess.Popen(
|
|
106 [tar_executable, '--version'],
|
|
107 stdout=subprocess.PIPE,
|
|
108 stderr=subprocess.PIPE,
|
|
109 env={'LANG': 'C'})
|
|
110 sout, _ = tar_version.communicate()
|
|
111 if 'GNU tar' in sout.decode():
|
|
112 config.available_features.add('gnutar')
|