From b4ebb0e415549c5dc04e0622bb8f06999c558ede Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Mon, 14 Jan 2013 17:12:54 +0000 Subject: [PATCH] Michael van der Westhuizen: Improve support for testing on Linux. Fixes http://llvm.org/bugs/show_bug.cgi?id=14892. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@172436 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/lit.cfg | 29 ++++++++++++++++++++++++----- test/support/platform_support.h | 7 ++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/test/lit.cfg b/test/lit.cfg index 512935c3..dc843ac5 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -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, diff --git a/test/support/platform_support.h b/test/support/platform_support.h index 11cdb045..eff5af07 100644 --- a/test/support/platform_support.h +++ b/test/support/platform_support.h @@ -27,9 +27,14 @@ #define LOCALE_zh_CN_UTF_8 "Chinese_China.936" #else #define LOCALE_en_US_UTF_8 "en_US.UTF-8" -#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2" #define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8" +#ifdef __linux__ +#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO-8859-1" +#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO-8859-2" +#else #define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO8859-1" +#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2" +#endif #define LOCALE_ru_RU_UTF_8 "ru_RU.UTF-8" #define LOCALE_zh_CN_UTF_8 "zh_CN.UTF-8" #endif