llvm.org GIT mirror llvm / 1e4a125
[lit] Make lit support config files with .py extension. Many editors and Python-related diagnostics tools such as debuggers break or fail in mysterious ways when python files don't end in .py. This is especially true on Windows, but still exists on other platforms. I don't want to be too heavy handed in changing everything across the board, but I do want to at least *allow* lit configs to have .py extensions. This patch makes the discovery process first look for a config file with a .py extension, and if one is not found, then looks for a config file using the old method. So for existing users, there should be no functional change. Differential Revision: https://reviews.llvm.org/D37838 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313849 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 1 year, 11 months ago
14 changed file(s) with 551 addition(s) and 506 deletion(s). Raw diff Collapse all Expand all
11111111 # variables needed for the 'lit.site.cfg' files. This function bundles the
11121112 # common variables that any Lit instance is likely to need, and custom
11131113 # variables can be passed in.
1114 function(configure_lit_site_cfg input output)
1114 function(configure_lit_site_cfg site_in site_out)
1115 cmake_parse_arguments(ARG "" "" "MAIN_CONFIG" ${ARGN})
1116
1117 if ("${ARG_MAIN_CONFIG}" STREQUAL "")
1118 set(ARG_MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg")
1119 endif()
1120
11151121 foreach(c ${LLVM_TARGETS_TO_BUILD})
11161122 set(TARGETS_BUILT "${TARGETS_BUILT} ${c}")
11171123 endforeach(c)
11571163 set(HOST_CXX "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
11581164 set(HOST_LDFLAGS "${CMAKE_EXE_LINKER_FLAGS}")
11591165
1160 set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!")
1166 set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${site_in}\n## Do not edit!")
11611167
11621168 # Override config_target_triple (and the env)
11631169 if(LLVM_TARGET_TRIPLE_ENV)
11761182 "import lit.llvm\n"
11771183 "lit.llvm.initialize(lit_config, config)\n")
11781184
1179 configure_file(${input} ${output} @ONLY)
1180 get_filename_component(INPUT_DIR ${input} DIRECTORY)
1181 if (EXISTS "${INPUT_DIR}/lit.cfg")
1182 set(PYTHON_STATEMENT "map_config('${INPUT_DIR}/lit.cfg', '${output}')")
1185 configure_file(${site_in} ${site_out} @ONLY)
1186 get_filename_component(INPUT_DIR ${site_in} DIRECTORY)
1187 if (EXISTS "${ARG_MAIN_CONFIG}")
1188 set(PYTHON_STATEMENT "map_config('${ARG_MAIN_CONFIG}', '${site_out}')")
11831189 get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP)
11841190 set(LLVM_LIT_CONFIG_MAP "${LLVM_LIT_CONFIG_MAP}\n${PYTHON_STATEMENT}")
11851191 set_property(GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP ${LLVM_LIT_CONFIG_MAP})
1010 BUILD_SHARED_LIBS)
1111
1212 configure_lit_site_cfg(
13 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
14 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
13 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
14 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
15 MAIN_CONFIG
16 ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
1517 )
1618 configure_lit_site_cfg(
17 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
18 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
19 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
20 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
21 MAIN_CONFIG
22 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
1923 )
2024
2125 # Don't include check-llvm into check-all without LLVM_BUILD_TOOLS.
147151
148152 add_lit_testsuite(check-llvm "Running the LLVM regression tests"
149153 ${CMAKE_CURRENT_BINARY_DIR}
150 PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
151 llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
152154 DEPENDS ${LLVM_TEST_DEPENDS}
153155 )
154156 set_target_properties(check-llvm PROPERTIES FOLDER "Tests")
155157
156158 add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR}
157 PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
158 llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
159159 DEPENDS ${LLVM_TEST_DEPENDS}
160160 )
161161
+0
-46
test/Unit/lit.cfg less more
None # -*- Python -*-
1
2 # Configuration file for the 'lit' test runner.
3
4 import os
5 import subprocess
6
7 import lit.formats
8
9 # name: The name of this test suite.
10 config.name = 'LLVM-Unit'
11
12 # suffixes: A list of file extensions to treat as test files.
13 config.suffixes = []
14
15 # is_early; Request to run this suite early.
16 config.is_early = True
17
18 # test_source_root: The root path where tests are located.
19 # test_exec_root: The root path where tests should be run.
20 config.test_exec_root = os.path.join(config.llvm_obj_root, 'unittests')
21 config.test_source_root = config.test_exec_root
22
23 # testFormat: The test format to use to interpret tests.
24 config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
25
26 # Propagate the temp directory. Windows requires this because it uses \Windows\
27 # if none of these are present.
28 if 'TMP' in os.environ:
29 config.environment['TMP'] = os.environ['TMP']
30 if 'TEMP' in os.environ:
31 config.environment['TEMP'] = os.environ['TEMP']
32
33 # Propagate path to symbolizer for ASan/MSan.
34 for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
35 if symbolizer in os.environ:
36 config.environment[symbolizer] = os.environ[symbolizer]
37
38 # Win32 seeks DLLs along %PATH%.
39 if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
40 config.environment['PATH'] = os.path.pathsep.join((
41 config.shlibdir, config.environment['PATH']))
42
43 # Win32 may use %SYSTEMDRIVE% during file system shell operations, so propogate.
44 if sys.platform == 'win32' and 'SYSTEMDRIVE' in os.environ:
45 config.environment['SYSTEMDRIVE'] = os.environ['SYSTEMDRIVE']
0 # -*- Python -*-
1
2 # Configuration file for the 'lit' test runner.
3
4 import os
5 import subprocess
6
7 import lit.formats
8
9 # name: The name of this test suite.
10 config.name = 'LLVM-Unit'
11
12 # suffixes: A list of file extensions to treat as test files.
13 config.suffixes = []
14
15 # is_early; Request to run this suite early.
16 config.is_early = True
17
18 # test_source_root: The root path where tests are located.
19 # test_exec_root: The root path where tests should be run.
20 config.test_exec_root = os.path.join(config.llvm_obj_root, 'unittests')
21 config.test_source_root = config.test_exec_root
22
23 # testFormat: The test format to use to interpret tests.
24 config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
25
26 # Propagate the temp directory. Windows requires this because it uses \Windows\
27 # if none of these are present.
28 if 'TMP' in os.environ:
29 config.environment['TMP'] = os.environ['TMP']
30 if 'TEMP' in os.environ:
31 config.environment['TEMP'] = os.environ['TEMP']
32
33 # Propagate path to symbolizer for ASan/MSan.
34 for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
35 if symbolizer in os.environ:
36 config.environment[symbolizer] = os.environ[symbolizer]
37
38 # Win32 seeks DLLs along %PATH%.
39 if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
40 config.environment['PATH'] = os.path.pathsep.join((
41 config.shlibdir, config.environment['PATH']))
42
43 # Win32 may use %SYSTEMDRIVE% during file system shell operations, so propogate.
44 if sys.platform == 'win32' and 'SYSTEMDRIVE' in os.environ:
45 config.environment['SYSTEMDRIVE'] = os.environ['SYSTEMDRIVE']
+0
-23
test/Unit/lit.site.cfg.in less more
None @LIT_SITE_CFG_IN_HEADER@
1
2 import sys
3
4 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
5 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
6 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
7 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
8 config.enable_shared = @ENABLE_SHARED@
9 config.shlibdir = "@SHLIBDIR@"
10
11 # Support substitution of the tools_dir and build_mode with user parameters.
12 # This is used when we can't determine the tool dir at configuration time.
13 try:
14 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
15 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
16 except KeyError:
17 e = sys.exc_info()[1]
18 key, = e.args
19 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
20
21 # Let the main config do the real work.
22 lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg")
0 @LIT_SITE_CFG_IN_HEADER@
1
2 import sys
3
4 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
5 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
6 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
7 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
8 config.enable_shared = @ENABLE_SHARED@
9 config.shlibdir = "@SHLIBDIR@"
10
11 # Support substitution of the tools_dir and build_mode with user parameters.
12 # This is used when we can't determine the tool dir at configuration time.
13 try:
14 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
15 config.llvm_build_mode = config.llvm_build_mode % lit_config.params
16 except KeyError:
17 e = sys.exc_info()[1]
18 key, = e.args
19 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
20
21 # Let the main config do the real work.
22 lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg.py")
+0
-354
test/lit.cfg less more
None # -*- Python -*-
1
2 # Configuration file for the 'lit' test runner.
3
4 import os
5 import sys
6 import re
7 import platform
8 import subprocess
9
10 import lit.util
11 import lit.formats
12 from lit.llvm import llvm_config
13
14 # name: The name of this test suite.
15 config.name = 'LLVM'
16
17 # testFormat: The test format to use to interpret tests.
18 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
19
20 # suffixes: A list of file extensions to treat as test files. This is overriden
21 # by individual lit.local.cfg files in the test subdirectories.
22 config.suffixes = ['.ll', '.c', '.cxx', '.test', '.txt', '.s', '.mir']
23
24 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
25 # subdirectories contain auxiliary inputs for various tests in their parent
26 # directories.
27 config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
28
29 # test_source_root: The root path where tests are located.
30 config.test_source_root = os.path.dirname(__file__)
31
32 # test_exec_root: The root path where tests should be run.
33 config.test_exec_root = os.path.join(config.llvm_obj_root, 'test')
34
35 # Tweak the PATH to include the tools dir.
36 llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
37
38 # Propagate some variables from the host environment.
39 llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP', 'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
40
41
42 # Set up OCAMLPATH to include newly built OCaml libraries.
43 top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml')
44 llvm_ocaml_lib = os.path.join(top_ocaml_lib, 'llvm')
45
46 llvm_config.with_system_environment('OCAMLPATH')
47 llvm_config.with_environment('OCAMLPATH', top_ocaml_lib, append_path=True)
48 llvm_config.with_environment('OCAMLPATH', llvm_ocaml_lib, append_path=True)
49
50 llvm_config.with_system_environment('CAML_LD_LIBRARY_PATH')
51 llvm_config.with_environment('CAML_LD_LIBRARY_PATH', llvm_ocaml_lib, append_path=True)
52
53 # Set up OCAMLRUNPARAM to enable backtraces in OCaml tests.
54 llvm_config.with_environment('OCAMLRUNPARAM', 'b')
55
56 # Provide the path to asan runtime lib 'libclang_rt.asan_osx_dynamic.dylib' if
57 # available. This is darwin specific since it's currently only needed on darwin.
58 def get_asan_rtlib():
59 if not "Address" in config.llvm_use_sanitizer or \
60 not "Darwin" in config.host_os or \
61 not "x86" in config.host_triple:
62 return ""
63 try:
64 import glob
65 except:
66 print("glob module not found, skipping get_asan_rtlib() lookup")
67 return ""
68 # The libclang_rt.asan_osx_dynamic.dylib path is obtained using the relative
69 # path from the host cc.
70 host_lib_dir = os.path.join(os.path.dirname(config.host_cc), "../lib")
71 asan_dylib_dir_pattern = host_lib_dir + \
72 "/clang/*/lib/darwin/libclang_rt.asan_osx_dynamic.dylib"
73 found_dylibs = glob.glob(asan_dylib_dir_pattern)
74 if len(found_dylibs) != 1:
75 return ""
76 return found_dylibs[0]
77
78 lli = 'lli'
79 # The target triple used by default by lli is the process target triple (some
80 # triple appropriate for generating code for the current process) but because
81 # we don't support COFF in MCJIT well enough for the tests, force ELF format on
82 # Windows. FIXME: the process target triple should be used here, but this is
83 # difficult to obtain on Windows.
84 if re.search(r'cygwin|mingw32|windows-gnu|windows-msvc|win32', config.host_triple):
85 lli += ' -mtriple='+config.host_triple+'-elf'
86 config.substitutions.append( ('%lli', lli ) )
87
88 # Similarly, have a macro to use llc with DWARF even when the host is win32.
89 llc_dwarf = 'llc'
90 if re.search(r'win32', config.target_triple):
91 llc_dwarf += ' -mtriple='+config.target_triple.replace('-win32', '-mingw32')
92 config.substitutions.append( ('%llc_dwarf', llc_dwarf) )
93
94 # Add site-specific substitutions.
95 config.substitutions.append( ('%gold', config.gold_executable) )
96 config.substitutions.append( ('%go', config.go_executable) )
97 config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
98 config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
99 config.substitutions.append( ('%exeext', config.llvm_exe_ext) )
100 config.substitutions.append( ('%python', config.python_executable) )
101 config.substitutions.append( ('%host_cc', config.host_cc) )
102
103 # Provide the path to asan runtime lib if available. On darwin, this lib needs
104 # to be loaded via DYLD_INSERT_LIBRARIES before libLTO.dylib in case the files
105 # to be linked contain instrumented sanitizer code.
106 ld64_cmd = config.ld64_executable
107 asan_rtlib = get_asan_rtlib()
108 if asan_rtlib:
109 ld64_cmd = "DYLD_INSERT_LIBRARIES={} {}".format(asan_rtlib, ld64_cmd)
110 config.substitutions.append( ('%ld64', ld64_cmd) )
111
112 # OCaml substitutions.
113 # Support tests for both native and bytecode builds.
114 config.substitutions.append( ('%ocamlc',
115 "%s ocamlc -cclib -L%s %s" %
116 (config.ocamlfind_executable, config.llvm_lib_dir, config.ocaml_flags)) )
117 if config.have_ocamlopt:
118 config.substitutions.append( ('%ocamlopt',
119 "%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s" %
120 (config.ocamlfind_executable, config.llvm_lib_dir, config.llvm_lib_dir, config.ocaml_flags)) )
121 else:
122 config.substitutions.append( ('%ocamlopt', "true" ) )
123
124 # For each occurrence of an llvm tool name as its own word, replace it
125 # with the full path to the build directory holding that tool. This
126 # ensures that we are testing the tools just built and not some random
127 # tools that might happen to be in the user's PATH. Thus this list
128 # includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
129 # (llvm_tools_dir in lit parlance).
130
131 # Avoid matching RUN line fragments that are actually part of
132 # path names or options or whatever.
133 # The regex is a pre-assertion to avoid matching a preceding
134 # dot, hyphen, carat, or slash (.foo, -foo, etc.). Some patterns
135 # also have a post-assertion to not match a trailing hyphen (foo-).
136 NOJUNK = r"(?
137
138
139 def find_tool_substitution(pattern):
140 # Extract the tool name from the pattern. This relies on the tool
141 # name being surrounded by \b word match operators. If the
142 # pattern starts with "| ", include it in the string to be
143 # substituted.
144 tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
145 pattern)
146 tool_pipe = tool_match.group(2)
147 tool_name = tool_match.group(4)
148 # Did the user specify the tool path + arguments? This allows things like
149 # llvm-lit "-Dllc=llc -enable-misched -verify-machineinstrs"
150 tool_path = lit_config.params.get(tool_name)
151 if tool_path is None:
152 tool_path = lit.util.which(tool_name, config.llvm_tools_dir)
153 if tool_path is None:
154 return tool_name, tool_path, tool_pipe
155 if (tool_name == "llc" and
156 'LLVM_ENABLE_MACHINE_VERIFIER' in os.environ and
157 os.environ['LLVM_ENABLE_MACHINE_VERIFIER'] == "1"):
158 tool_path += " -verify-machineinstrs"
159 if (tool_name == "llvm-go"):
160 tool_path += " go=" + config.go_executable
161 return tool_name, tool_path, tool_pipe
162
163
164 for pattern in [r"\bbugpoint\b(?!-)",
165 NOJUNK + r"\bllc\b",
166 r"\blli\b",
167 r"\bllvm-ar\b",
168 r"\bllvm-as\b",
169 r"\bllvm-bcanalyzer\b",
170 r"\bllvm-config\b",
171 r"\bllvm-cov\b",
172 r"\bllvm-cxxdump\b",
173 r"\bllvm-cvtres\b",
174 r"\bllvm-diff\b",
175 r"\bllvm-dis\b",
176 r"\bllvm-dsymutil\b",
177 r"\bllvm-dwarfdump\b",
178 r"\bllvm-extract\b",
179 r"\bllvm-isel-fuzzer\b",
180 r"\bllvm-lib\b",
181 r"\bllvm-link\b",
182 r"\bllvm-lto\b",
183 r"\bllvm-lto2\b",
184 r"\bllvm-mc\b",
185 r"\bllvm-mcmarkup\b",
186 r"\bllvm-modextract\b",
187 r"\bllvm-nm\b",
188 r"\bllvm-objcopy\b",
189 r"\bllvm-objdump\b",
190 r"\bllvm-pdbutil\b",
191 r"\bllvm-profdata\b",
192 r"\bllvm-ranlib\b",
193 r"\bllvm-readobj\b",
194 r"\bllvm-rtdyld\b",
195 r"\bllvm-size\b",
196 r"\bllvm-split\b",
197 r"\bllvm-strings\b",
198 r"\bllvm-tblgen\b",
199 r"\bllvm-c-test\b",
200 r"\bllvm-cxxfilt\b",
201 r"\bllvm-xray\b",
202 NOJUNK + r"\bllvm-symbolizer\b",
203 NOJUNK + r"\bopt\b",
204 r"\bFileCheck\b",
205 r"\bobj2yaml\b",
206 NOJUNK + r"\bsancov\b",
207 NOJUNK + r"\bsanstats\b",
208 r"\byaml2obj\b",
209 r"\byaml-bench\b",
210 r"\bverify-uselistorder\b",
211 # Handle these specially as they are strings searched
212 # for during testing.
213 r"\| \bcount\b",
214 r"\| \bnot\b"]:
215 tool_name, tool_path, tool_pipe = find_tool_substitution(pattern)
216 if not tool_path:
217 # Warn, but still provide a substitution.
218 lit_config.note('Did not find ' + tool_name + ' in ' + config.llvm_tools_dir)
219 tool_path = config.llvm_tools_dir + '/' + tool_name
220 config.substitutions.append((pattern, tool_pipe + tool_path))
221
222 # For tools that are optional depending on the config, we won't warn
223 # if they're missing.
224 for pattern in [r"\bllvm-go\b",
225 r"\bllvm-mt\b",
226 r"\bKaleidoscope-Ch3\b",
227 r"\bKaleidoscope-Ch4\b",
228 r"\bKaleidoscope-Ch5\b",
229 r"\bKaleidoscope-Ch6\b",
230 r"\bKaleidoscope-Ch7\b",
231 r"\bKaleidoscope-Ch8\b"]:
232 tool_name, tool_path, tool_pipe = find_tool_substitution(pattern)
233 if not tool_path:
234 # Provide a substitution anyway, for the sake of consistent errors.
235 tool_path = config.llvm_tools_dir + '/' + tool_name
236 config.substitutions.append((pattern, tool_pipe + tool_path))
237
238
239 ### Targets
240
241 config.targets = frozenset(config.targets_to_build.split())
242
243 for arch in config.targets_to_build.split():
244 config.available_features.add(arch.lower() + '-registered-target')
245
246 ### Features
247
248 # Others/can-execute.txt
249 if sys.platform not in ['win32']:
250 config.available_features.add('can-execute')
251 config.available_features.add('not_COFF')
252
253 # Loadable module
254 # FIXME: This should be supplied by Makefile or autoconf.
255 if sys.platform in ['win32', 'cygwin']:
256 loadable_module = (config.enable_shared == 1)
257 else:
258 loadable_module = True
259
260 if loadable_module:
261 config.available_features.add('loadable_module')
262
263 # Static libraries are not built if BUILD_SHARED_LIBS is ON.
264 if not config.build_shared_libs:
265 config.available_features.add("static-libs")
266
267 # Direct object generation
268 if not 'hexagon' in config.target_triple:
269 config.available_features.add("object-emission")
270
271 # LLVM can be configured with an empty default triple
272 # Some tests are "generic" and require a valid default triple
273 if config.target_triple:
274 config.available_features.add("default_triple")
275
276 import subprocess
277
278 def have_ld_plugin_support():
279 if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
280 return False
281
282 ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE, env={'LANG': 'C'})
283 ld_out = ld_cmd.stdout.read().decode()
284 ld_cmd.wait()
285
286 if not '-plugin' in ld_out:
287 return False
288
289 # check that the used emulations are supported.
290 emu_line = [l for l in ld_out.split('\n') if 'supported emulations' in l]
291 if len(emu_line) != 1:
292 return False
293 emu_line = emu_line[0]
294 fields = emu_line.split(':')
295 if len(fields) != 3:
296 return False
297 emulations = fields[2].split()
298 if 'elf_x86_64' not in emulations:
299 return False
300 if 'elf32ppc' in emulations:
301 config.available_features.add('ld_emu_elf32ppc')
302
303 ld_version = subprocess.Popen([config.gold_executable, '--version'], stdout = subprocess.PIPE, env={'LANG': 'C'})
304 if not 'GNU gold' in ld_version.stdout.read().decode():
305 return False
306 ld_version.wait()
307
308 return True
309
310 if have_ld_plugin_support():
311 config.available_features.add('ld_plugin')
312
313 def have_ld64_plugin_support():
314 if not config.llvm_tool_lto_build or config.ld64_executable == '':
315 return False
316
317 ld_cmd = subprocess.Popen([config.ld64_executable, '-v'], stderr = subprocess.PIPE)
318 ld_out = ld_cmd.stderr.read().decode()
319 ld_cmd.wait()
320
321 if 'ld64' not in ld_out or 'LTO' not in ld_out:
322 return False
323
324 return True
325
326 if have_ld64_plugin_support():
327 config.available_features.add('ld64_plugin')
328
329 # Ask llvm-config about asserts and global-isel.
330 llvm_config.feature_config(
331 [('--assertion-mode', {'ON' : 'asserts'}),
332 ('--has-global-isel', {'ON' : 'global-isel'})])
333
334 if 'darwin' == sys.platform:
335 try:
336 sysctl_cmd = subprocess.Popen(['sysctl', 'hw.optional.fma'],
337 stdout = subprocess.PIPE)
338 except OSError:
339 print("Could not exec sysctl")
340 result = sysctl_cmd.stdout.read().decode('ascii')
341 if -1 != result.find("hw.optional.fma: 1"):
342 config.available_features.add('fma3')
343 sysctl_cmd.wait()
344
345 # .debug_frame is not emitted for targeting Windows x64.
346 if not re.match(r'^x86_64.*-(mingw32|windows-gnu|win32)', config.target_triple):
347 config.available_features.add('debug_frame')
348
349 if config.have_libxar:
350 config.available_features.add('xar')
351
352 if config.llvm_libxml2_enabled == "1":
353 config.available_features.add('libxml2')
0 # -*- Python -*-
1
2 # Configuration file for the 'lit' test runner.
3
4 import os
5 import sys
6 import re
7 import platform
8 import subprocess
9
10 import lit.util
11 import lit.formats
12 from lit.llvm import llvm_config
13
14 # name: The name of this test suite.
15 config.name = 'LLVM'
16
17 # testFormat: The test format to use to interpret tests.
18 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
19
20 # suffixes: A list of file extensions to treat as test files. This is overriden
21 # by individual lit.local.cfg files in the test subdirectories.
22 config.suffixes = ['.ll', '.c', '.cxx', '.test', '.txt', '.s', '.mir']
23
24 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
25 # subdirectories contain auxiliary inputs for various tests in their parent
26 # directories.
27 config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
28
29 # test_source_root: The root path where tests are located.
30 config.test_source_root = os.path.dirname(__file__)
31
32 # test_exec_root: The root path where tests should be run.
33 config.test_exec_root = os.path.join(config.llvm_obj_root, 'test')
34
35 # Tweak the PATH to include the tools dir.
36 llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
37
38 # Propagate some variables from the host environment.
39 llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP', 'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
40
41
42 # Set up OCAMLPATH to include newly built OCaml libraries.
43 top_ocaml_lib = os.path.join(config.llvm_lib_dir, 'ocaml')
44 llvm_ocaml_lib = os.path.join(top_ocaml_lib, 'llvm')
45
46 llvm_config.with_system_environment('OCAMLPATH')
47 llvm_config.with_environment('OCAMLPATH', top_ocaml_lib, append_path=True)
48 llvm_config.with_environment('OCAMLPATH', llvm_ocaml_lib, append_path=True)
49
50 llvm_config.with_system_environment('CAML_LD_LIBRARY_PATH')
51 llvm_config.with_environment('CAML_LD_LIBRARY_PATH', llvm_ocaml_lib, append_path=True)
52
53 # Set up OCAMLRUNPARAM to enable backtraces in OCaml tests.
54 llvm_config.with_environment('OCAMLRUNPARAM', 'b')
55
56 # Provide the path to asan runtime lib 'libclang_rt.asan_osx_dynamic.dylib' if
57 # available. This is darwin specific since it's currently only needed on darwin.
58 def get_asan_rtlib():
59 if not "Address" in config.llvm_use_sanitizer or \
60 not "Darwin" in config.host_os or \
61 not "x86" in config.host_triple:
62 return ""
63 try:
64 import glob
65 except:
66 print("glob module not found, skipping get_asan_rtlib() lookup")
67 return ""
68 # The libclang_rt.asan_osx_dynamic.dylib path is obtained using the relative
69 # path from the host cc.
70 host_lib_dir = os.path.join(os.path.dirname(config.host_cc), "../lib")
71 asan_dylib_dir_pattern = host_lib_dir + \
72 "/clang/*/lib/darwin/libclang_rt.asan_osx_dynamic.dylib"
73 found_dylibs = glob.glob(asan_dylib_dir_pattern)
74 if len(found_dylibs) != 1:
75 return ""
76 return found_dylibs[0]
77
78 lli = 'lli'
79 # The target triple used by default by lli is the process target triple (some
80 # triple appropriate for generating code for the current process) but because
81 # we don't support COFF in MCJIT well enough for the tests, force ELF format on
82 # Windows. FIXME: the process target triple should be used here, but this is
83 # difficult to obtain on Windows.
84 if re.search(r'cygwin|mingw32|windows-gnu|windows-msvc|win32', config.host_triple):
85 lli += ' -mtriple='+config.host_triple+'-elf'
86 config.substitutions.append( ('%lli', lli ) )
87
88 # Similarly, have a macro to use llc with DWARF even when the host is win32.
89 llc_dwarf = 'llc'
90 if re.search(r'win32', config.target_triple):
91 llc_dwarf += ' -mtriple='+config.target_triple.replace('-win32', '-mingw32')
92 config.substitutions.append( ('%llc_dwarf', llc_dwarf) )
93
94 # Add site-specific substitutions.
95 config.substitutions.append( ('%gold', config.gold_executable) )
96 config.substitutions.append( ('%go', config.go_executable) )
97 config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
98 config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
99 config.substitutions.append( ('%exeext', config.llvm_exe_ext) )
100 config.substitutions.append( ('%python', config.python_executable) )
101 config.substitutions.append( ('%host_cc', config.host_cc) )
102
103 # Provide the path to asan runtime lib if available. On darwin, this lib needs
104 # to be loaded via DYLD_INSERT_LIBRARIES before libLTO.dylib in case the files
105 # to be linked contain instrumented sanitizer code.
106 ld64_cmd = config.ld64_executable
107 asan_rtlib = get_asan_rtlib()
108 if asan_rtlib:
109 ld64_cmd = "DYLD_INSERT_LIBRARIES={} {}".format(asan_rtlib, ld64_cmd)
110 config.substitutions.append( ('%ld64', ld64_cmd) )
111
112 # OCaml substitutions.
113 # Support tests for both native and bytecode builds.
114 config.substitutions.append( ('%ocamlc',
115 "%s ocamlc -cclib -L%s %s" %
116 (config.ocamlfind_executable, config.llvm_lib_dir, config.ocaml_flags)) )
117 if config.have_ocamlopt:
118 config.substitutions.append( ('%ocamlopt',
119 "%s ocamlopt -cclib -L%s -cclib -Wl,-rpath,%s %s" %
120 (config.ocamlfind_executable, config.llvm_lib_dir, config.llvm_lib_dir, config.ocaml_flags)) )
121 else:
122 config.substitutions.append( ('%ocamlopt', "true" ) )
123
124 # For each occurrence of an llvm tool name as its own word, replace it
125 # with the full path to the build directory holding that tool. This
126 # ensures that we are testing the tools just built and not some random
127 # tools that might happen to be in the user's PATH. Thus this list
128 # includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
129 # (llvm_tools_dir in lit parlance).
130
131 # Avoid matching RUN line fragments that are actually part of
132 # path names or options or whatever.
133 # The regex is a pre-assertion to avoid matching a preceding
134 # dot, hyphen, carat, or slash (.foo, -foo, etc.). Some patterns
135 # also have a post-assertion to not match a trailing hyphen (foo-).
136 NOJUNK = r"(?
137
138
139 def find_tool_substitution(pattern):
140 # Extract the tool name from the pattern. This relies on the tool
141 # name being surrounded by \b word match operators. If the
142 # pattern starts with "| ", include it in the string to be
143 # substituted.
144 tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
145 pattern)
146 tool_pipe = tool_match.group(2)
147 tool_name = tool_match.group(4)
148 # Did the user specify the tool path + arguments? This allows things like
149 # llvm-lit "-Dllc=llc -enable-misched -verify-machineinstrs"
150 tool_path = lit_config.params.get(tool_name)
151 if tool_path is None:
152 tool_path = lit.util.which(tool_name, config.llvm_tools_dir)
153 if tool_path is None:
154 return tool_name, tool_path, tool_pipe
155 if (tool_name == "llc" and
156 'LLVM_ENABLE_MACHINE_VERIFIER' in os.environ and
157 os.environ['LLVM_ENABLE_MACHINE_VERIFIER'] == "1"):
158 tool_path += " -verify-machineinstrs"
159 if (tool_name == "llvm-go"):
160 tool_path += " go=" + config.go_executable
161 return tool_name, tool_path, tool_pipe
162
163
164 for pattern in [r"\bbugpoint\b(?!-)",
165 NOJUNK + r"\bllc\b",
166 r"\blli\b",
167 r"\bllvm-ar\b",
168 r"\bllvm-as\b",
169 r"\bllvm-bcanalyzer\b",
170 r"\bllvm-config\b",
171 r"\bllvm-cov\b",
172 r"\bllvm-cxxdump\b",
173 r"\bllvm-cvtres\b",
174 r"\bllvm-diff\b",
175 r"\bllvm-dis\b",
176 r"\bllvm-dsymutil\b",
177 r"\bllvm-dwarfdump\b",
178 r"\bllvm-extract\b",
179 r"\bllvm-isel-fuzzer\b",
180 r"\bllvm-lib\b",
181 r"\bllvm-link\b",
182 r"\bllvm-lto\b",
183 r"\bllvm-lto2\b",
184 r"\bllvm-mc\b",
185 r"\bllvm-mcmarkup\b",
186 r"\bllvm-modextract\b",
187 r"\bllvm-nm\b",
188 r"\bllvm-objcopy\b",
189 r"\bllvm-objdump\b",
190 r"\bllvm-pdbutil\b",
191 r"\bllvm-profdata\b",
192 r"\bllvm-ranlib\b",
193 r"\bllvm-readobj\b",
194 r"\bllvm-rtdyld\b",
195 r"\bllvm-size\b",
196 r"\bllvm-split\b",
197 r"\bllvm-strings\b",
198 r"\bllvm-tblgen\b",
199 r"\bllvm-c-test\b",
200 r"\bllvm-cxxfilt\b",
201 r"\bllvm-xray\b",
202 NOJUNK + r"\bllvm-symbolizer\b",
203 NOJUNK + r"\bopt\b",
204 r"\bFileCheck\b",
205 r"\bobj2yaml\b",
206 NOJUNK + r"\bsancov\b",
207 NOJUNK + r"\bsanstats\b",
208 r"\byaml2obj\b",
209 r"\byaml-bench\b",
210 r"\bverify-uselistorder\b",
211 # Handle these specially as they are strings searched
212 # for during testing.
213 r"\| \bcount\b",
214 r"\| \bnot\b"]:
215 tool_name, tool_path, tool_pipe = find_tool_substitution(pattern)
216 if not tool_path:
217 # Warn, but still provide a substitution.
218 lit_config.note('Did not find ' + tool_name + ' in ' + config.llvm_tools_dir)
219 tool_path = config.llvm_tools_dir + '/' + tool_name
220 config.substitutions.append((pattern, tool_pipe + tool_path))
221
222 # For tools that are optional depending on the config, we won't warn
223 # if they're missing.
224 for pattern in [r"\bllvm-go\b",
225 r"\bllvm-mt\b",
226 r"\bKaleidoscope-Ch3\b",
227 r"\bKaleidoscope-Ch4\b",
228 r"\bKaleidoscope-Ch5\b",
229 r"\bKaleidoscope-Ch6\b",
230 r"\bKaleidoscope-Ch7\b",
231 r"\bKaleidoscope-Ch8\b"]:
232 tool_name, tool_path, tool_pipe = find_tool_substitution(pattern)
233 if not tool_path:
234 # Provide a substitution anyway, for the sake of consistent errors.
235 tool_path = config.llvm_tools_dir + '/' + tool_name
236 config.substitutions.append((pattern, tool_pipe + tool_path))
237
238
239 ### Targets
240
241 config.targets = frozenset(config.targets_to_build.split())
242
243 for arch in config.targets_to_build.split():
244 config.available_features.add(arch.lower() + '-registered-target')
245
246 ### Features
247
248 # Others/can-execute.txt
249 if sys.platform not in ['win32']:
250 config.available_features.add('can-execute')
251 config.available_features.add('not_COFF')
252
253 # Loadable module
254 # FIXME: This should be supplied by Makefile or autoconf.
255 if sys.platform in ['win32', 'cygwin']:
256 loadable_module = (config.enable_shared == 1)
257 else:
258 loadable_module = True
259
260 if loadable_module:
261 config.available_features.add('loadable_module')
262
263 # Static libraries are not built if BUILD_SHARED_LIBS is ON.
264 if not config.build_shared_libs:
265 config.available_features.add("static-libs")
266
267 # Direct object generation
268 if not 'hexagon' in config.target_triple:
269 config.available_features.add("object-emission")
270
271 # LLVM can be configured with an empty default triple
272 # Some tests are "generic" and require a valid default triple
273 if config.target_triple:
274 config.available_features.add("default_triple")
275
276 import subprocess
277
278 def have_ld_plugin_support():
279 if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
280 return False
281
282 ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE, env={'LANG': 'C'})
283 ld_out = ld_cmd.stdout.read().decode()
284 ld_cmd.wait()
285
286 if not '-plugin' in ld_out:
287 return False
288
289 # check that the used emulations are supported.
290 emu_line = [l for l in ld_out.split('\n') if 'supported emulations' in l]
291 if len(emu_line) != 1:
292 return False
293 emu_line = emu_line[0]
294 fields = emu_line.split(':')
295 if len(fields) != 3:
296 return False
297 emulations = fields[2].split()
298 if 'elf_x86_64' not in emulations:
299 return False
300 if 'elf32ppc' in emulations:
301 config.available_features.add('ld_emu_elf32ppc')
302
303 ld_version = subprocess.Popen([config.gold_executable, '--version'], stdout = subprocess.PIPE, env={'LANG': 'C'})
304 if not 'GNU gold' in ld_version.stdout.read().decode():
305 return False
306 ld_version.wait()
307
308 return True
309
310 if have_ld_plugin_support():
311 config.available_features.add('ld_plugin')
312
313 def have_ld64_plugin_support():
314 if not config.llvm_tool_lto_build or config.ld64_executable == '':
315 return False
316
317 ld_cmd = subprocess.Popen([config.ld64_executable, '-v'], stderr = subprocess.PIPE)
318 ld_out = ld_cmd.stderr.read().decode()
319 ld_cmd.wait()
320
321 if 'ld64' not in ld_out or 'LTO' not in ld_out:
322 return False
323
324 return True
325
326 if have_ld64_plugin_support():
327 config.available_features.add('ld64_plugin')
328
329 # Ask llvm-config about asserts and global-isel.
330 llvm_config.feature_config(
331 [('--assertion-mode', {'ON' : 'asserts'}),
332 ('--has-global-isel', {'ON' : 'global-isel'})])
333
334 if 'darwin' == sys.platform:
335 try:
336 sysctl_cmd = subprocess.Popen(['sysctl', 'hw.optional.fma'],
337 stdout = subprocess.PIPE)
338 except OSError:
339 print("Could not exec sysctl")
340 result = sysctl_cmd.stdout.read().decode('ascii')
341 if -1 != result.find("hw.optional.fma: 1"):
342 config.available_features.add('fma3')
343 sysctl_cmd.wait()
344
345 # .debug_frame is not emitted for targeting Windows x64.
346 if not re.match(r'^x86_64.*-(mingw32|windows-gnu|win32)', config.target_triple):
347 config.available_features.add('debug_frame')
348
349 if config.have_libxar:
350 config.available_features.add('xar')
351
352 if config.llvm_libxml2_enabled == "1":
353 config.available_features.add('libxml2')
+0
-58
test/lit.site.cfg.in less more
None @LIT_SITE_CFG_IN_HEADER@
1
2 import sys
3
4 config.host_triple = "@LLVM_HOST_TRIPLE@"
5 config.target_triple = "@TARGET_TRIPLE@"
6 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
7 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
8 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
9 config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
10 config.llvm_shlib_dir = "@SHLIBDIR@"
11 config.llvm_shlib_ext = "@SHLIBEXT@"
12 config.llvm_exe_ext = "@EXEEXT@"
13 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
14 config.python_executable = "@PYTHON_EXECUTABLE@"
15 config.gold_executable = "@GOLD_EXECUTABLE@"
16 config.ld64_executable = "@LD64_EXECUTABLE@"
17 config.llvm_tool_lto_build = @LLVM_TOOL_LTO_BUILD@
18 config.ocamlfind_executable = "@OCAMLFIND@"
19 config.have_ocamlopt = @HAVE_OCAMLOPT@
20 config.have_ocaml_ounit = @HAVE_OCAML_OUNIT@
21 config.ocaml_flags = "@OCAMLFLAGS@"
22 config.include_go_tests = @LLVM_INCLUDE_GO_TESTS@
23 config.go_executable = "@GO_EXECUTABLE@"
24 config.enable_shared = @ENABLE_SHARED@
25 config.enable_assertions = @ENABLE_ASSERTIONS@
26 config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
27 config.targets_to_build = "@TARGETS_TO_BUILD@"
28 config.native_target = "@LLVM_NATIVE_ARCH@"
29 config.llvm_bindings = "@LLVM_BINDINGS@".split(' ')
30 config.host_os = "@HOST_OS@"
31 config.host_arch = "@HOST_ARCH@"
32 config.host_cc = "@HOST_CC@"
33 config.host_cxx = "@HOST_CXX@"
34 config.host_ldflags = "@HOST_LDFLAGS@"
35 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
36 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
37 config.have_zlib = @HAVE_LIBZ@
38 config.have_libxar = @HAVE_LIBXAR@
39 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
40 config.enable_ffi = @LLVM_ENABLE_FFI@
41 config.build_shared_libs = @BUILD_SHARED_LIBS@
42 config.llvm_libxml2_enabled = "@LLVM_LIBXML2_ENABLED@"
43
44 # Support substitution of the tools_dir with user parameters. This is
45 # used when we can't determine the tool dir at configuration time.
46 try:
47 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
48 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
49 except KeyError:
50 e = sys.exc_info()[1]
51 key, = e.args
52 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
53
54 @LIT_SITE_CFG_IN_FOOTER@
55
56 # Let the main config do the real work.
57 lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/lit.cfg")
0 @LIT_SITE_CFG_IN_HEADER@
1
2 import sys
3
4 config.host_triple = "@LLVM_HOST_TRIPLE@"
5 config.target_triple = "@TARGET_TRIPLE@"
6 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
7 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
8 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
9 config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
10 config.llvm_shlib_dir = "@SHLIBDIR@"
11 config.llvm_shlib_ext = "@SHLIBEXT@"
12 config.llvm_exe_ext = "@EXEEXT@"
13 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
14 config.python_executable = "@PYTHON_EXECUTABLE@"
15 config.gold_executable = "@GOLD_EXECUTABLE@"
16 config.ld64_executable = "@LD64_EXECUTABLE@"
17 config.llvm_tool_lto_build = @LLVM_TOOL_LTO_BUILD@
18 config.ocamlfind_executable = "@OCAMLFIND@"
19 config.have_ocamlopt = @HAVE_OCAMLOPT@
20 config.have_ocaml_ounit = @HAVE_OCAML_OUNIT@
21 config.ocaml_flags = "@OCAMLFLAGS@"
22 config.include_go_tests = @LLVM_INCLUDE_GO_TESTS@
23 config.go_executable = "@GO_EXECUTABLE@"
24 config.enable_shared = @ENABLE_SHARED@
25 config.enable_assertions = @ENABLE_ASSERTIONS@
26 config.enable_abi_breaking_checks = "@LLVM_ENABLE_ABI_BREAKING_CHECKS@"
27 config.targets_to_build = "@TARGETS_TO_BUILD@"
28 config.native_target = "@LLVM_NATIVE_ARCH@"
29 config.llvm_bindings = "@LLVM_BINDINGS@".split(' ')
30 config.host_os = "@HOST_OS@"
31 config.host_arch = "@HOST_ARCH@"
32 config.host_cc = "@HOST_CC@"
33 config.host_cxx = "@HOST_CXX@"
34 config.host_ldflags = "@HOST_LDFLAGS@"
35 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
36 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
37 config.have_zlib = @HAVE_LIBZ@
38 config.have_libxar = @HAVE_LIBXAR@
39 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
40 config.enable_ffi = @LLVM_ENABLE_FFI@
41 config.build_shared_libs = @BUILD_SHARED_LIBS@
42 config.llvm_libxml2_enabled = "@LLVM_LIBXML2_ENABLED@"
43
44 # Support substitution of the tools_dir with user parameters. This is
45 # used when we can't determine the tool dir at configuration time.
46 try:
47 config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
48 config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
49 except KeyError:
50 e = sys.exc_info()[1]
51 key, = e.args
52 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
53
54 @LIT_SITE_CFG_IN_FOOTER@
55
56 # Let the main config do the real work.
57 lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/lit.cfg.py")
4343
4444 # Configuration files to look for when discovering test suites.
4545 self.config_prefix = config_prefix or 'lit'
46 self.config_name = '%s.cfg' % (self.config_prefix,)
47 self.site_config_name = '%s.site.cfg' % (self.config_prefix,)
48 self.local_config_name = '%s.local.cfg' % (self.config_prefix,)
46 self.suffixes = ['cfg.py', 'cfg']
47 self.config_names = ['%s.%s' % (self.config_prefix,x) for x in self.suffixes]
48 self.site_config_names = ['%s.site.%s' % (self.config_prefix,x) for x in self.suffixes]
49 self.local_config_names = ['%s.local.%s' % (self.config_prefix,x) for x in self.suffixes]
4950
5051 self.numErrors = 0
5152 self.numWarnings = 0
99 from lit.TestingConfig import TestingConfig
1010 from lit import LitConfig, Test
1111
12 def chooseConfigFileFromDir(dir, config_names):
13 for name in config_names:
14 p = os.path.join(dir, name)
15 if os.path.exists(p):
16 return p
17 return None
18
1219 def dirContainsTestSuite(path, lit_config):
13 cfgpath = os.path.join(path, lit_config.site_config_name)
14 if os.path.exists(cfgpath):
15 return cfgpath
16 cfgpath = os.path.join(path, lit_config.config_name)
17 if os.path.exists(cfgpath):
18 return cfgpath
20 cfgpath = chooseConfigFileFromDir(path, lit_config.site_config_names)
21 if not cfgpath:
22 cfgpath = chooseConfigFileFromDir(path, lit_config.config_names)
23 return cfgpath
1924
2025 def getTestSuite(item, litConfig, cache):
2126 """getTestSuite(item, litConfig, cache) -> (suite, relative_path)
98103
99104 # Check if there is a local configuration file.
100105 source_path = ts.getSourcePath(path_in_suite)
101 cfgpath = os.path.join(source_path, litConfig.local_config_name)
106 cfgpath = chooseConfigFileFromDir(source_path, litConfig.local_config_names)
102107
103108 # If not, just reuse the parent config.
104 if not os.path.exists(cfgpath):
109 if not cfgpath:
105110 return parent
106111
107112 # Otherwise, copy the current config and load the local configuration
0 # Load the discovery suite, but with a separate exec root.
1 import os
2 config.test_exec_root = os.path.dirname(__file__)
3 config.test_source_root = os.path.join(os.path.dirname(config.test_exec_root), "discovery")
4 lit_config.load_config(config, os.path.join(config.test_source_root, "lit.cfg"))
3737 # CHECK-EXACT-TEST: sub-suite :: test-one
3838 # CHECK-EXACT-TEST: top-level-suite :: subdir/test-three
3939
40 # Check discovery when config files end in .py
41 # RUN: %{lit} %{inputs}/py-config-discovery \
42 # RUN: -j 1 --debug --show-tests --show-suites \
43 # RUN: -v > %t.out 2> %t.err
44 # RUN: FileCheck --check-prefix=CHECK-PYCONFIG-OUT < %t.out %s
45 # RUN: FileCheck --check-prefix=CHECK-PYCONFIG-ERR < %t.err %s
46 #
47 # CHECK-PYCONFIG-ERR: loading suite config '{{.*(/|\\\\)py-config-discovery(/|\\\\)lit.site.cfg.py}}'
48 # CHECK-PYCONFIG-ERR: load_config from '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
49 # CHECK-PYCONFIG-ERR: loaded config '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
50 # CHECK-PYCONFIG-ERR: loaded config '{{.*(/|\\\\)py-config-discovery(/|\\\\)lit.site.cfg.py}}'
51 # CHECK-PYCONFIG-ERR-DAG: loading suite config '{{.*(/|\\\\)discovery(/|\\\\)subsuite(/|\\\\)lit.cfg}}'
52 # CHECK-PYCONFIG-ERR-DAG: loading local config '{{.*(/|\\\\)discovery(/|\\\\)subdir(/|\\\\)lit.local.cfg}}'
53 #
54 # CHECK-PYCONFIG-OUT: -- Test Suites --
55 # CHECK-PYCONFIG-OUT: sub-suite - 2 tests
56 # CHECK-PYCONFIG-OUT: Source Root: {{.*[/\\]discovery[/\\]subsuite$}}
57 # CHECK-PYCONFIG-OUT: Exec Root : {{.*[/\\]discovery[/\\]subsuite$}}
58 # CHECK-PYCONFIG-OUT: top-level-suite - 3 tests
59 # CHECK-PYCONFIG-OUT: Source Root: {{.*[/\\]discovery$}}
60 # CHECK-PYCONFIG-OUT: Exec Root : {{.*[/\\]py-config-discovery$}}
61 #
62 # CHECK-PYCONFIG-OUT: -- Available Tests --
63 # CHECK-PYCONFIG-OUT: sub-suite :: test-one
64 # CHECK-PYCONFIG-OUT: sub-suite :: test-two
65 # CHECK-PYCONFIG-OUT: top-level-suite :: subdir/test-three
66 # CHECK-PYCONFIG-OUT: top-level-suite :: test-one
67 # CHECK-PYCONFIG-OUT: top-level-suite :: test-two
4068
4169 # Check discovery when using an exec path.
4270 #