|
@@ -8,6 +8,8 @@ import platform
|
|
|
import tempfile
|
|
|
import signal
|
|
|
import subprocess
|
|
|
+import errno
|
|
|
+import time
|
|
|
|
|
|
class LibcxxTestFormat(lit.formats.FileBasedTest):
|
|
|
"""
|
|
@@ -24,9 +26,15 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
|
|
|
self.cpp_flags = list(cpp_flags)
|
|
|
self.ld_flags = list(ld_flags)
|
|
|
|
|
|
- def execute_command(self, command):
|
|
|
- p = subprocess.Popen(command, stdin=subprocess.PIPE,
|
|
|
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
+ def execute_command(self, command, in_dir=None):
|
|
|
+ kwargs = {
|
|
|
+ 'stdin' :subprocess.PIPE,
|
|
|
+ 'stdout':subprocess.PIPE,
|
|
|
+ 'stderr':subprocess.PIPE,
|
|
|
+ }
|
|
|
+ if in_dir:
|
|
|
+ kwargs['cwd'] = in_dir
|
|
|
+ p = subprocess.Popen(command, **kwargs)
|
|
|
out,err = p.communicate()
|
|
|
exitCode = p.wait()
|
|
|
|
|
@@ -37,8 +45,18 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
|
|
|
return out, err, exitCode
|
|
|
|
|
|
def execute(self, test, lit_config):
|
|
|
+ while True:
|
|
|
+ try:
|
|
|
+ return self._execute(test, lit_config)
|
|
|
+ except OSError, oe:
|
|
|
+ if oe.errno != errno.ETXTBSY:
|
|
|
+ raise
|
|
|
+ time.sleep(0.1)
|
|
|
+
|
|
|
+ def _execute(self, test, lit_config):
|
|
|
name = test.path_in_suite[-1]
|
|
|
source_path = test.getSourcePath()
|
|
|
+ source_dir = os.path.dirname(source_path)
|
|
|
|
|
|
# Check what kind of test this is.
|
|
|
assert name.endswith('.pass.cpp') or name.endswith('.fail.cpp')
|
|
@@ -85,7 +103,7 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
|
|
|
cmd = [exec_path]
|
|
|
if lit_config.useValgrind:
|
|
|
cmd = lit_config.valgrindArgs + cmd
|
|
|
- out, err, exitCode = self.execute_command(cmd)
|
|
|
+ out, err, exitCode = self.execute_command(cmd, source_dir)
|
|
|
if exitCode != 0:
|
|
|
report = """Compiled With: %s\n""" % ' '.join(["'%s'" % a
|
|
|
for a in compile_cmd])
|
|
@@ -157,8 +175,9 @@ libraries = []
|
|
|
if sys.platform == 'darwin':
|
|
|
libraries += ['-lSystem']
|
|
|
if sys.platform == 'linux2':
|
|
|
- libraries += ['-lgcc_eh', '-lsupc++', '-lc', '-lm', '-lrt', '-lgcc_s']
|
|
|
+ libraries += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', '-lrt', '-lgcc_s']
|
|
|
libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
|
|
|
+ compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS']
|
|
|
|
|
|
config.test_format = LibcxxTestFormat(
|
|
|
cxx_under_test,
|