From 3f61a183a81cdc879ea6a435811765ae315846de Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Wed, 27 Apr 2016 15:26:27 +0000 Subject: [PATCH] Decorate TSan tests with "@skipUnlessThreadSanitizer" which skips the tests if the selected compiler can't compile with "-fsanitize=thread". llvm-svn: 267726 --- lldb/packages/Python/lldbsuite/test/decorators.py | 18 ++++++++++++++++++ .../test/functionalities/tsan/basic/TestTsanBasic.py | 1 + .../functionalities/tsan/multiple/TestTsanMultiple.py | 1 + .../tsan/thread_leak/TestTsanThreadLeak.py | 1 + .../tsan/thread_numbers/TestTsanThreadNumbers.py | 1 + 5 files changed, 22 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index f5d194f..d33a849 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -7,6 +7,7 @@ from functools import wraps import os import re import sys +import tempfile # Third-party modules import six @@ -505,6 +506,23 @@ def skipUnlessCompilerRt(func): return "compiler-rt not found" if not os.path.exists(compilerRtPath) else None return skipTestIfFn(is_compiler_rt_missing)(func) +def skipUnlessThreadSanitizer(func): + """Decorate the item to skip test unless Clang -fsanitize=thread is supported.""" + def is_compiler_clang_with_thread_sanitizer(self): + compiler_path = self.getCompiler() + compiler = os.path.basename(compiler_path) + if not compiler.startswith("clang"): + return "Test requires clang as compiler" + f = tempfile.NamedTemporaryFile() + cmd = "echo 'int main() {}' | %s -x c -o %s -" % (compiler_path, f.name) + if os.popen(cmd).close() != None: + return None # The compiler cannot compile at all, let's *not* skip the test + cmd = "echo 'int main() {}' | %s -fsanitize=thread -x c -o %s -" % (compiler_path, f.name) + if os.popen(cmd).close() != None: + return "Compiler cannot compile with -fsanitize=thread" + return None + return skipTestIfFn(is_compiler_clang_with_thread_sanitizer)(func) + def skipUnlessClangModules(): """Decorate the item to skip test unless Clang -gmodules flag is supported.""" def is_compiler_clang_with_gmodules(self): diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py index 12cd13b..44fa9ce 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/TestTsanBasic.py @@ -17,6 +17,7 @@ class TsanBasicTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt + @skipUnlessThreadSanitizer def test (self): self.build () self.tsan_tests () diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py index ae36291..9878d62 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/multiple/TestTsanMultiple.py @@ -17,6 +17,7 @@ class TsanMultipleTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt + @skipUnlessThreadSanitizer def test (self): self.build () self.tsan_tests () diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py index 14a0d03..ed62009 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_leak/TestTsanThreadLeak.py @@ -17,6 +17,7 @@ class TsanThreadLeakTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt + @skipUnlessThreadSanitizer def test (self): self.build () self.tsan_tests () diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py index 18ebaa0..c7905bc 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/thread_numbers/TestTsanThreadNumbers.py @@ -17,6 +17,7 @@ class TsanThreadNumbersTestCase(TestBase): @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default @skipIfRemote @skipUnlessCompilerRt + @skipUnlessThreadSanitizer def test (self): self.build () self.tsan_tests () -- 2.7.4