3 # Configuration file for the 'lit' test runner.
9 # name: The name of this test suite.
12 # Tweak PATH for Win32 to decide to use bash.exe or not.
13 if sys.platform in ['win32']:
14 # Seek sane tools in directories and set to $PATH.
15 path = getattr(config, 'lit_tools_dir', None)
16 path = lit.getToolsPath(path,
17 config.environment['PATH'],
18 ['cmp.exe', 'grep.exe', 'sed.exe'])
20 path = os.path.pathsep.join((path,
21 config.environment['PATH']))
22 config.environment['PATH'] = path
24 # testFormat: The test format to use to interpret tests.
25 execute_external = (not sys.platform in ['win32']
26 or lit.getBashPath() not in [None, ""])
27 config.test_format = lit.formats.ShTest(execute_external)
29 # To ignore test output on stderr so it doesn't trigger failures uncomment this:
30 #config.test_format = lit.formats.TclTest(ignoreStdErr=True)
32 # suffixes: A list of file extensions to treat as test files, this is actually
36 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
37 # subdirectories contain auxiliary inputs for various tests in their parent
39 config.excludes = ['Inputs']
41 # test_source_root: The root path where tests are located.
42 config.test_source_root = os.path.dirname(__file__)
44 # test_exec_root: The root path where tests should be run.
45 llvm_obj_root = getattr(config, 'llvm_obj_root', None)
46 if llvm_obj_root is not None:
47 config.test_exec_root = os.path.join(llvm_obj_root, 'test')
49 # Tweak the PATH to include the scripts dir, the tools dir, and the llvm-gcc bin
51 if llvm_obj_root is not None:
52 llvm_src_root = getattr(config, 'llvm_src_root', None)
54 lit.fatal('No LLVM source root set!')
55 path = os.path.pathsep.join((os.path.join(llvm_src_root, 'test',
57 config.environment['PATH']))
58 config.environment['PATH'] = path
60 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
61 if not llvm_tools_dir:
62 lit.fatal('No LLVM tools dir set!')
63 path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
64 config.environment['PATH'] = path
66 # Propagate 'HOME' through the environment.
67 if 'HOME' in os.environ:
68 config.environment['HOME'] = os.environ['HOME']
70 # Propagate 'INCLUDE' through the environment.
71 if 'INCLUDE' in os.environ:
72 config.environment['INCLUDE'] = os.environ['INCLUDE']
74 # Propagate 'LIB' through the environment.
75 if 'LIB' in os.environ:
76 config.environment['LIB'] = os.environ['LIB']
78 # Propagate the temp directory. Windows requires this because it uses \Windows\
79 # if none of these are present.
80 if 'TMP' in os.environ:
81 config.environment['TMP'] = os.environ['TMP']
82 if 'TEMP' in os.environ:
83 config.environment['TEMP'] = os.environ['TEMP']
85 # Propagate LLVM_SRC_ROOT into the environment.
86 config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '')
88 # Propagate PYTHON_EXECUTABLE into the environment
89 config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable',
96 # Check that the object root is known.
97 if config.test_exec_root is None:
98 # Otherwise, we haven't loaded the site specific configuration (the user is
99 # probably trying to run on a test file directly, and either the site
100 # configuration hasn't been created by the build system, or we are in an
101 # out-of-tree build situation).
103 # Check for 'llvm_site_config' user parameter, and use that if available.
104 site_cfg = lit.params.get('llvm_site_config', None)
105 if site_cfg and os.path.exists(site_cfg):
106 lit.load_config(config, site_cfg)
109 # Try to detect the situation where we are using an out-of-tree build by
110 # looking for 'llvm-config'.
112 # FIXME: I debated (i.e., wrote and threw away) adding logic to
113 # automagically generate the lit.site.cfg if we are in some kind of fresh
114 # build situation. This means knowing how to invoke the build system
115 # though, and I decided it was too much magic.
117 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
119 lit.fatal('No site specific configuration available!')
121 # Get the source and object roots.
122 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
123 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
125 # Validate that we got a tree which points to here.
126 this_src_root = os.path.dirname(config.test_source_root)
127 if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
128 lit.fatal('No site specific configuration available!')
130 # Check that the site specific configuration exists.
131 site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg')
132 if not os.path.exists(site_cfg):
133 lit.fatal('No site specific configuration available!')
135 # Okay, that worked. Notify the user of the automagic, and reconfigure.
136 lit.note('using out-of-tree build at %r' % llvm_obj_root)
137 lit.load_config(config, site_cfg)
142 # When running under valgrind, we mangle '-vg' or '-vg_leak' onto the end of the
143 # triple so we can check it with XFAIL and XTARGET.
144 config.target_triple += lit.valgrindTriple
146 # Process jit implementation option
147 jit_impl_cfg = lit.params.get('jit_impl', None)
148 if jit_impl_cfg == 'mcjit':
149 # When running with mcjit, mangle -mcjit into target triple
150 # and add -use-mcjit flag to lli invocation
151 if 'i686' in config.target_triple:
152 config.target_triple += jit_impl_cfg + '-ia32'
153 elif 'x86_64' in config.target_triple:
154 config.target_triple += jit_impl_cfg + '-ia64'
156 config.target_triple += jit_impl_cfg
158 config.substitutions.append( ('%lli', 'lli -use-mcjit') )
160 config.substitutions.append( ('%lli', 'lli') )
162 # Add site-specific substitutions.
163 config.substitutions.append( ('%ocamlopt', config.ocamlopt_executable) )
164 config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
165 config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )
167 # For each occurrence of an llvm tool name as its own word, replace it
168 # with the full path to the build directory holding that tool. This
169 # ensures that we are testing the tools just built and not some random
170 # tools that might happen to be in the user's PATH. Thus this list
171 # includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
172 # (llvm_tools_dir in lit parlance).
173 # Don't match 'bugpoint-' or 'clang-'.
174 # Don't match '/clang' or '-clang'.
175 if os.pathsep == ';':
176 pathext = os.environ.get('PATHEXT', '').split(';')
179 for pattern in [r"\bbugpoint\b(?!-)", r"(?<!/|-)\bclang\b(?!-)",
181 r"\bllc\b", r"\blli\b",
182 r"\bllvm-ar\b", r"\bllvm-as\b",
183 r"\bllvm-bcanalyzer\b", r"\bllvm-config\b",
184 r"\bllvm-cov\b", r"\bllvm-diff\b",
185 r"\bllvm-dis\b", r"\bllvm-dwarfdump\b",
187 r"\bllvm-link\b", r"\bllvm-mc\b",
188 r"\bllvm-nm\b", r"\bllvm-objdump\b",
189 r"\bllvm-prof\b", r"\bllvm-ranlib\b",
190 r"\bllvm-rtdyld\b", r"\bllvm-shlib\b",
192 # Don't match '-llvmc'.
193 r"(?<!-)\bllvmc\b", r"\blto\b",
194 # Don't match '.opt', '-opt',
196 r"\bmacho-dump\b", r"(?<!\.|-|\^|/)\bopt\b",
197 r"\bllvm-tblgen\b", r"\bFileCheck\b",
198 r"\bFileUpdate\b", r"\bc-index-test\b",
199 r"\bfpcmp\b", r"\bllvm-PerfectShuffle\b",
200 # Handle these specially as they are strings searched
201 # for during testing.
202 r"\| \bcount\b", r"\| \bnot\b"]:
203 # Extract the tool name from the pattern. This relies on the tool
204 # name being surrounded by \b word match operators. If the
205 # pattern starts with "| ", include it in the string to be
207 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
208 r"\2" + llvm_tools_dir + "/" + r"\4",
211 substitution_ext = substitution + ext
212 if os.path.exists(substitution_ext):
213 substitution = substitution_ext
215 config.substitutions.append((pattern, substitution))
220 if sys.platform not in ['win32'] or lit.getBashPath() != '':
221 config.available_features.add('shell')
224 # FIXME: This should be supplied by Makefile or autoconf.
225 if sys.platform in ['win32', 'cygwin']:
226 loadable_module = (config.enable_shared == 1)
228 loadable_module = True
231 config.available_features.add('loadable_module')
233 # llc knows whether he is compiled with -DNDEBUG.
236 llc_cmd = subprocess.Popen([os.path.join(llvm_tools_dir, 'llc'), '-version'],
237 stdout = subprocess.PIPE)
239 print "Could not find llc in " + llvm_tools_dir
242 if re.search(r'with assertions', llc_cmd.stdout.read()):
243 config.available_features.add('asserts')