From 2c8dda4e53a305566bfd92967166ffe68d53851b Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 6 Jun 2014 21:04:55 +0000 Subject: [PATCH] [TSan] Make lit-tests more self-contained llvm-svn: 210370 --- compiler-rt/test/tsan/Helpers/blacklist.txt | 2 -- compiler-rt/test/tsan/Helpers/lit.local.cfg | 2 -- compiler-rt/test/tsan/SharedLibs/lit.local.cfg | 4 ---- .../test/tsan/SharedLibs/load_shared_lib-so.cc | 25 ---------------------- compiler-rt/test/tsan/blacklist.cc | 5 ++--- compiler-rt/test/tsan/blacklist2.cc | 5 ++++- compiler-rt/test/tsan/load_shared_lib.cc | 22 +++++++++++++++++-- compiler-rt/test/tsan/mutex_cycle2.c | 8 +++---- 8 files changed, 30 insertions(+), 43 deletions(-) delete mode 100644 compiler-rt/test/tsan/Helpers/blacklist.txt delete mode 100644 compiler-rt/test/tsan/Helpers/lit.local.cfg delete mode 100644 compiler-rt/test/tsan/SharedLibs/lit.local.cfg delete mode 100644 compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc diff --git a/compiler-rt/test/tsan/Helpers/blacklist.txt b/compiler-rt/test/tsan/Helpers/blacklist.txt deleted file mode 100644 index 999d07d..0000000 --- a/compiler-rt/test/tsan/Helpers/blacklist.txt +++ /dev/null @@ -1,2 +0,0 @@ -fun:*Blacklisted_Thread2* -fun:*CallTouchGlobal* diff --git a/compiler-rt/test/tsan/Helpers/lit.local.cfg b/compiler-rt/test/tsan/Helpers/lit.local.cfg deleted file mode 100644 index 9246b10..0000000 --- a/compiler-rt/test/tsan/Helpers/lit.local.cfg +++ /dev/null @@ -1,2 +0,0 @@ -# Files in this directory are helper files for other output tests. -config.suffixes = [] diff --git a/compiler-rt/test/tsan/SharedLibs/lit.local.cfg b/compiler-rt/test/tsan/SharedLibs/lit.local.cfg deleted file mode 100644 index b3677c1..0000000 --- a/compiler-rt/test/tsan/SharedLibs/lit.local.cfg +++ /dev/null @@ -1,4 +0,0 @@ -# Sources in this directory are compiled as shared libraries and used by -# tests in parent directory. - -config.suffixes = [] diff --git a/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc b/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc deleted file mode 100644 index f449fe9..0000000 --- a/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc +++ /dev/null @@ -1,25 +0,0 @@ -//===----------- load_shared_lib-so.cc --------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file is a part of ThreadSanitizer (TSan), a race detector. -// -//===----------------------------------------------------------------------===// - -#include -#include - -int GLOB_SHARED = 0; - -extern "C" -void *write_from_so(void *unused) { - if (unused) - sleep(1); - GLOB_SHARED++; - return NULL; -} diff --git a/compiler-rt/test/tsan/blacklist.cc b/compiler-rt/test/tsan/blacklist.cc index ab6f1d1..d6ca383 100644 --- a/compiler-rt/test/tsan/blacklist.cc +++ b/compiler-rt/test/tsan/blacklist.cc @@ -1,8 +1,7 @@ // Test blacklist functionality for TSan. -// RUN: %clangxx_tsan -O1 %s \ -// RUN: -fsanitize-blacklist=%p/Helpers/blacklist.txt \ -// RUN: -o %t && %run %t 2>&1 | FileCheck %s +// RUN: echo "fun:*Blacklisted_Thread2*" > %t.blacklist +// RUN: %clangxx_tsan -O1 %s -fsanitize-blacklist=%t.blacklist -o %t && %run %t 2>&1 | FileCheck %s #include #include diff --git a/compiler-rt/test/tsan/blacklist2.cc b/compiler-rt/test/tsan/blacklist2.cc index b39eef8..1258208 100644 --- a/compiler-rt/test/tsan/blacklist2.cc +++ b/compiler-rt/test/tsan/blacklist2.cc @@ -1,6 +1,9 @@ // Test that blacklisted functions are still contained in the stack trace. -// RUN: %clangxx_tsan -O1 %s -fsanitize-blacklist=%p/Helpers/blacklist.txt -o %t +// RUN: echo "fun:*Blacklisted_Thread2*" > %t.blacklist +// RUN: echo "fun:*CallTouchGlobal*" >> %t.blacklist + +// RUN: %clangxx_tsan -O1 %s -fsanitize-blacklist=%t.blacklist -o %t // RUN: %deflake %run %t 2>&1 | FileCheck %s #include #include diff --git a/compiler-rt/test/tsan/load_shared_lib.cc b/compiler-rt/test/tsan/load_shared_lib.cc index 2747b29..a27dc1c 100644 --- a/compiler-rt/test/tsan/load_shared_lib.cc +++ b/compiler-rt/test/tsan/load_shared_lib.cc @@ -2,10 +2,26 @@ // reports, the second report occurring in a new shared library is still // symbolized correctly. -// RUN: %clangxx_tsan -O1 %p/SharedLibs/load_shared_lib-so.cc \ -// RUN: -fPIC -shared -o %t-so.so +// RUN: %clangxx_tsan -O1 %s -DBUILD_SO -fPIC -shared -o %t-so.so // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s +#ifdef BUILD_SO + +#include +#include + +int GLOB_SHARED = 0; + +extern "C" +void *write_from_so(void *unused) { + if (unused) + sleep(1); + GLOB_SHARED++; + return NULL; +} + +#else // BUILD_SO + #include #include #include @@ -46,3 +62,5 @@ int main(int argc, char *argv[]) { // CHECK: write_from_so return 0; } + +#endif // BUILD_SO diff --git a/compiler-rt/test/tsan/mutex_cycle2.c b/compiler-rt/test/tsan/mutex_cycle2.c index fb2b533..cd9a467 100644 --- a/compiler-rt/test/tsan/mutex_cycle2.c +++ b/compiler-rt/test/tsan/mutex_cycle2.c @@ -1,9 +1,9 @@ // RUN: %clangxx_tsan %s -o %t // RUN: TSAN_OPTIONS=detect_deadlocks=1 not %run %t 2>&1 | FileCheck %s -// RUN: echo "deadlock:main" > sup -// RUN: TSAN_OPTIONS="detect_deadlocks=1 suppressions=sup" %run %t -// RUN: echo "deadlock:zzzz" > sup -// RUN: TSAN_OPTIONS="detect_deadlocks=1 suppressions=sup" not %run %t 2>&1 | FileCheck %s +// RUN: echo "deadlock:main" > %t.sup +// RUN: TSAN_OPTIONS="detect_deadlocks=1 suppressions=%t.sup" %run %t +// RUN: echo "deadlock:zzzz" > %t.sup +// RUN: TSAN_OPTIONS="detect_deadlocks=1 suppressions=%t.sup" not %run %t 2>&1 | FileCheck %s #include int main() { -- 2.7.4