[cfe-commits] [libcxx] r172436 - in /libcxx/trunk/test: lit.cfg support/platform_support.h
Michael van der Westhuizen
r1mikey at gmail.com
Tue Feb 5 22:25:52 PST 2013
Hi Daniel,
I'm not terribly fond of this workaround either. I was a little surprised to see this on Linux, as I'd only ever seen this sort of thing on Windows before.
I gather from looking around the Internet that this particular set of failures is due to the (randomly named) output test file still being open for write by the time the test harness executes it. From what I've found this is likely due to Linux delaying some VM object cache updates (and performing them asynchronously). This results in what is, effectively, a race condition, where the close of the output executable doesn't immediately mark the output file as no longer being written to, so when Python calls execve to run the test we get the ETXTBUSY error.
I''m at a little bit of a loss about how to work around this in a cleaner way. One small cleanup would be to only retry the execution of the test, rather than the whole compile/link/execute. As for properly dealing with this problem on Linux, I'm open to suggestions (but I think "fix the kernel" may be the only true fix)...
Michael
On 05 Feb 2013, at 8:14 PM, Daniel Dunbar <daniel at zuster.org> wrote:
> Hi Michael,
>
> I'm not a huge fan of handling the ETXTBUSY problem in this fashion, if possible I would rather see if there is a way to avoid this error completely.
>
> Do you know why this error is coming up? From my reading of the code, the executable file should be written and closed by the compiler before we ever try to execute it, so I don't see why this should happen (unless there was a name collision on the exec files which is probably not likely).
>
> - Daniel
>
>
> On Mon, Jan 14, 2013 at 9:12 AM, Howard Hinnant <hhinnant at apple.com> wrote:
> Author: hhinnant
> Date: Mon Jan 14 11:12:54 2013
> New Revision: 172436
>
> URL: http://llvm.org/viewvc/llvm-project?rev=172436&view=rev
> Log:
> Michael van der Westhuizen: Improve support for testing on Linux. Fixes http://llvm.org/bugs/show_bug.cgi?id=14892.
>
> Modified:
> libcxx/trunk/test/lit.cfg
> libcxx/trunk/test/support/platform_support.h
>
> Modified: libcxx/trunk/test/lit.cfg
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=172436&r1=172435&r2=172436&view=diff
> ==============================================================================
> --- libcxx/trunk/test/lit.cfg (original)
> +++ libcxx/trunk/test/lit.cfg Mon Jan 14 11:12:54 2013
> @@ -8,6 +8,8 @@
> import tempfile
> import signal
> import subprocess
> +import errno
> +import time
>
> class LibcxxTestFormat(lit.formats.FileBasedTest):
> """
> @@ -24,9 +26,15 @@
> 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 @@
> 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 @@
> 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 @@
> 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,
>
> Modified: libcxx/trunk/test/support/platform_support.h
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/platform_support.h?rev=172436&r1=172435&r2=172436&view=diff
> ==============================================================================
> --- libcxx/trunk/test/support/platform_support.h (original)
> +++ libcxx/trunk/test/support/platform_support.h Mon Jan 14 11:12:54 2013
> @@ -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
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130206/d5aa28b1/attachment.html>
More information about the cfe-commits
mailing list