Daniel Dunbar | 3bc6a98 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 1 | # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 2 | |
| 3 | # Configuration file for the 'lit' test runner. |
| 4 | |
Daniel Dunbar | 9e9d076 | 2013-08-30 19:52:12 +0000 | [diff] [blame] | 5 | import errno |
Dan Albert | b4ed5ca | 2014-08-04 18:44:48 +0000 | [diff] [blame] | 6 | import locale |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 7 | import os |
| 8 | import platform |
Daniel Dunbar | 9e9d076 | 2013-08-30 19:52:12 +0000 | [diff] [blame] | 9 | import re |
| 10 | import shlex |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 11 | import signal |
| 12 | import subprocess |
Daniel Dunbar | 9e9d076 | 2013-08-30 19:52:12 +0000 | [diff] [blame] | 13 | import sys |
| 14 | import tempfile |
Howard Hinnant | b4ebb0e | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 15 | import time |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 16 | |
Daniel Dunbar | bd7b48a | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 17 | import lit.Test |
| 18 | import lit.formats |
| 19 | import lit.util |
| 20 | |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 21 | class LibcxxTestFormat(lit.formats.FileBasedTest): |
| 22 | """ |
| 23 | Custom test format handler for use with the test format use by libc++. |
| 24 | |
| 25 | Tests fall into two categories: |
| 26 | FOO.pass.cpp - Executable test which should compile, run, and exit with |
| 27 | code 0. |
| 28 | FOO.fail.cpp - Negative test case which is expected to fail compilation. |
| 29 | """ |
| 30 | |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 31 | def __init__(self, cxx_under_test, use_verify_for_fail, |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 32 | cpp_flags, ld_flags, exec_env, |
| 33 | use_ccache=False): |
Daniel Dunbar | 7e0c57b | 2010-09-15 04:11:29 +0000 | [diff] [blame] | 34 | self.cxx_under_test = cxx_under_test |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 35 | self.use_verify_for_fail = use_verify_for_fail |
Daniel Dunbar | 611581b | 2010-09-15 04:31:58 +0000 | [diff] [blame] | 36 | self.cpp_flags = list(cpp_flags) |
| 37 | self.ld_flags = list(ld_flags) |
Daniel Dunbar | cccf255 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 38 | self.exec_env = dict(exec_env) |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 39 | self.use_ccache = use_ccache |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 40 | |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 41 | def execute(self, test, lit_config): |
Howard Hinnant | b4ebb0e | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 42 | while True: |
| 43 | try: |
| 44 | return self._execute(test, lit_config) |
| 45 | except OSError, oe: |
| 46 | if oe.errno != errno.ETXTBSY: |
| 47 | raise |
| 48 | time.sleep(0.1) |
| 49 | |
| 50 | def _execute(self, test, lit_config): |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 51 | # Extract test metadata from the test file. |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 52 | requires = [] |
Eric Fiselier | da98ce0 | 2014-08-18 06:43:06 +0000 | [diff] [blame] | 53 | unsupported = [] |
Justin Bogner | 464da3b | 2014-09-03 06:01:52 +0000 | [diff] [blame] | 54 | use_verify = False |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 55 | with open(test.getSourcePath()) as f: |
| 56 | for ln in f: |
| 57 | if 'XFAIL:' in ln: |
| 58 | items = ln[ln.index('XFAIL:') + 6:].split(',') |
Daniel Dunbar | 585b48d | 2013-08-21 23:06:32 +0000 | [diff] [blame] | 59 | test.xfails.extend([s.strip() for s in items]) |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 60 | elif 'REQUIRES:' in ln: |
| 61 | items = ln[ln.index('REQUIRES:') + 9:].split(',') |
| 62 | requires.extend([s.strip() for s in items]) |
Eric Fiselier | da98ce0 | 2014-08-18 06:43:06 +0000 | [diff] [blame] | 63 | elif 'UNSUPPORTED:' in ln: |
| 64 | items = ln[ln.index('UNSUPPORTED:') + 12:].split(',') |
| 65 | unsupported.extend([s.strip() for s in items]) |
Justin Bogner | 464da3b | 2014-09-03 06:01:52 +0000 | [diff] [blame] | 66 | elif 'USE_VERIFY' in ln and self.use_verify_for_fail: |
| 67 | use_verify = True |
Eric Fiselier | d3d01ea | 2014-07-31 22:56:52 +0000 | [diff] [blame] | 68 | elif not ln.strip().startswith("//") and ln.strip(): |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 69 | # Stop at the first non-empty line that is not a C++ |
| 70 | # comment. |
| 71 | break |
| 72 | |
| 73 | # Check that we have the required features. |
| 74 | # |
| 75 | # FIXME: For now, this is cribbed from lit.TestRunner, to avoid |
| 76 | # introducing a dependency there. What we more ideally would like to do |
Daniel Dunbar | 585b48d | 2013-08-21 23:06:32 +0000 | [diff] [blame] | 77 | # is lift the "requires" handling to be a core lit framework feature. |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 78 | missing_required_features = [f for f in requires |
| 79 | if f not in test.config.available_features] |
| 80 | if missing_required_features: |
| 81 | return (lit.Test.UNSUPPORTED, |
| 82 | "Test requires the following features: %s" % ( |
| 83 | ', '.join(missing_required_features),)) |
| 84 | |
Eric Fiselier | da98ce0 | 2014-08-18 06:43:06 +0000 | [diff] [blame] | 85 | unsupported_features = [f for f in unsupported |
| 86 | if f in test.config.available_features] |
| 87 | if unsupported_features: |
| 88 | return (lit.Test.UNSUPPORTED, |
| 89 | "Test is unsupported with the following features: %s" % ( |
| 90 | ', '.join(unsupported_features),)) |
| 91 | |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 92 | # Evaluate the test. |
Justin Bogner | 464da3b | 2014-09-03 06:01:52 +0000 | [diff] [blame] | 93 | return self._evaluate_test(test, use_verify, lit_config) |
Daniel Dunbar | 81d1ef7 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 94 | |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 95 | def _make_report(self, cmd, out, err, rc): |
| 96 | report = "Command: %s\n" % cmd |
| 97 | report += "Exit Code: %d\n" % rc |
| 98 | if out: |
| 99 | report += "Standard Output:\n--\n%s--\n" % out |
| 100 | if err: |
| 101 | report += "Standard Error:\n--\n%s--\n" % err |
| 102 | report += '\n' |
| 103 | return cmd, report, rc |
| 104 | |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 105 | def _compile(self, output_path, source_path, use_verify=False): |
| 106 | cmd = [self.cxx_under_test, '-c', '-o', output_path, source_path] |
| 107 | cmd += self.cpp_flags |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 108 | if use_verify: |
| 109 | cmd += ['-Xclang', '-verify'] |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 110 | if self.use_ccache: |
| 111 | cmd = ['ccache'] + cmd |
Eric Fiselier | bd00008 | 2014-11-25 03:03:32 +0000 | [diff] [blame] | 112 | out, err, rc = lit.util.executeCommand(cmd) |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 113 | return cmd, out, err, rc |
| 114 | |
| 115 | def _link(self, exec_path, object_path): |
| 116 | cmd = [self.cxx_under_test, '-o', exec_path, object_path] |
| 117 | cmd += self.cpp_flags + self.ld_flags |
| 118 | out, err, rc = lit.util.executeCommand(cmd) |
| 119 | return cmd, out, err, rc |
| 120 | |
| 121 | def _compile_and_link(self, exec_path, source_path): |
| 122 | object_file = tempfile.NamedTemporaryFile(suffix=".o", delete=False) |
| 123 | object_path = object_file.name |
| 124 | object_file.close() |
| 125 | try: |
| 126 | cmd, out, err, rc = self._compile(object_path, source_path) |
| 127 | if rc != 0: |
| 128 | return cmd, out, err, rc |
| 129 | return self._link(exec_path, object_path) |
| 130 | finally: |
| 131 | try: |
| 132 | os.remove(object_path) |
| 133 | except: |
| 134 | pass |
| 135 | |
| 136 | def _build(self, exec_path, source_path, compile_only=False, |
| 137 | use_verify=False): |
| 138 | if compile_only: |
| 139 | cmd, out, err, rc = self._compile(exec_path, source_path, use_verify) |
| 140 | else: |
| 141 | assert not use_verify |
| 142 | cmd, out, err, rc = self._compile_and_link(exec_path, source_path) |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 143 | return self._make_report(cmd, out, err, rc) |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 144 | |
| 145 | def _clean(self, exec_path): |
| 146 | os.remove(exec_path) |
| 147 | |
| 148 | def _run(self, exec_path, lit_config, in_dir=None): |
| 149 | cmd = [] |
| 150 | if self.exec_env: |
| 151 | cmd.append('env') |
| 152 | cmd.extend('%s=%s' % (name, value) |
| 153 | for name,value in self.exec_env.items()) |
| 154 | cmd.append(exec_path) |
| 155 | if lit_config.useValgrind: |
| 156 | cmd = lit_config.valgrindArgs + cmd |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 157 | out, err, rc = lit.util.executeCommand(cmd, cwd=in_dir) |
| 158 | return self._make_report(cmd, out, err, rc) |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 159 | |
Justin Bogner | 464da3b | 2014-09-03 06:01:52 +0000 | [diff] [blame] | 160 | def _evaluate_test(self, test, use_verify, lit_config): |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 161 | name = test.path_in_suite[-1] |
| 162 | source_path = test.getSourcePath() |
Howard Hinnant | b4ebb0e | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 163 | source_dir = os.path.dirname(source_path) |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 164 | |
| 165 | # Check what kind of test this is. |
| 166 | assert name.endswith('.pass.cpp') or name.endswith('.fail.cpp') |
| 167 | expected_compile_fail = name.endswith('.fail.cpp') |
| 168 | |
| 169 | # If this is a compile (failure) test, build it and check for failure. |
| 170 | if expected_compile_fail: |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 171 | cmd, report, rc = self._build('/dev/null', source_path, |
| 172 | compile_only=True, |
| 173 | use_verify=use_verify) |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 174 | expected_rc = 0 if use_verify else 1 |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 175 | if rc == expected_rc: |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 176 | return lit.Test.PASS, "" |
| 177 | else: |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 178 | return lit.Test.FAIL, report + 'Expected compilation to fail!\n' |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 179 | else: |
| 180 | exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False) |
| 181 | exec_path = exec_file.name |
| 182 | exec_file.close() |
| 183 | |
| 184 | try: |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 185 | cmd, report, rc = self._build(exec_path, source_path) |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 186 | compile_cmd = cmd |
| 187 | if rc != 0: |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 188 | report += "Compilation failed unexpectedly!" |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 189 | return lit.Test.FAIL, report |
| 190 | |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 191 | cmd, report, rc = self._run(exec_path, lit_config, |
| 192 | source_dir) |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 193 | if rc != 0: |
Eric Fiselier | cd83c787 | 2014-12-07 04:28:50 +0000 | [diff] [blame] | 194 | report = "Compiled With: %s\n%s" % (compile_cmd, report) |
| 195 | report += "Compiled test failed unexpectedly!" |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 196 | return lit.Test.FAIL, report |
| 197 | finally: |
| 198 | try: |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 199 | # Note that cleanup of exec_file happens in `_clean()`. If |
| 200 | # you override this, cleanup is your reponsibility. |
| 201 | self._clean(exec_path) |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 202 | except: |
| 203 | pass |
| 204 | return lit.Test.PASS, "" |
| 205 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 206 | |
| 207 | class Configuration(object): |
| 208 | def __init__(self, lit_config, config): |
| 209 | self.lit_config = lit_config |
| 210 | self.config = config |
| 211 | self.cxx = None |
| 212 | self.src_root = None |
| 213 | self.obj_root = None |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame^] | 214 | self.library_root = None |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 215 | self.env = {} |
Eric Fiselier | e6e69df | 2014-11-24 23:46:42 +0000 | [diff] [blame] | 216 | self.compile_flags = ['-nostdinc++'] |
| 217 | self.link_flags = ['-nodefaultlibs'] |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 218 | self.use_system_lib = False |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 219 | self.use_clang_verify = False |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 220 | self.use_ccache = False |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 221 | |
| 222 | if platform.system() not in ('Darwin', 'FreeBSD', 'Linux'): |
| 223 | self.lit_config.fatal("unrecognized system") |
| 224 | |
| 225 | def get_lit_conf(self, name, default=None): |
| 226 | val = self.lit_config.params.get(name, None) |
| 227 | if val is None: |
| 228 | val = getattr(self.config, name, None) |
| 229 | if val is None: |
| 230 | val = default |
| 231 | return val |
| 232 | |
Eric Fiselier | 2764d04 | 2014-12-07 08:52:19 +0000 | [diff] [blame] | 233 | def get_lit_bool(self, name, default=None): |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 234 | conf = self.get_lit_conf(name) |
| 235 | if conf is None: |
Eric Fiselier | 2764d04 | 2014-12-07 08:52:19 +0000 | [diff] [blame] | 236 | return default |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 237 | if conf.lower() in ('1', 'true'): |
| 238 | return True |
| 239 | if conf.lower() in ('', '0', 'false'): |
| 240 | return False |
| 241 | self.lit_config.fatal( |
| 242 | "parameter '{}' should be true or false".format(name)) |
| 243 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 244 | def configure(self): |
| 245 | self.configure_cxx() |
Eric Fiselier | c934ca7 | 2014-12-06 21:13:15 +0000 | [diff] [blame] | 246 | self.probe_cxx() |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 247 | self.configure_triple() |
| 248 | self.configure_src_root() |
| 249 | self.configure_obj_root() |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame^] | 250 | self.configure_library_root() |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 251 | self.configure_use_system_lib() |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 252 | self.configure_use_clang_verify() |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 253 | self.configure_ccache() |
Eric Fiselier | 2050be2 | 2014-12-07 00:34:23 +0000 | [diff] [blame] | 254 | self.configure_env() |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 255 | self.configure_std_flag() |
| 256 | self.configure_compile_flags() |
| 257 | self.configure_link_flags() |
| 258 | self.configure_sanitizer() |
| 259 | self.configure_features() |
Eric Fiselier | e6e69df | 2014-11-24 23:46:42 +0000 | [diff] [blame] | 260 | # Print the final compile and link flags. |
| 261 | self.lit_config.note('Using compile flags: %s' % self.compile_flags) |
| 262 | self.lit_config.note('Using link flags: %s' % self.link_flags) |
| 263 | # Print as list to prevent "set([...])" from being printed. |
| 264 | self.lit_config.note('Using available_features: %s' % |
| 265 | list(self.config.available_features)) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 266 | |
| 267 | def get_test_format(self): |
| 268 | return LibcxxTestFormat( |
| 269 | self.cxx, |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 270 | self.use_clang_verify, |
Eric Fiselier | e6e69df | 2014-11-24 23:46:42 +0000 | [diff] [blame] | 271 | cpp_flags=self.compile_flags, |
| 272 | ld_flags=self.link_flags, |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 273 | exec_env=self.env, |
| 274 | use_ccache=self.use_ccache) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 275 | |
| 276 | def configure_cxx(self): |
| 277 | # Gather various compiler parameters. |
| 278 | self.cxx = self.get_lit_conf('cxx_under_test') |
| 279 | |
| 280 | # If no specific cxx_under_test was given, attempt to infer it as |
| 281 | # clang++. |
| 282 | if self.cxx is None: |
| 283 | clangxx = lit.util.which('clang++', |
| 284 | self.config.environment['PATH']) |
| 285 | if clangxx: |
| 286 | self.cxx = clangxx |
| 287 | self.lit_config.note( |
| 288 | "inferred cxx_under_test as: %r" % self.cxx) |
| 289 | if not self.cxx: |
| 290 | self.lit_config.fatal('must specify user parameter cxx_under_test ' |
| 291 | '(e.g., --param=cxx_under_test=clang++)') |
| 292 | |
Eric Fiselier | c934ca7 | 2014-12-06 21:13:15 +0000 | [diff] [blame] | 293 | def probe_cxx(self): |
| 294 | # Dump all of the predefined macros |
| 295 | dump_macro_cmd = [self.cxx, '-dM', '-E', '-x', 'c++', '/dev/null'] |
| 296 | out, err, rc = lit.util.executeCommand(dump_macro_cmd) |
| 297 | if rc != 0: |
| 298 | self.lit_config.warning('Failed to dump macros for compiler: %s' % |
| 299 | self.cxx) |
| 300 | return |
| 301 | # Create a dict containing all the predefined macros. |
| 302 | macros = {} |
| 303 | lines = [l.strip() for l in out.split('\n') if l.strip()] |
| 304 | for l in lines: |
| 305 | assert l.startswith('#define ') |
| 306 | l = l[len('#define '):] |
| 307 | macro, _, value = l.partition(' ') |
| 308 | macros[macro] = value |
| 309 | # Add compiler information to available features. |
| 310 | compiler_name = None |
| 311 | major_ver = minor_ver = None |
| 312 | if '__clang__' in macros.keys(): |
| 313 | compiler_name = 'clang' |
| 314 | # Treat apple's llvm fork differently. |
Eric Fiselier | 74e7af0 | 2014-12-06 22:49:38 +0000 | [diff] [blame] | 315 | if '__apple_build_version__' in macros.keys(): |
Eric Fiselier | c934ca7 | 2014-12-06 21:13:15 +0000 | [diff] [blame] | 316 | compiler_name = 'apple-clang' |
| 317 | major_ver = macros['__clang_major__'] |
| 318 | minor_ver = macros['__clang_minor__'] |
| 319 | elif '__GNUC__' in macros.keys(): |
| 320 | compiler_name = 'gcc' |
| 321 | major_ver = macros['__GNUC__'] |
| 322 | minor_ver = macros['__GNUC_MINOR__'] |
| 323 | else: |
| 324 | self.lit_config.warning('Failed to detect compiler for cxx: %s' % |
| 325 | self.cxx) |
| 326 | if compiler_name is not None: |
| 327 | self.config.available_features.add(compiler_name) |
| 328 | self.config.available_features.add('%s-%s.%s' % ( |
| 329 | compiler_name, major_ver, minor_ver)) |
| 330 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 331 | def configure_src_root(self): |
| 332 | self.src_root = self.get_lit_conf( |
| 333 | 'libcxx_src_root', os.path.dirname(self.config.test_source_root)) |
| 334 | |
| 335 | def configure_obj_root(self): |
| 336 | self.obj_root = self.get_lit_conf('libcxx_obj_root', self.src_root) |
| 337 | |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame^] | 338 | def configure_library_root(self): |
| 339 | self.library_root = self.get_lit_conf('libcxx_library_root', self.obj_root) |
| 340 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 341 | def configure_use_system_lib(self): |
| 342 | # This test suite supports testing against either the system library or |
| 343 | # the locally built one; the former mode is useful for testing ABI |
| 344 | # compatibility between the current headers and a shipping dynamic |
| 345 | # library. |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 346 | self.use_system_lib = self.get_lit_bool('use_system_lib') |
| 347 | if self.use_system_lib is None: |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 348 | # Default to testing against the locally built libc++ library. |
| 349 | self.use_system_lib = False |
| 350 | self.lit_config.note( |
| 351 | "inferred use_system_lib as: %r" % self.use_system_lib) |
| 352 | |
Justin Bogner | 837cfe5 | 2014-09-03 04:32:08 +0000 | [diff] [blame] | 353 | def configure_use_clang_verify(self): |
| 354 | '''If set, run clang with -verify on failing tests.''' |
| 355 | self.use_clang_verify = self.get_lit_bool('use_clang_verify') |
| 356 | if self.use_clang_verify is None: |
| 357 | # TODO: Default this to True when using clang. |
| 358 | self.use_clang_verify = False |
| 359 | self.lit_config.note( |
| 360 | "inferred use_clang_verify as: %r" % self.use_clang_verify) |
| 361 | |
Eric Fiselier | b8e7680 | 2014-12-19 19:27:32 +0000 | [diff] [blame] | 362 | def configure_ccache(self): |
| 363 | self.use_ccache = self.get_lit_bool('use_ccache', False) |
| 364 | if self.use_ccache: |
| 365 | self.lit_config.note('enabling ccache') |
| 366 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 367 | def configure_features(self): |
Jonathan Roelofs | d634a2c | 2014-09-05 19:03:46 +0000 | [diff] [blame] | 368 | additional_features = self.get_lit_conf('additional_features') |
| 369 | if additional_features: |
| 370 | for f in additional_features.split(','): |
| 371 | self.config.available_features.add(f.strip()) |
Jonathan Roelofs | 217bdc1 | 2014-09-05 17:21:57 +0000 | [diff] [blame] | 372 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 373 | # Figure out which of the required locales we support |
| 374 | locales = { |
| 375 | 'Darwin': { |
| 376 | 'en_US.UTF-8': 'en_US.UTF-8', |
| 377 | 'cs_CZ.ISO8859-2': 'cs_CZ.ISO8859-2', |
| 378 | 'fr_FR.UTF-8': 'fr_FR.UTF-8', |
| 379 | 'fr_CA.ISO8859-1': 'cs_CZ.ISO8859-1', |
| 380 | 'ru_RU.UTF-8': 'ru_RU.UTF-8', |
| 381 | 'zh_CN.UTF-8': 'zh_CN.UTF-8', |
| 382 | }, |
| 383 | 'FreeBSD': { |
| 384 | 'en_US.UTF-8': 'en_US.UTF-8', |
| 385 | 'cs_CZ.ISO8859-2': 'cs_CZ.ISO8859-2', |
| 386 | 'fr_FR.UTF-8': 'fr_FR.UTF-8', |
| 387 | 'fr_CA.ISO8859-1': 'fr_CA.ISO8859-1', |
| 388 | 'ru_RU.UTF-8': 'ru_RU.UTF-8', |
| 389 | 'zh_CN.UTF-8': 'zh_CN.UTF-8', |
| 390 | }, |
| 391 | 'Linux': { |
| 392 | 'en_US.UTF-8': 'en_US.UTF-8', |
| 393 | 'cs_CZ.ISO8859-2': 'cs_CZ.ISO-8859-2', |
| 394 | 'fr_FR.UTF-8': 'fr_FR.UTF-8', |
| 395 | 'fr_CA.ISO8859-1': 'fr_CA.ISO-8859-1', |
| 396 | 'ru_RU.UTF-8': 'ru_RU.UTF-8', |
| 397 | 'zh_CN.UTF-8': 'zh_CN.UTF-8', |
| 398 | }, |
| 399 | 'Windows': { |
| 400 | 'en_US.UTF-8': 'English_United States.1252', |
| 401 | 'cs_CZ.ISO8859-2': 'Czech_Czech Republic.1250', |
| 402 | 'fr_FR.UTF-8': 'French_France.1252', |
| 403 | 'fr_CA.ISO8859-1': 'French_Canada.1252', |
| 404 | 'ru_RU.UTF-8': 'Russian_Russia.1251', |
| 405 | 'zh_CN.UTF-8': 'Chinese_China.936', |
| 406 | }, |
| 407 | } |
| 408 | |
| 409 | default_locale = locale.setlocale(locale.LC_ALL) |
| 410 | for feature, loc in locales[platform.system()].items(): |
| 411 | try: |
| 412 | locale.setlocale(locale.LC_ALL, loc) |
Eric Fiselier | ae6e58c | 2014-08-23 04:02:21 +0000 | [diff] [blame] | 413 | self.config.available_features.add('locale.{0}'.format(feature)) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 414 | except: |
Eric Fiselier | ae6e58c | 2014-08-23 04:02:21 +0000 | [diff] [blame] | 415 | self.lit_config.warning('The locale {0} is not supported by ' |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 416 | 'your platform. Some tests will be ' |
| 417 | 'unsupported.'.format(loc)) |
| 418 | locale.setlocale(locale.LC_ALL, default_locale) |
| 419 | |
| 420 | # Write an "available feature" that combines the triple when |
| 421 | # use_system_lib is enabled. This is so that we can easily write XFAIL |
| 422 | # markers for tests that are known to fail with versions of libc++ as |
| 423 | # were shipped with a particular triple. |
| 424 | if self.use_system_lib: |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 425 | self.config.available_features.add( |
Eric Fiselier | 2b0f03a | 2014-10-27 22:14:25 +0000 | [diff] [blame] | 426 | 'with_system_lib=%s' % self.config.target_triple) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 427 | |
Eric Fiselier | aeff14f | 2014-11-21 08:02:38 +0000 | [diff] [blame] | 428 | # Some linux distributions have different locale data than others. |
| 429 | # Insert the distributions name and name-version into the available |
| 430 | # features to allow tests to XFAIL on them. |
| 431 | if sys.platform.startswith('linux'): |
Eric Fiselier | 1567ac8 | 2014-11-21 08:54:35 +0000 | [diff] [blame] | 432 | name, ver, _ = platform.linux_distribution() |
| 433 | name = name.lower().strip() |
| 434 | ver = ver.lower().strip() |
Eric Fiselier | bd8adae | 2014-12-19 21:42:17 +0000 | [diff] [blame] | 435 | if name: |
| 436 | self.config.available_features.add(name) |
| 437 | if name and ver: |
| 438 | self.config.available_features.add('%s-%s' % (name, ver)) |
Eric Fiselier | aeff14f | 2014-11-21 08:02:38 +0000 | [diff] [blame] | 439 | |
Jonathan Roelofs | d9144e8 | 2014-12-11 18:35:36 +0000 | [diff] [blame] | 440 | # Simulator testing can take a really long time for some of these tests |
| 441 | # so add a feature check so we can REQUIRES: long_tests in them |
| 442 | self.long_tests = self.get_lit_bool('long_tests') |
| 443 | if self.long_tests is None: |
| 444 | # Default to running long tests. |
| 445 | self.long_tests = True |
| 446 | self.lit_config.note( |
| 447 | "inferred long_tests as: %r" % self.long_tests) |
| 448 | |
| 449 | if self.long_tests: |
| 450 | self.config.available_features.add('long_tests') |
| 451 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 452 | def configure_compile_flags(self): |
| 453 | # Configure extra compiler flags. |
| 454 | self.compile_flags += ['-I' + self.src_root + '/include', |
| 455 | '-I' + self.src_root + '/test/support'] |
Eric Fiselier | 5636e63 | 2014-10-23 22:57:56 +0000 | [diff] [blame] | 456 | if sys.platform.startswith('linux'): |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 457 | self.compile_flags += ['-D__STDC_FORMAT_MACROS', |
| 458 | '-D__STDC_LIMIT_MACROS', |
| 459 | '-D__STDC_CONSTANT_MACROS'] |
Eric Fiselier | 01f6a14 | 2014-12-12 02:36:23 +0000 | [diff] [blame] | 460 | enable_exceptions = self.get_lit_bool('enable_exceptions', True) |
| 461 | if enable_exceptions: |
| 462 | self.config.available_features.add('exceptions') |
| 463 | else: |
| 464 | self.compile_flags += ['-fno-exceptions'] |
| 465 | enable_rtti = self.get_lit_bool('enable_rtti', True) |
| 466 | if enable_rtti: |
| 467 | self.config.available_features.add('rtti') |
| 468 | else: |
| 469 | self.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI'] |
Eric Fiselier | ae9fec0 | 2014-12-12 03:12:18 +0000 | [diff] [blame] | 470 | enable_32bit = self.get_lit_bool('enable_32bit', False) |
| 471 | if enable_32bit: |
| 472 | self.compile_flags += ['-m32'] |
Eric Fiselier | 7330ed3 | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 473 | # Configure threading features. |
Eric Fiselier | 2764d04 | 2014-12-07 08:52:19 +0000 | [diff] [blame] | 474 | enable_threads = self.get_lit_bool('enable_threads', True) |
| 475 | enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock', True) |
Eric Fiselier | 7330ed3 | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 476 | if not enable_threads: |
| 477 | self.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS'] |
| 478 | self.config.available_features.add('libcpp-has-no-threads') |
| 479 | if not enable_monotonic_clock: |
| 480 | self.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'] |
| 481 | self.config.available_features.add('libcpp-has-no-monotonic-clock') |
| 482 | elif not enable_monotonic_clock: |
| 483 | self.lit_config.fatal('enable_monotonic_clock cannot be false when' |
| 484 | ' enable_threads is true.') |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 485 | |
Eric Fiselier | 01f6a14 | 2014-12-12 02:36:23 +0000 | [diff] [blame] | 486 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 487 | def configure_link_flags(self): |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 488 | # Configure library search paths |
Eric Fiselier | cb7e32c | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 489 | abi_library_path = self.get_lit_conf('abi_library_path', '') |
Eric Fiselier | cb7e32c | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 490 | if not self.use_system_lib: |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame^] | 491 | self.link_flags += ['-L' + self.library_root] |
| 492 | self.link_flags += ['-Wl,-rpath,' + self.library_root] |
Eric Fiselier | cb7e32c | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 493 | if abi_library_path: |
| 494 | self.link_flags += ['-L' + abi_library_path, |
Eric Fiselier | 83313c7 | 2014-12-06 22:08:51 +0000 | [diff] [blame] | 495 | '-Wl,-rpath,' + abi_library_path] |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 496 | # Configure libraries |
| 497 | self.link_flags += ['-lc++'] |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 498 | link_flags_str = self.get_lit_conf('link_flags') |
| 499 | if link_flags_str is None: |
| 500 | cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') |
| 501 | if cxx_abi == 'libstdc++': |
| 502 | self.link_flags += ['-lstdc++'] |
| 503 | elif cxx_abi == 'libsupc++': |
| 504 | self.link_flags += ['-lsupc++'] |
| 505 | elif cxx_abi == 'libcxxabi': |
| 506 | self.link_flags += ['-lc++abi'] |
| 507 | elif cxx_abi == 'libcxxrt': |
| 508 | self.link_flags += ['-lcxxrt'] |
| 509 | elif cxx_abi == 'none': |
| 510 | pass |
| 511 | else: |
| 512 | self.lit_config.fatal( |
| 513 | 'C++ ABI setting %s unsupported for tests' % cxx_abi) |
| 514 | |
| 515 | if sys.platform == 'darwin': |
| 516 | self.link_flags += ['-lSystem'] |
Eric Fiselier | 5636e63 | 2014-10-23 22:57:56 +0000 | [diff] [blame] | 517 | elif sys.platform.startswith('linux'): |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 518 | self.link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread', |
| 519 | '-lrt', '-lgcc_s'] |
| 520 | elif sys.platform.startswith('freebsd'): |
| 521 | self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s'] |
| 522 | else: |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 523 | self.lit_config.fatal("unrecognized system: %r" % sys.platform) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 524 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 525 | if link_flags_str: |
| 526 | self.link_flags += shlex.split(link_flags_str) |
| 527 | |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 528 | |
| 529 | def configure_std_flag(self): |
| 530 | # Try and get the std version from the command line. Fall back to |
| 531 | # default given in lit.site.cfg is not present. If default is not |
| 532 | # present then force c++11. |
| 533 | std = self.get_lit_conf('std') |
| 534 | if std is None: |
| 535 | std = 'c++11' |
| 536 | self.lit_config.note('using default std: \'-std=c++11\'') |
Eric Fiselier | ae6e58c | 2014-08-23 04:02:21 +0000 | [diff] [blame] | 537 | self.compile_flags += ['-std={0}'.format(std)] |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 538 | self.config.available_features.add(std) |
| 539 | |
| 540 | def configure_sanitizer(self): |
| 541 | san = self.get_lit_conf('llvm_use_sanitizer', '').strip() |
| 542 | if san: |
Eric Fiselier | 44678f4 | 2014-11-14 02:47:08 +0000 | [diff] [blame] | 543 | # Search for llvm-symbolizer along the compiler path first |
| 544 | # and then along the PATH env variable. |
| 545 | symbolizer_search_paths = os.environ.get('PATH', '') |
| 546 | cxx_path = lit.util.which(self.cxx) |
| 547 | if cxx_path is not None: |
| 548 | symbolizer_search_paths = os.path.dirname(cxx_path) + \ |
| 549 | os.pathsep + symbolizer_search_paths |
| 550 | llvm_symbolizer = lit.util.which('llvm-symbolizer', |
| 551 | symbolizer_search_paths) |
| 552 | # Setup the sanitizer compile flags |
Eric Fiselier | 1383dc5 | 2014-11-14 22:18:03 +0000 | [diff] [blame] | 553 | self.compile_flags += ['-g', '-fno-omit-frame-pointer'] |
Eric Fiselier | 5636e63 | 2014-10-23 22:57:56 +0000 | [diff] [blame] | 554 | if sys.platform.startswith('linux'): |
Eric Fiselier | 3de9baa | 2014-10-23 02:54:15 +0000 | [diff] [blame] | 555 | self.link_flags += ['-ldl'] |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 556 | if san == 'Address': |
| 557 | self.compile_flags += ['-fsanitize=address'] |
Eric Fiselier | 44678f4 | 2014-11-14 02:47:08 +0000 | [diff] [blame] | 558 | if llvm_symbolizer is not None: |
| 559 | self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 560 | self.config.available_features.add('asan') |
| 561 | elif san == 'Memory' or san == 'MemoryWithOrigins': |
| 562 | self.compile_flags += ['-fsanitize=memory'] |
| 563 | if san == 'MemoryWithOrigins': |
| 564 | self.compile_flags += ['-fsanitize-memory-track-origins'] |
Eric Fiselier | 44678f4 | 2014-11-14 02:47:08 +0000 | [diff] [blame] | 565 | if llvm_symbolizer is not None: |
| 566 | self.env['MSAN_SYMBOLIZER_PATH'] = llvm_symbolizer |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 567 | self.config.available_features.add('msan') |
Eric Fiselier | 66d529f | 2014-10-16 23:21:59 +0000 | [diff] [blame] | 568 | elif san == 'Undefined': |
| 569 | self.compile_flags += ['-fsanitize=undefined', |
| 570 | '-fno-sanitize=vptr,function', |
Eric Fiselier | 05123a8 | 2014-11-14 02:07:52 +0000 | [diff] [blame] | 571 | '-fno-sanitize-recover', '-O3'] |
Eric Fiselier | 66d529f | 2014-10-16 23:21:59 +0000 | [diff] [blame] | 572 | self.config.available_features.add('ubsan') |
Eric Fiselier | af2976d | 2014-11-18 21:26:45 +0000 | [diff] [blame] | 573 | elif san == 'Thread': |
| 574 | self.compile_flags += ['-fsanitize=thread'] |
| 575 | self.config.available_features.add('tsan') |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 576 | else: |
| 577 | self.lit_config.fatal('unsupported value for ' |
Eric Fiselier | ae6e58c | 2014-08-23 04:02:21 +0000 | [diff] [blame] | 578 | 'libcxx_use_san: {0}'.format(san)) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 579 | |
| 580 | def configure_triple(self): |
| 581 | # Get or infer the target triple. |
| 582 | self.config.target_triple = self.get_lit_conf('target_triple') |
| 583 | # If no target triple was given, try to infer it from the compiler |
| 584 | # under test. |
| 585 | if not self.config.target_triple: |
Eric Fiselier | 2b0f03a | 2014-10-27 22:14:25 +0000 | [diff] [blame] | 586 | target_triple = lit.util.capture( |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 587 | [self.cxx, '-dumpmachine']).strip() |
Eric Fiselier | 2b0f03a | 2014-10-27 22:14:25 +0000 | [diff] [blame] | 588 | # Drop sub-major version components from the triple, because the |
| 589 | # current XFAIL handling expects exact matches for feature checks. |
Eric Fiselier | a01a623 | 2014-10-28 18:03:38 +0000 | [diff] [blame] | 590 | # Example: x86_64-apple-darwin14.0.0 -> x86_64-apple-darwin14 |
Eric Fiselier | 2b0f03a | 2014-10-27 22:14:25 +0000 | [diff] [blame] | 591 | # The 5th group handles triples greater than 3 parts |
| 592 | # (ex x86_64-pc-linux-gnu). |
| 593 | target_triple = re.sub(r'([^-]+)-([^-]+)-([^.]+)([^-]*)(.*)', |
| 594 | r'\1-\2-\3\5', target_triple) |
| 595 | # linux-gnu is needed in the triple to properly identify linuxes |
| 596 | # that use GLIBC. Handle redhat and opensuse triples as special |
| 597 | # cases and append the missing `-gnu` portion. |
| 598 | if target_triple.endswith('redhat-linux') or \ |
| 599 | target_triple.endswith('suse-linux'): |
| 600 | target_triple += '-gnu' |
| 601 | self.config.target_triple = target_triple |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 602 | self.lit_config.note( |
| 603 | "inferred target_triple as: %r" % self.config.target_triple) |
| 604 | |
Eric Fiselier | 2050be2 | 2014-12-07 00:34:23 +0000 | [diff] [blame] | 605 | def configure_env(self): |
| 606 | if sys.platform == 'darwin' and not self.use_system_lib: |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame^] | 607 | self.env['DYLD_LIBRARY_PATH'] = self.library_root |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 608 | |
Daniel Dunbar | f5eadcd | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 609 | # name: The name of this test suite. |
| 610 | config.name = 'libc++' |
| 611 | |
| 612 | # suffixes: A list of file extensions to treat as test files. |
| 613 | config.suffixes = ['.cpp'] |
| 614 | |
| 615 | # test_source_root: The root path where tests are located. |
| 616 | config.test_source_root = os.path.dirname(__file__) |
| 617 | |
Eric Fiselier | 4778eed | 2014-12-20 03:16:55 +0000 | [diff] [blame^] | 618 | # Infer the test_exec_root from the libcxx_object root. |
| 619 | libcxx_obj_root = getattr(config, 'libcxx_obj_root', None) |
| 620 | if libcxx_obj_root is not None: |
| 621 | config.test_exec_root = os.path.join(libcxx_obj_root, 'test') |
| 622 | |
| 623 | # Check that the test exec root is known. |
| 624 | if config.test_exec_root is None: |
| 625 | # Otherwise, we haven't loaded the site specific configuration (the user is |
| 626 | # probably trying to run on a test file directly, and either the site |
| 627 | # configuration hasn't been created by the build system, or we are in an |
| 628 | # out-of-tree build situation). |
| 629 | site_cfg = lit_config.params.get('libcxx_site_config', |
| 630 | os.environ.get('LIBCXX_SITE_CONFIG')) |
| 631 | if not site_cfg: |
| 632 | lit_config.warning('No site specific configuration file found!' |
| 633 | ' Running the tests in the default configuration.') |
| 634 | # TODO: Set test_exec_root to a temporary directory where output files |
| 635 | # can be placed. This is needed for ShTest. |
| 636 | elif not os.path.isfile(site_cfg): |
| 637 | lit_config.fatal( |
| 638 | "Specified site configuration file does not exist: '%s'" % |
| 639 | site_cfg) |
| 640 | else: |
| 641 | lit_config.note('using site specific configuration at %s' % site_cfg) |
| 642 | lit_config.load_config(config, site_cfg) |
| 643 | raise SystemExit() |
| 644 | |
| 645 | |
Dan Albert | 877409a | 2014-11-24 22:24:06 +0000 | [diff] [blame] | 646 | cfg_variant = getattr(config, 'configuration_variant', '') |
| 647 | if cfg_variant: |
| 648 | print 'Using configuration variant: %s' % cfg_variant |
| 649 | |
| 650 | # Construct an object of the type named `<VARIANT>Configuration`. |
| 651 | configuration = globals()['%sConfiguration' % cfg_variant](lit_config, config) |
Dan Albert | 2c26213 | 2014-08-21 17:30:44 +0000 | [diff] [blame] | 652 | configuration.configure() |
| 653 | config.test_format = configuration.get_test_format() |