Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 1 | # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 2 | |
| 3 | # Configuration file for the 'lit' test runner. |
| 4 | |
| 5 | import os |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 6 | import sys |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 7 | import platform |
| 8 | import tempfile |
| 9 | import signal |
| 10 | import subprocess |
Howard Hinnant | 3778f27 | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 11 | import errno |
| 12 | import time |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 13 | import shlex |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 14 | |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 15 | import lit.Test |
| 16 | import lit.formats |
| 17 | import lit.util |
| 18 | |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 19 | class LibcxxTestFormat(lit.formats.FileBasedTest): |
| 20 | """ |
| 21 | Custom test format handler for use with the test format use by libc++. |
| 22 | |
| 23 | Tests fall into two categories: |
| 24 | FOO.pass.cpp - Executable test which should compile, run, and exit with |
| 25 | code 0. |
| 26 | FOO.fail.cpp - Negative test case which is expected to fail compilation. |
| 27 | """ |
| 28 | |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 29 | def __init__(self, cxx_under_test, cpp_flags, ld_flags, exec_env): |
Daniel Dunbar | bc9a848 | 2010-09-15 04:11:29 +0000 | [diff] [blame] | 30 | self.cxx_under_test = cxx_under_test |
Daniel Dunbar | 5f09d9e0 | 2010-09-15 04:31:58 +0000 | [diff] [blame] | 31 | self.cpp_flags = list(cpp_flags) |
| 32 | self.ld_flags = list(ld_flags) |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 33 | self.exec_env = dict(exec_env) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 34 | |
Howard Hinnant | 3778f27 | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 35 | def execute_command(self, command, in_dir=None): |
| 36 | kwargs = { |
| 37 | 'stdin' :subprocess.PIPE, |
| 38 | 'stdout':subprocess.PIPE, |
| 39 | 'stderr':subprocess.PIPE, |
| 40 | } |
| 41 | if in_dir: |
| 42 | kwargs['cwd'] = in_dir |
| 43 | p = subprocess.Popen(command, **kwargs) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 44 | out,err = p.communicate() |
| 45 | exitCode = p.wait() |
| 46 | |
| 47 | # Detect Ctrl-C in subprocess. |
| 48 | if exitCode == -signal.SIGINT: |
| 49 | raise KeyboardInterrupt |
| 50 | |
| 51 | return out, err, exitCode |
| 52 | |
| 53 | def execute(self, test, lit_config): |
Howard Hinnant | 3778f27 | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 54 | while True: |
| 55 | try: |
| 56 | return self._execute(test, lit_config) |
| 57 | except OSError, oe: |
| 58 | if oe.errno != errno.ETXTBSY: |
| 59 | raise |
| 60 | time.sleep(0.1) |
| 61 | |
| 62 | def _execute(self, test, lit_config): |
Daniel Dunbar | f51f031 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 63 | # Extract test metadata from the test file. |
Daniel Dunbar | f51f031 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 64 | requires = [] |
| 65 | with open(test.getSourcePath()) as f: |
| 66 | for ln in f: |
| 67 | if 'XFAIL:' in ln: |
| 68 | items = ln[ln.index('XFAIL:') + 6:].split(',') |
Daniel Dunbar | 019c590 | 2013-08-21 23:06:32 +0000 | [diff] [blame^] | 69 | test.xfails.extend([s.strip() for s in items]) |
Daniel Dunbar | f51f031 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 70 | elif 'REQUIRES:' in ln: |
| 71 | items = ln[ln.index('REQUIRES:') + 9:].split(',') |
| 72 | requires.extend([s.strip() for s in items]) |
| 73 | elif not ln.startswith("//") and ln.strip(): |
| 74 | # Stop at the first non-empty line that is not a C++ |
| 75 | # comment. |
| 76 | break |
| 77 | |
| 78 | # Check that we have the required features. |
| 79 | # |
| 80 | # FIXME: For now, this is cribbed from lit.TestRunner, to avoid |
| 81 | # introducing a dependency there. What we more ideally would like to do |
Daniel Dunbar | 019c590 | 2013-08-21 23:06:32 +0000 | [diff] [blame^] | 82 | # is lift the "requires" handling to be a core lit framework feature. |
Daniel Dunbar | f51f031 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 83 | missing_required_features = [f for f in requires |
| 84 | if f not in test.config.available_features] |
| 85 | if missing_required_features: |
| 86 | return (lit.Test.UNSUPPORTED, |
| 87 | "Test requires the following features: %s" % ( |
| 88 | ', '.join(missing_required_features),)) |
| 89 | |
Daniel Dunbar | f51f031 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 90 | # Evaluate the test. |
Daniel Dunbar | 019c590 | 2013-08-21 23:06:32 +0000 | [diff] [blame^] | 91 | return self._evaluate_test(test, lit_config) |
Daniel Dunbar | f51f031 | 2013-02-05 21:03:25 +0000 | [diff] [blame] | 92 | |
| 93 | def _evaluate_test(self, test, lit_config): |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 94 | name = test.path_in_suite[-1] |
| 95 | source_path = test.getSourcePath() |
Howard Hinnant | 3778f27 | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 96 | source_dir = os.path.dirname(source_path) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 97 | |
| 98 | # Check what kind of test this is. |
| 99 | assert name.endswith('.pass.cpp') or name.endswith('.fail.cpp') |
| 100 | expected_compile_fail = name.endswith('.fail.cpp') |
| 101 | |
| 102 | # If this is a compile (failure) test, build it and check for failure. |
| 103 | if expected_compile_fail: |
| 104 | cmd = [self.cxx_under_test, '-c', |
Daniel Dunbar | 5f09d9e0 | 2010-09-15 04:31:58 +0000 | [diff] [blame] | 105 | '-o', '/dev/null', source_path] + self.cpp_flags |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 106 | out, err, exitCode = self.execute_command(cmd) |
| 107 | if exitCode == 1: |
| 108 | return lit.Test.PASS, "" |
| 109 | else: |
| 110 | report = """Command: %s\n""" % ' '.join(["'%s'" % a |
| 111 | for a in cmd]) |
| 112 | report += """Exit Code: %d\n""" % exitCode |
| 113 | if out: |
| 114 | report += """Standard Output:\n--\n%s--""" % out |
| 115 | if err: |
| 116 | report += """Standard Error:\n--\n%s--""" % err |
| 117 | report += "\n\nExpected compilation to fail!" |
Daniel Dunbar | 5f09d9e0 | 2010-09-15 04:31:58 +0000 | [diff] [blame] | 118 | return lit.Test.FAIL, report |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 119 | else: |
| 120 | exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False) |
| 121 | exec_path = exec_file.name |
| 122 | exec_file.close() |
| 123 | |
| 124 | try: |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 125 | compile_cmd = [self.cxx_under_test, '-o', exec_path, |
Daniel Dunbar | 5f09d9e0 | 2010-09-15 04:31:58 +0000 | [diff] [blame] | 126 | source_path] + self.cpp_flags + self.ld_flags |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 127 | cmd = compile_cmd |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 128 | out, err, exitCode = self.execute_command(cmd) |
| 129 | if exitCode != 0: |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 130 | report = """Command: %s\n""" % ' '.join(["'%s'" % a |
| 131 | for a in cmd]) |
| 132 | report += """Exit Code: %d\n""" % exitCode |
| 133 | if out: |
| 134 | report += """Standard Output:\n--\n%s--""" % out |
| 135 | if err: |
| 136 | report += """Standard Error:\n--\n%s--""" % err |
| 137 | report += "\n\nCompilation failed unexpectedly!" |
| 138 | return lit.Test.FAIL, report |
| 139 | |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 140 | cmd = [] |
| 141 | if self.exec_env: |
| 142 | cmd.append('env') |
| 143 | cmd.extend('%s=%s' % (name, value) |
| 144 | for name,value in self.exec_env.items()) |
| 145 | cmd.append(exec_path) |
Howard Hinnant | c1a45fb | 2012-08-02 18:36:47 +0000 | [diff] [blame] | 146 | if lit_config.useValgrind: |
| 147 | cmd = lit_config.valgrindArgs + cmd |
Howard Hinnant | 3778f27 | 2013-01-14 17:12:54 +0000 | [diff] [blame] | 148 | out, err, exitCode = self.execute_command(cmd, source_dir) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 149 | if exitCode != 0: |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 150 | report = """Compiled With: %s\n""" % \ |
| 151 | ' '.join(["'%s'" % a for a in compile_cmd]) |
| 152 | report += """Command: %s\n""" % \ |
| 153 | ' '.join(["'%s'" % a for a in cmd]) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 154 | report += """Exit Code: %d\n""" % exitCode |
| 155 | if out: |
| 156 | report += """Standard Output:\n--\n%s--""" % out |
| 157 | if err: |
| 158 | report += """Standard Error:\n--\n%s--""" % err |
| 159 | report += "\n\nCompiled test failed unexpectedly!" |
| 160 | return lit.Test.FAIL, report |
| 161 | finally: |
| 162 | try: |
| 163 | os.remove(exec_path) |
| 164 | except: |
| 165 | pass |
| 166 | return lit.Test.PASS, "" |
| 167 | |
| 168 | # name: The name of this test suite. |
| 169 | config.name = 'libc++' |
| 170 | |
| 171 | # suffixes: A list of file extensions to treat as test files. |
| 172 | config.suffixes = ['.cpp'] |
| 173 | |
| 174 | # test_source_root: The root path where tests are located. |
| 175 | config.test_source_root = os.path.dirname(__file__) |
| 176 | |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 177 | # Gather various compiler parameters. |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 178 | cxx_under_test = lit_config.params.get('cxx_under_test', None) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 179 | if cxx_under_test is None: |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 180 | cxx_under_test = getattr(config, 'cxx_under_test', None) |
Daniel Dunbar | 05abe93 | 2013-02-06 20:24:23 +0000 | [diff] [blame] | 181 | |
| 182 | # If no specific cxx_under_test was given, attempt to infer it as clang++. |
| 183 | clangxx = lit.util.which('clang++', config.environment['PATH']) |
| 184 | if clangxx is not None: |
| 185 | cxx_under_test = clangxx |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 186 | lit_config.note("inferred cxx_under_test as: %r" % (cxx_under_test,)) |
Daniel Dunbar | 05abe93 | 2013-02-06 20:24:23 +0000 | [diff] [blame] | 187 | if cxx_under_test is None: |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 188 | lit_config.fatal('must specify user parameter cxx_under_test ' |
| 189 | '(e.g., --param=cxx_under_test=clang++)') |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 190 | |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 191 | libcxx_src_root = lit_config.params.get('libcxx_src_root', None) |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 192 | if libcxx_src_root is None: |
| 193 | libcxx_src_root = getattr(config, 'libcxx_src_root', None) |
| 194 | if libcxx_src_root is None: |
| 195 | libcxx_src_root = os.path.dirname(config.test_source_root) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 196 | |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 197 | libcxx_obj_root = lit_config.params.get('libcxx_obj_root', None) |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 198 | if libcxx_obj_root is None: |
| 199 | libcxx_obj_root = getattr(config, 'libcxx_obj_root', None) |
| 200 | if libcxx_obj_root is None: |
| 201 | libcxx_obj_root = libcxx_src_root |
| 202 | |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 203 | cxx_has_stdcxx0x_flag_str = lit_config.params.get('cxx_has_stdcxx0x_flag', None) |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 204 | if cxx_has_stdcxx0x_flag_str is not None: |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 205 | if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'): |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 206 | cxx_has_stdcxx0x_flag = True |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 207 | elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'): |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 208 | cxx_has_stdcxx0x_flag = False |
| 209 | else: |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 210 | lit_config.fatal( |
| 211 | 'user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1') |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 212 | else: |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 213 | cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 214 | |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 215 | # This test suite supports testing against either the system library or the |
| 216 | # locally built one; the former mode is useful for testing ABI compatibility |
Daniel Dunbar | 5178942 | 2013-02-06 17:47:08 +0000 | [diff] [blame] | 217 | # between the current headers and a shipping dynamic library. |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 218 | use_system_lib_str = lit_config.params.get('use_system_lib', None) |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 219 | if use_system_lib_str is not None: |
| 220 | if use_system_lib_str.lower() in ('1', 'true'): |
| 221 | use_system_lib = True |
| 222 | elif use_system_lib_str.lower() in ('', '0', 'false'): |
| 223 | use_system_lib = False |
| 224 | else: |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 225 | lit_config.fatal('user parameter use_system_lib should be 0 or 1') |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 226 | else: |
Daniel Dunbar | 5178942 | 2013-02-06 17:47:08 +0000 | [diff] [blame] | 227 | # Default to testing against the locally built libc++ library. |
| 228 | use_system_lib = False |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 229 | lit_config.note("inferred use_system_lib as: %r" % (use_system_lib,)) |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 230 | |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 231 | link_flags = [] |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 232 | link_flags_str = lit_config.params.get('link_flags', None) |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 233 | if link_flags_str is None: |
| 234 | link_flags_str = getattr(config, 'link_flags', None) |
| 235 | if link_flags_str is None: |
| 236 | if sys.platform == 'darwin': |
| 237 | link_flags += ['-lSystem'] |
| 238 | elif sys.platform == 'linux2': |
| 239 | link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', |
| 240 | '-lrt', '-lgcc_s'] |
| 241 | else: |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 242 | lit_config.fatal("unrecognized system") |
| 243 | lit_config.note("inferred link_flags as: %r" % (link_flags,)) |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 244 | if not link_flags_str is None: |
| 245 | link_flags += shlex.split(link_flags_str) |
| 246 | |
Chandler Carruth | ce395a9 | 2011-01-23 01:05:20 +0000 | [diff] [blame] | 247 | # Configure extra compiler flags. |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 248 | include_paths = ['-I' + libcxx_src_root + '/include', |
| 249 | '-I' + libcxx_src_root + '/test/support'] |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 250 | library_paths = ['-L' + libcxx_obj_root + '/lib'] |
Chandler Carruth | ce395a9 | 2011-01-23 01:05:20 +0000 | [diff] [blame] | 251 | compile_flags = [] |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 252 | if cxx_has_stdcxx0x_flag: |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 253 | compile_flags += ['-std=c++0x'] |
Chandler Carruth | ce395a9 | 2011-01-23 01:05:20 +0000 | [diff] [blame] | 254 | |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 255 | # Configure extra linker parameters. |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 256 | exec_env = {} |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 257 | if sys.platform == 'darwin': |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 258 | if not use_system_lib: |
| 259 | exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib') |
| 260 | elif sys.platform == 'linux2': |
Daniel Dunbar | d2d614c | 2013-02-06 17:45:53 +0000 | [diff] [blame] | 261 | if not use_system_lib: |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 262 | link_flags += ['-Wl,-R', libcxx_obj_root + '/lib'] |
| 263 | compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', |
| 264 | '-D__STDC_CONSTANT_MACROS'] |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 265 | else: |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 266 | lit_config.fatal("unrecognized system") |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 267 | |
Daniel Dunbar | 7c4b853 | 2012-11-27 23:56:28 +0000 | [diff] [blame] | 268 | config.test_format = LibcxxTestFormat( |
| 269 | cxx_under_test, |
| 270 | cpp_flags = ['-nostdinc++'] + compile_flags + include_paths, |
Daniel Dunbar | 62b9439 | 2013-02-12 19:28:51 +0000 | [diff] [blame] | 271 | ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + link_flags, |
Daniel Dunbar | 8495871 | 2013-02-05 18:03:49 +0000 | [diff] [blame] | 272 | exec_env = exec_env) |
Daniel Dunbar | 42ea463 | 2010-09-15 03:57:04 +0000 | [diff] [blame] | 273 | |
Daniel Dunbar | b6354a0 | 2013-02-05 22:28:03 +0000 | [diff] [blame] | 274 | # Get or infer the target triple. |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 275 | config.target_triple = lit_config.params.get('target_triple', None) |
Daniel Dunbar | b6354a0 | 2013-02-05 22:28:03 +0000 | [diff] [blame] | 276 | # If no target triple was given, try to infer it from the compiler under test. |
| 277 | if config.target_triple is None: |
| 278 | config.target_triple = lit.util.capture( |
| 279 | [cxx_under_test, '-dumpmachine']).strip() |
Daniel Dunbar | 4a38129 | 2013-08-09 14:44:11 +0000 | [diff] [blame] | 280 | lit_config.note("inferred target_triple as: %r" % (config.target_triple,)) |
Daniel Dunbar | 582c97d | 2013-02-05 21:43:30 +0000 | [diff] [blame] | 281 | |
| 282 | # Write an "available feature" that combines the triple when use_system_lib is |
| 283 | # enabled. This is so that we can easily write XFAIL markers for tests that are |
| 284 | # known to fail with versions of libc++ as were shipped with a particular |
| 285 | # triple. |
| 286 | if use_system_lib: |
| 287 | config.available_features.add('with_system_lib=%s' % ( |
| 288 | config.target_triple,)) |