| OLD | NEW |
| 1 # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: | 1 # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: |
| 2 | 2 |
| 3 # Configuration file for the 'lit' test runner. | 3 # Configuration file for the 'lit' test runner. |
| 4 | 4 |
| 5 import errno | 5 import errno |
| 6 import locale | 6 import locale |
| 7 import os | 7 import os |
| 8 import platform | 8 import platform |
| 9 import re | 9 import re |
| 10 import shlex | 10 import shlex |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 """ | 22 """ |
| 23 Custom test format handler for use with the test format use by libc++. | 23 Custom test format handler for use with the test format use by libc++. |
| 24 | 24 |
| 25 Tests fall into two categories: | 25 Tests fall into two categories: |
| 26 FOO.pass.cpp - Executable test which should compile, run, and exit with | 26 FOO.pass.cpp - Executable test which should compile, run, and exit with |
| 27 code 0. | 27 code 0. |
| 28 FOO.fail.cpp - Negative test case which is expected to fail compilation. | 28 FOO.fail.cpp - Negative test case which is expected to fail compilation. |
| 29 """ | 29 """ |
| 30 | 30 |
| 31 def __init__(self, cxx_under_test, use_verify_for_fail, | 31 def __init__(self, cxx_under_test, use_verify_for_fail, |
| 32 cpp_flags, ld_flags, exec_env): | 32 cpp_flags, ld_flags, exec_env, |
| 33 # @LOCALMOD |
| 34 exe_suffix, shell_prefix): |
| 33 self.cxx_under_test = cxx_under_test | 35 self.cxx_under_test = cxx_under_test |
| 34 self.use_verify_for_fail = use_verify_for_fail | 36 self.use_verify_for_fail = use_verify_for_fail |
| 35 self.cpp_flags = list(cpp_flags) | 37 self.cpp_flags = list(cpp_flags) |
| 36 self.ld_flags = list(ld_flags) | 38 self.ld_flags = list(ld_flags) |
| 37 self.exec_env = dict(exec_env) | 39 self.exec_env = dict(exec_env) |
| 40 # @LOCALMOD-START |
| 41 self.exe_suffix = exe_suffix |
| 42 self.shell_prefix = shell_prefix |
| 43 # @LOCALMOD-END |
| 38 | 44 |
| 39 def execute(self, test, lit_config): | 45 def execute(self, test, lit_config): |
| 40 while True: | 46 while True: |
| 41 try: | 47 try: |
| 42 return self._execute(test, lit_config) | 48 return self._execute(test, lit_config) |
| 43 except OSError, oe: | 49 except OSError, oe: |
| 44 if oe.errno != errno.ETXTBSY: | 50 if oe.errno != errno.ETXTBSY: |
| 45 raise | 51 raise |
| 46 time.sleep(0.1) | 52 time.sleep(0.1) |
| 47 | 53 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 def _clean(self, exec_path): | 115 def _clean(self, exec_path): |
| 110 os.remove(exec_path) | 116 os.remove(exec_path) |
| 111 | 117 |
| 112 def _run(self, exec_path, lit_config, in_dir=None): | 118 def _run(self, exec_path, lit_config, in_dir=None): |
| 113 cmd = [] | 119 cmd = [] |
| 114 if self.exec_env: | 120 if self.exec_env: |
| 115 cmd.append('env') | 121 cmd.append('env') |
| 116 cmd.extend('%s=%s' % (name, value) | 122 cmd.extend('%s=%s' % (name, value) |
| 117 for name,value in self.exec_env.items()) | 123 for name,value in self.exec_env.items()) |
| 118 cmd.append(exec_path) | 124 cmd.append(exec_path) |
| 125 # @LOCALMOD-START |
| 126 if self.shell_prefix: |
| 127 cmd = self.shell_prefix + cmd |
| 128 # @LOCALMOD-END |
| 119 if lit_config.useValgrind: | 129 if lit_config.useValgrind: |
| 120 cmd = lit_config.valgrindArgs + cmd | 130 cmd = lit_config.valgrindArgs + cmd |
| 121 out, err, exitCode = lit.util.executeCommand(cmd, cwd=in_dir) | 131 out, err, exitCode = lit.util.executeCommand(cmd, cwd=in_dir) |
| 122 return cmd, out, err, exitCode | 132 return cmd, out, err, exitCode |
| 123 | 133 |
| 124 def _evaluate_test(self, test, use_verify, lit_config): | 134 def _evaluate_test(self, test, use_verify, lit_config): |
| 125 name = test.path_in_suite[-1] | 135 name = test.path_in_suite[-1] |
| 126 source_path = test.getSourcePath() | 136 source_path = test.getSourcePath() |
| 127 source_dir = os.path.dirname(source_path) | 137 source_dir = os.path.dirname(source_path) |
| 128 | 138 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 142 report = """Command: %s\n""" % ' '.join(["'%s'" % a | 152 report = """Command: %s\n""" % ' '.join(["'%s'" % a |
| 143 for a in cmd]) | 153 for a in cmd]) |
| 144 report += """Exit Code: %d\n""" % rc | 154 report += """Exit Code: %d\n""" % rc |
| 145 if out: | 155 if out: |
| 146 report += """Standard Output:\n--\n%s--""" % out | 156 report += """Standard Output:\n--\n%s--""" % out |
| 147 if err: | 157 if err: |
| 148 report += """Standard Error:\n--\n%s--""" % err | 158 report += """Standard Error:\n--\n%s--""" % err |
| 149 report += "\n\nExpected compilation to fail!" | 159 report += "\n\nExpected compilation to fail!" |
| 150 return lit.Test.FAIL, report | 160 return lit.Test.FAIL, report |
| 151 else: | 161 else: |
| 152 exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False) | 162 # @LOCALMOD-START |
| 163 exec_file = tempfile.NamedTemporaryFile( |
| 164 suffix=self.exe_suffix, delete=False) |
| 165 # @LOCALMOD-END |
| 153 exec_path = exec_file.name | 166 exec_path = exec_file.name |
| 154 exec_file.close() | 167 exec_file.close() |
| 155 | 168 |
| 156 try: | 169 try: |
| 157 cmd, out, err, rc = self._build(exec_path, source_path) | 170 cmd, out, err, rc = self._build(exec_path, source_path) |
| 158 compile_cmd = cmd | 171 compile_cmd = cmd |
| 159 if rc != 0: | 172 if rc != 0: |
| 160 report = """Command: %s\n""" % ' '.join(["'%s'" % a | 173 report = """Command: %s\n""" % ' '.join(["'%s'" % a |
| 161 for a in cmd]) | 174 for a in cmd]) |
| 162 report += """Exit Code: %d\n""" % rc | 175 report += """Exit Code: %d\n""" % rc |
| (...skipping 25 matching lines...) Expand all Loading... |
| 188 self._clean(exec_path) | 201 self._clean(exec_path) |
| 189 except: | 202 except: |
| 190 pass | 203 pass |
| 191 return lit.Test.PASS, "" | 204 return lit.Test.PASS, "" |
| 192 | 205 |
| 193 | 206 |
| 194 class Configuration(object): | 207 class Configuration(object): |
| 195 def __init__(self, lit_config, config): | 208 def __init__(self, lit_config, config): |
| 196 self.lit_config = lit_config | 209 self.lit_config = lit_config |
| 197 self.config = config | 210 self.config = config |
| 211 # @LOCALMOD-START |
| 212 self.exe_suffix = None |
| 213 self.shell_prefix = None |
| 214 # @LOCALMOD-END |
| 198 self.cxx = None | 215 self.cxx = None |
| 199 self.src_root = None | 216 self.src_root = None |
| 200 self.obj_root = None | 217 self.obj_root = None |
| 201 self.env = {} | 218 self.env = {} |
| 202 self.compile_flags = ['-nostdinc++'] | 219 self.compile_flags = ['-nostdinc++'] |
| 203 self.link_flags = ['-nodefaultlibs'] | 220 self.link_flags = ['-nodefaultlibs'] |
| 204 self.use_system_lib = False | 221 self.use_system_lib = False |
| 205 self.use_clang_verify = False | 222 self.use_clang_verify = False |
| 206 | 223 |
| 207 if platform.system() not in ('Darwin', 'FreeBSD', 'Linux'): | 224 if platform.system() not in ('Darwin', 'FreeBSD', 'Linux'): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 220 if conf is None: | 237 if conf is None: |
| 221 return None | 238 return None |
| 222 if conf.lower() in ('1', 'true'): | 239 if conf.lower() in ('1', 'true'): |
| 223 return True | 240 return True |
| 224 if conf.lower() in ('', '0', 'false'): | 241 if conf.lower() in ('', '0', 'false'): |
| 225 return False | 242 return False |
| 226 self.lit_config.fatal( | 243 self.lit_config.fatal( |
| 227 "parameter '{}' should be true or false".format(name)) | 244 "parameter '{}' should be true or false".format(name)) |
| 228 | 245 |
| 229 def configure(self): | 246 def configure(self): |
| 247 # @LOCALMOD |
| 248 self.configure_exe_wrappers() |
| 230 self.configure_cxx() | 249 self.configure_cxx() |
| 231 self.configure_triple() | 250 self.configure_triple() |
| 232 self.configure_src_root() | 251 self.configure_src_root() |
| 233 self.configure_obj_root() | 252 self.configure_obj_root() |
| 234 self.configure_use_system_lib() | 253 self.configure_use_system_lib() |
| 235 self.configure_use_clang_verify() | 254 self.configure_use_clang_verify() |
| 236 self.configure_env() | 255 self.configure_env() |
| 237 self.configure_std_flag() | 256 self.configure_std_flag() |
| 238 self.configure_compile_flags() | 257 self.configure_compile_flags() |
| 239 self.configure_link_flags() | 258 self.configure_link_flags() |
| 240 self.configure_sanitizer() | 259 self.configure_sanitizer() |
| 241 self.configure_features() | 260 self.configure_features() |
| 261 # @LOCALMOD-START -- filter out nostdinc++ and nodefaultlibs if needed. |
| 262 if self.use_system_lib: |
| 263 self.compile_flags = [flag for flag in self.compile_flags |
| 264 if flag != '-nostdinc++'] |
| 265 self.link_flags = [flag for flag in self.link_flags |
| 266 if flag != '-nodefaultlibs'] |
| 267 # @LOCALMOD-END |
| 242 # Print the final compile and link flags. | 268 # Print the final compile and link flags. |
| 243 self.lit_config.note('Using compile flags: %s' % self.compile_flags) | 269 self.lit_config.note('Using compile flags: %s' % self.compile_flags) |
| 244 self.lit_config.note('Using link flags: %s' % self.link_flags) | 270 self.lit_config.note('Using link flags: %s' % self.link_flags) |
| 245 # Print as list to prevent "set([...])" from being printed. | 271 # Print as list to prevent "set([...])" from being printed. |
| 246 self.lit_config.note('Using available_features: %s' % | 272 self.lit_config.note('Using available_features: %s' % |
| 247 list(self.config.available_features)) | 273 list(self.config.available_features)) |
| 248 | 274 |
| 249 def get_test_format(self): | 275 def get_test_format(self): |
| 250 return LibcxxTestFormat( | 276 return LibcxxTestFormat( |
| 251 self.cxx, | 277 self.cxx, |
| 252 self.use_clang_verify, | 278 self.use_clang_verify, |
| 253 cpp_flags=self.compile_flags, | 279 cpp_flags=self.compile_flags, |
| 254 ld_flags=self.link_flags, | 280 ld_flags=self.link_flags, |
| 255 exec_env=self.env) | 281 exec_env=self.env, |
| 282 # @LOCALMOD |
| 283 exe_suffix=self.exe_suffix, |
| 284 shell_prefix=self.shell_prefix) |
| 285 |
| 286 # @LOCALMOD-START |
| 287 def configure_exe_wrappers(self): |
| 288 # Allow customizing the resulting executable's suffix |
| 289 # as well as an wrapper around how to run the executable |
| 290 # via a shell_prefix. |
| 291 self.exe_suffix = self.get_lit_conf('exe_suffix', 'exe') |
| 292 self.shell_prefix = self.get_lit_conf('shell_prefix', None) |
| 293 if self.shell_prefix: |
| 294 self.shell_prefix = shlex.split(self.shell_prefix) |
| 295 # @LOCALMOD-END |
| 256 | 296 |
| 257 def configure_cxx(self): | 297 def configure_cxx(self): |
| 258 # Gather various compiler parameters. | 298 # Gather various compiler parameters. |
| 259 self.cxx = self.get_lit_conf('cxx_under_test') | 299 self.cxx = self.get_lit_conf('cxx_under_test') |
| 260 | 300 |
| 261 # If no specific cxx_under_test was given, attempt to infer it as | 301 # If no specific cxx_under_test was given, attempt to infer it as |
| 262 # clang++. | 302 # clang++. |
| 263 if self.cxx is None: | 303 if self.cxx is None: |
| 264 clangxx = lit.util.which('clang++', | 304 clangxx = lit.util.which('clang++', |
| 265 self.config.environment['PATH']) | 305 self.config.environment['PATH']) |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 config.test_source_root = os.path.dirname(__file__) | 561 config.test_source_root = os.path.dirname(__file__) |
| 522 | 562 |
| 523 cfg_variant = getattr(config, 'configuration_variant', '') | 563 cfg_variant = getattr(config, 'configuration_variant', '') |
| 524 if cfg_variant: | 564 if cfg_variant: |
| 525 print 'Using configuration variant: %s' % cfg_variant | 565 print 'Using configuration variant: %s' % cfg_variant |
| 526 | 566 |
| 527 # Construct an object of the type named `<VARIANT>Configuration`. | 567 # Construct an object of the type named `<VARIANT>Configuration`. |
| 528 configuration = globals()['%sConfiguration' % cfg_variant](lit_config, config) | 568 configuration = globals()['%sConfiguration' % cfg_variant](lit_config, config) |
| 529 configuration.configure() | 569 configuration.configure() |
| 530 config.test_format = configuration.get_test_format() | 570 config.test_format = configuration.get_test_format() |
| OLD | NEW |