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