3 # Configuration file for the 'lit' test runner.
10 # name: The name of this test suite.
13 # Tweak PATH for Win32 to decide to use bash.exe or not.
14 if sys.platform in ['win32']:
15 # Seek sane tools in directories and set to $PATH.
16 path = getattr(config, 'lit_tools_dir', None)
17 path = lit.getToolsPath(path,
18 config.environment['PATH'],
19 ['cmp.exe', 'grep.exe', 'sed.exe'])
21 path = os.path.pathsep.join((path,
22 config.environment['PATH']))
23 config.environment['PATH'] = path
25 # Choose between lit's internal shell pipeline runner and a real shell. If
26 # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
27 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
29 # 0 is external, "" is default, and everything else is internal.
30 execute_external = (use_lit_shell == "0")
32 # Otherwise we default to internal on Windows and external elsewhere, as
33 # bash on Windows is usually very slow.
34 execute_external = (not sys.platform in ['win32'])
36 # testFormat: The test format to use to interpret tests.
37 config.test_format = lit.formats.ShTest(execute_external)
39 # To ignore test output on stderr so it doesn't trigger failures uncomment this:
40 #config.test_format = lit.formats.TclTest(ignoreStdErr=True)
42 # suffixes: A list of file extensions to treat as test files, this is actually
46 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
47 # subdirectories contain auxiliary inputs for various tests in their parent
49 config.excludes = ['Inputs']
51 # test_source_root: The root path where tests are located.
52 config.test_source_root = os.path.dirname(__file__)
54 # test_exec_root: The root path where tests should be run.
55 llvm_obj_root = getattr(config, 'llvm_obj_root', None)
56 if llvm_obj_root is not None:
57 config.test_exec_root = os.path.join(llvm_obj_root, 'test')
59 # Tweak the PATH to include the scripts dir, the tools dir, and the llvm-gcc bin
61 if llvm_obj_root is not None:
62 llvm_src_root = getattr(config, 'llvm_src_root', None)
64 lit.fatal('No LLVM source root set!')
65 path = os.path.pathsep.join((os.path.join(llvm_src_root, 'test',
67 config.environment['PATH']))
68 config.environment['PATH'] = path
70 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
71 if not llvm_tools_dir:
72 lit.fatal('No LLVM tools dir set!')
73 path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
74 config.environment['PATH'] = path
76 # Propagate 'HOME' through the environment.
77 if 'HOME' in os.environ:
78 config.environment['HOME'] = os.environ['HOME']
80 # Propagate 'INCLUDE' through the environment.
81 if 'INCLUDE' in os.environ:
82 config.environment['INCLUDE'] = os.environ['INCLUDE']
84 # Propagate 'LIB' through the environment.
85 if 'LIB' in os.environ:
86 config.environment['LIB'] = os.environ['LIB']
88 # Propagate the temp directory. Windows requires this because it uses \Windows\
89 # if none of these are present.
90 if 'TMP' in os.environ:
91 config.environment['TMP'] = os.environ['TMP']
92 if 'TEMP' in os.environ:
93 config.environment['TEMP'] = os.environ['TEMP']
95 # Propagate LLVM_SRC_ROOT into the environment.
96 config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '')
98 # Propagate PYTHON_EXECUTABLE into the environment
99 config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable',
102 # Propagate path to symbolizer for ASan/MSan.
103 for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
104 if symbolizer in os.environ:
105 config.environment[symbolizer] = os.environ[symbolizer]
111 # Check that the object root is known.
112 if config.test_exec_root is None:
113 # Otherwise, we haven't loaded the site specific configuration (the user is
114 # probably trying to run on a test file directly, and either the site
115 # configuration hasn't been created by the build system, or we are in an
116 # out-of-tree build situation).
118 # Check for 'llvm_site_config' user parameter, and use that if available.
119 site_cfg = lit.params.get('llvm_site_config', None)
120 if site_cfg and os.path.exists(site_cfg):
121 lit.load_config(config, site_cfg)
124 # Try to detect the situation where we are using an out-of-tree build by
125 # looking for 'llvm-config'.
127 # FIXME: I debated (i.e., wrote and threw away) adding logic to
128 # automagically generate the lit.site.cfg if we are in some kind of fresh
129 # build situation. This means knowing how to invoke the build system
130 # though, and I decided it was too much magic.
132 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
134 lit.fatal('No site specific configuration available!')
136 # Get the source and object roots.
137 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
138 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
140 # Validate that we got a tree which points to here.
141 this_src_root = os.path.dirname(config.test_source_root)
142 if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
143 lit.fatal('No site specific configuration available!')
145 # Check that the site specific configuration exists.
146 site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg')
147 if not os.path.exists(site_cfg):
148 lit.fatal('No site specific configuration available!')
150 # Okay, that worked. Notify the user of the automagic, and reconfigure.
151 lit.note('using out-of-tree build at %r' % llvm_obj_root)
152 lit.load_config(config, site_cfg)
157 # Provide a command line for mcjit tests
158 lli_mcjit = 'lli -use-mcjit'
159 # The target triple used by default by lli is the process target triple (some
160 # triple appropriate for generating code for the current process) but because
161 # we don't support COFF in MCJIT well enough for the tests, force ELF format on
162 # Windows. FIXME: the process target triple should be used here, but this is
163 # difficult to obtain on Windows.
164 if re.search(r'cygwin|mingw32|win32', config.host_triple):
165 lli_mcjit += ' -mtriple='+config.host_triple+'-elf'
166 config.substitutions.append( ('%lli_mcjit', lli_mcjit) )
168 # Provide a substition for those tests that need to run the jit to obtain data
169 # but simply want use the currently considered most reliable jit for platform
170 # FIXME: ppc32 is not ready for mcjit.
171 if 'arm' in config.target_triple \
172 or 'powerpc64' in config.target_triple:
173 defaultIsMCJIT = 'true'
175 defaultIsMCJIT = 'false'
176 config.substitutions.append( ('%defaultjit', '-use-mcjit='+defaultIsMCJIT) )
178 # Process jit implementation option
179 jit_impl_cfg = lit.params.get('jit_impl', None)
180 if jit_impl_cfg == 'mcjit':
181 # When running with mcjit, mangle -mcjit into target triple
182 # and add -use-mcjit flag to lli invocation
183 if 'i686' in config.target_triple:
184 config.target_triple += jit_impl_cfg + '-ia32'
185 elif 'x86_64' in config.target_triple:
186 config.target_triple += jit_impl_cfg + '-ia64'
188 config.target_triple += jit_impl_cfg
190 config.substitutions.append( ('%lli', 'lli -use-mcjit') )
192 config.substitutions.append( ('%lli', 'lli') )
194 # Add site-specific substitutions.
195 config.substitutions.append( ('%ocamlopt', config.ocamlopt_executable) )
196 config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
197 config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
199 # For each occurrence of an llvm tool name as its own word, replace it
200 # with the full path to the build directory holding that tool. This
201 # ensures that we are testing the tools just built and not some random
202 # tools that might happen to be in the user's PATH. Thus this list
203 # includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
204 # (llvm_tools_dir in lit parlance).
205 # Don't match 'bugpoint-' or 'clang-'.
206 # Don't match '/clang' or '-clang'.
207 if os.pathsep == ';':
208 pathext = os.environ.get('PATHEXT', '').split(';')
211 for pattern in [r"\bbugpoint\b(?!-)", r"(?<!/|-)\bclang\b(?!-)",
213 r"\bllc\b", r"\blli\b",
214 r"\bllvm-ar\b", r"\bllvm-as\b",
215 r"\bllvm-bcanalyzer\b", r"\bllvm-config\b",
216 r"\bllvm-cov\b", r"\bllvm-diff\b",
217 r"\bllvm-dis\b", r"\bllvm-dwarfdump\b",
218 r"\bllvm-extract\b", r"\bllvm-jistlistener\b",
219 r"\bllvm-link\b", r"\bllvm-mc\b",
220 r"\bllvm-nm\b", r"\bllvm-objdump\b",
221 r"\bllvm-prof\b", r"\bllvm-ranlib\b",
222 r"\bllvm-rtdyld\b", r"\bllvm-shlib\b",
224 # Don't match '-llvmc'.
225 r"(?<!-)\bllvmc\b", r"\blto\b",
226 # Don't match '.opt', '-opt',
228 r"\bmacho-dump\b", r"(?<!\.|-|\^|/)\bopt\b",
229 r"\bllvm-tblgen\b", r"\bFileCheck\b",
230 r"\bFileUpdate\b", r"\bc-index-test\b",
231 r"\bfpcmp\b", r"\bllvm-PerfectShuffle\b",
232 # Handle these specially as they are strings searched
233 # for during testing.
234 r"\| \bcount\b", r"\| \bnot\b"]:
235 # Extract the tool name from the pattern. This relies on the tool
236 # name being surrounded by \b word match operators. If the
237 # pattern starts with "| ", include it in the string to be
239 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
240 r"\2" + llvm_tools_dir + "/" + r"\4",
243 substitution_ext = substitution + ext
244 if os.path.exists(substitution_ext):
245 substitution = substitution_ext
247 config.substitutions.append((pattern, substitution))
253 config.available_features.add('shell')
256 # FIXME: This should be supplied by Makefile or autoconf.
257 if sys.platform in ['win32', 'cygwin']:
258 loadable_module = (config.enable_shared == 1)
260 loadable_module = True
263 config.available_features.add('loadable_module')
266 if config.lto_is_enabled == "1" and platform.system() == "Darwin":
267 config.available_features.add('lto_on_osx')
270 if config.llvm_use_sanitizer == "Address":
271 config.available_features.add("asan")
272 if (config.llvm_use_sanitizer == "Memory" or
273 config.llvm_use_sanitizer == "MemoryWithOrigins"):
274 config.available_features.add("msan")
276 # llc knows whether he is compiled with -DNDEBUG.
279 llc_cmd = subprocess.Popen([os.path.join(llvm_tools_dir, 'llc'), '-version'],
280 stdout = subprocess.PIPE)
282 print "Could not find llc in " + llvm_tools_dir
285 if re.search(r'with assertions', llc_cmd.stdout.read()):
286 config.available_features.add('asserts')