summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-09-18 07:23:54 +0000
committerAlexey Samsonov <samsonov@google.com>2012-09-18 07:23:54 +0000
commit3168586f24f2d275e6fae167d9a4d98238004f43 (patch)
treeb7b7bee981a84b27a1bec78dc6b0fc0252ce5bf0 /lib
parent53fec5d65c35f69656f30e16dbfa439d3860be68 (diff)
[TSan] port all output tests to lit and move them to lit_tests directory. This makes 'make check-tsan' command test both unit and output TSan tests. Old custom makefiles for running TSan tests are still functional as well.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@164110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/tsan/Makefile.old2
-rw-r--r--lib/tsan/lit_tests/CMakeLists.txt28
-rw-r--r--lib/tsan/lit_tests/free_race.c (renamed from lib/tsan/output_tests/free_race.c)2
-rw-r--r--lib/tsan/lit_tests/free_race2.c (renamed from lib/tsan/output_tests/free_race2.c)2
-rw-r--r--lib/tsan/lit_tests/heap_race.cc (renamed from lib/tsan/output_tests/heap_race.cc)1
-rw-r--r--lib/tsan/lit_tests/lit.cfg86
-rw-r--r--lib/tsan/lit_tests/lit.site.cfg.in19
-rw-r--r--lib/tsan/lit_tests/memcpy_race.cc (renamed from lib/tsan/output_tests/memcpy_race.cc)2
-rw-r--r--lib/tsan/lit_tests/mop_with_offset.cc (renamed from lib/tsan/output_tests/mop_with_offset.cc)2
-rw-r--r--lib/tsan/lit_tests/mop_with_offset2.cc (renamed from lib/tsan/output_tests/mop_with_offset2.cc)2
-rw-r--r--lib/tsan/lit_tests/mutex_destroy_locked.cc (renamed from lib/tsan/output_tests/mutex_destroy_locked.cc)2
-rw-r--r--lib/tsan/lit_tests/race_on_barrier.c (renamed from lib/tsan/output_tests/race_on_barrier.c)2
-rw-r--r--lib/tsan/lit_tests/race_on_barrier2.c (renamed from lib/tsan/output_tests/race_on_barrier2.c)1
-rw-r--r--lib/tsan/lit_tests/race_on_heap.cc (renamed from lib/tsan/output_tests/race_on_heap.cc)1
-rw-r--r--lib/tsan/lit_tests/race_on_mutex.c (renamed from lib/tsan/output_tests/race_on_mutex.c)5
-rw-r--r--lib/tsan/lit_tests/race_with_finished_thread.cc (renamed from lib/tsan/output_tests/race_with_finished_thread.cc)2
-rw-r--r--lib/tsan/lit_tests/simple_race.c (renamed from lib/tsan/output_tests/simple_race.c)1
-rw-r--r--lib/tsan/lit_tests/simple_race.cc (renamed from lib/tsan/output_tests/simple_race.cc)1
-rw-r--r--lib/tsan/lit_tests/simple_stack.c (renamed from lib/tsan/output_tests/simple_stack.c)21
-rw-r--r--lib/tsan/lit_tests/simple_stack2.cc (renamed from lib/tsan/output_tests/simple_stack2.cc)13
-rw-r--r--lib/tsan/lit_tests/sleep_sync.cc (renamed from lib/tsan/output_tests/sleep_sync.cc)2
-rw-r--r--lib/tsan/lit_tests/sleep_sync2.cc (renamed from lib/tsan/output_tests/sleep_sync2.cc)1
-rw-r--r--lib/tsan/lit_tests/static_init1.cc (renamed from lib/tsan/output_tests/static_init1.cc)2
-rw-r--r--lib/tsan/lit_tests/static_init2.cc (renamed from lib/tsan/output_tests/static_init2.cc)2
-rw-r--r--lib/tsan/lit_tests/static_init3.cc (renamed from lib/tsan/output_tests/static_init3.cc)1
-rw-r--r--lib/tsan/lit_tests/static_init4.cc (renamed from lib/tsan/output_tests/static_init4.cc)2
-rw-r--r--lib/tsan/lit_tests/static_init5.cc (renamed from lib/tsan/output_tests/static_init5.cc)2
-rw-r--r--lib/tsan/lit_tests/suppress_same_address.cc (renamed from lib/tsan/output_tests/suppress_same_address.cc)2
-rw-r--r--lib/tsan/lit_tests/suppress_same_stacks.cc (renamed from lib/tsan/output_tests/suppress_same_stacks.cc)2
-rwxr-xr-xlib/tsan/lit_tests/test_output.sh (renamed from lib/tsan/output_tests/test_output.sh)4
-rw-r--r--lib/tsan/lit_tests/thread_leak.c (renamed from lib/tsan/output_tests/thread_leak.c)4
-rw-r--r--lib/tsan/lit_tests/thread_leak2.c (renamed from lib/tsan/output_tests/thread_leak2.c)4
-rw-r--r--lib/tsan/lit_tests/thread_leak3.c (renamed from lib/tsan/output_tests/thread_leak3.c)2
-rw-r--r--lib/tsan/lit_tests/tiny_race.c (renamed from lib/tsan/output_tests/tiny_race.c)1
-rw-r--r--lib/tsan/lit_tests/virtual_inheritance_compile_bug.cc (renamed from lib/tsan/output_tests/virtual_inheritance_compile_bug.cc)2
-rw-r--r--lib/tsan/lit_tests/vptr_benign_race.cc (renamed from lib/tsan/output_tests/vptr_benign_race.cc)1
-rw-r--r--lib/tsan/lit_tests/vptr_harmful_race.cc (renamed from lib/tsan/output_tests/vptr_harmful_race.cc)1
37 files changed, 193 insertions, 37 deletions
diff --git a/lib/tsan/Makefile.old b/lib/tsan/Makefile.old
index 95322730c..1273a7873 100644
--- a/lib/tsan/Makefile.old
+++ b/lib/tsan/Makefile.old
@@ -53,7 +53,7 @@ test: libtsan tsan_test
run: all
(ulimit -s 8192; ./tsan_test)
- ./output_tests/test_output.sh
+ ./lit_tests/test_output.sh
presubmit:
# Debug build with clang.
diff --git a/lib/tsan/lit_tests/CMakeLists.txt b/lib/tsan/lit_tests/CMakeLists.txt
index 62cad7870..4e3273b3a 100644
--- a/lib/tsan/lit_tests/CMakeLists.txt
+++ b/lib/tsan/lit_tests/CMakeLists.txt
@@ -1,10 +1,34 @@
configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ )
+
+configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
)
-# Run TSan unit tests.
-if(LLVM_INCLUDE_TESTS)
+if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}")
+ # Run TSan output tests only if we're not cross-compiling,
+ # and can be sure that clang would produce working binaries.
+ set(TSAN_TEST_DEPS
+ clang clang-headers FileCheck count not
+ ${TSAN_RUNTIME_LIBRARIES}
+ )
+ set(TSAN_TEST_PARAMS
+ tsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ )
+ if(LLVM_INCLUDE_TESTS)
+ list(APPEND ASAN_TEST_DEPS TsanUnitTests)
+ endif()
+ add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ PARAMS ${TSAN_TEST_PARAMS}
+ DEPENDS ${TSAN_TEST_DEPS}
+ )
+ set_target_properties(check-tsan PROPERTIES FOLDER "TSan unittests")
+elseif(LLVM_INCLUDE_TESTS)
+ # Otherwise run only TSan unit tests.
add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}/Unit
DEPENDS TsanUnitTests)
diff --git a/lib/tsan/output_tests/free_race.c b/lib/tsan/lit_tests/free_race.c
index fb7fbac77..9200c3bb3 100644
--- a/lib/tsan/output_tests/free_race.c
+++ b/lib/tsan/lit_tests/free_race.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -40,4 +41,3 @@ int main() {
// CHECK: Previous write of size 8 at {{.*}} by thread 1:
// CHECK: #0 free
// CHECK: #1 Thread1
-
diff --git a/lib/tsan/output_tests/free_race2.c b/lib/tsan/lit_tests/free_race2.c
index 7b2bdec03..095f82ea0 100644
--- a/lib/tsan/output_tests/free_race2.c
+++ b/lib/tsan/lit_tests/free_race2.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <stdlib.h>
void __attribute__((noinline)) foo(int *mem) {
@@ -23,4 +24,3 @@ int main() {
// CHECK: #0 free
// CHECK: #1 foo
// CHECK: #2 main
-
diff --git a/lib/tsan/output_tests/heap_race.cc b/lib/tsan/lit_tests/heap_race.cc
index e92bb3797..297f8dbde 100644
--- a/lib/tsan/output_tests/heap_race.cc
+++ b/lib/tsan/lit_tests/heap_race.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <stddef.h>
diff --git a/lib/tsan/lit_tests/lit.cfg b/lib/tsan/lit_tests/lit.cfg
new file mode 100644
index 000000000..f5e5230ef
--- /dev/null
+++ b/lib/tsan/lit_tests/lit.cfg
@@ -0,0 +1,86 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = 'ThreadSanitizer'
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+def DisplayNoConfigMessage():
+ lit.fatal("No site specific configuration available! " +
+ "Try running your test from the build tree or running " +
+ "make check-tsan")
+
+# Figure out LLVM source root.
+llvm_src_root = getattr(config, 'llvm_src_root', None)
+if llvm_src_root is None:
+ # We probably haven't loaded the site-specific configuration: the user
+ # is likely trying to run a test file directly, and the site configuration
+ # wasn't created by the build system.
+ tsan_site_cfg = lit.params.get('tsan_site_config', None)
+ if (tsan_site_cfg) and (os.path.exists(tsan_site_cfg)):
+ lit.load_config(config, tsan_site_cfg)
+ raise SystemExit
+
+ # Try to guess the location of site-specific configuration using llvm-config
+ # util that can point where the build tree is.
+ llvm_config = lit.util.which("llvm-config", config.environment["PATH"])
+ if not llvm_config:
+ DisplayNoConfigMessage()
+
+ # Validate that llvm-config points to the same source tree.
+ llvm_src_root = lit.util.capture(["llvm-config", "--src-root"]).strip()
+ tsan_test_src_root = os.path.join(llvm_src_root, "projects", "compiler-rt",
+ "lib", "tsan", "lit_tests")
+ if (os.path.realpath(tsan_test_src_root) !=
+ os.path.realpath(config.test_source_root)):
+ DisplayNoConfigMessage()
+
+ # Find out the presumed location of generated site config.
+ llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
+ tsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
+ "lib", "tsan", "lit_tests", "lit.site.cfg")
+ if (not tsan_site_cfg) or (not os.path.exists(tsan_site_cfg)):
+ DisplayNoConfigMessage()
+
+ lit.load_config(config, tsan_site_cfg)
+ raise SystemExit
+
+# Setup attributes common for all compiler-rt projects.
+compiler_rt_lit_cfg = os.path.join(llvm_src_root, "projects", "compiler-rt",
+ "lib", "lit.common.cfg")
+if (not compiler_rt_lit_cfg) or (not os.path.exists(compiler_rt_lit_cfg)):
+ lit.fatal("Can't find common compiler-rt lit config at: %r"
+ % compiler_rt_lit_cfg)
+lit.load_config(config, compiler_rt_lit_cfg)
+
+# Setup environment variables for running ThreadSanitizer.
+config.environment['TSAN_OPTIONS'] = "atexit_sleep_ms=0"
+
+# Setup default compiler flags used with -faddress-sanitizer option.
+# FIXME: Review the set of required flags and check if it can be reduced.
+clang_tsan_cflags = ("-fthread-sanitizer "
+ + "-fPIE "
+ + "-fno-builtin "
+ + "-g "
+ + "-Wall "
+ + "-pie "
+ + "-lpthread "
+ + "-ldl ")
+clang_tsan_cxxflags = "-ccc-clang-cxx -ccc-cxx " + clang_tsan_cflags
+config.substitutions.append( ("%clangxx_tsan ", (" " + config.clang + " " +
+ clang_tsan_cxxflags + " ")) )
+config.substitutions.append( ("%clang_tsan ", (" " + config.clang + " " +
+ clang_tsan_cflags + " ")) )
+
+# Define CHECK-%os to check for OS-dependent output.
+config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
+
+# Default test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp']
+
+# ThreadSanitizer tests are currently supported on Linux only.
+if config.host_os not in ['Linux']:
+ config.unsupported = True
diff --git a/lib/tsan/lit_tests/lit.site.cfg.in b/lib/tsan/lit_tests/lit.site.cfg.in
new file mode 100644
index 000000000..b1c6ccf54
--- /dev/null
+++ b/lib/tsan/lit_tests/lit.site.cfg.in
@@ -0,0 +1,19 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+
+config.clang = "@LLVM_BINARY_DIR@/bin/clang"
+config.host_os = "@HOST_OS@"
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+
+# LLVM tools dir can be passed in lit parameters, so try to
+# apply substitution.
+try:
+ config.llvm_tools_dir = config.llvm_tools_dir % lit.params
+except KeyError,e:
+ key, = e.args
+ lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
+
+# Let the main config do the real work.
+lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
diff --git a/lib/tsan/output_tests/memcpy_race.cc b/lib/tsan/lit_tests/memcpy_race.cc
index c6b79a709..c87bc9c9a 100644
--- a/lib/tsan/output_tests/memcpy_race.cc
+++ b/lib/tsan/lit_tests/memcpy_race.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
@@ -37,4 +38,3 @@ int main() {
// CHECK: Previous write of size 1 at [[ADDR]] by thread 1:
// CHECK: #0 memcpy
// CHECK: #1 Thread1
-
diff --git a/lib/tsan/output_tests/mop_with_offset.cc b/lib/tsan/lit_tests/mop_with_offset.cc
index fc497bfb4..14ece1a73 100644
--- a/lib/tsan/output_tests/mop_with_offset.cc
+++ b/lib/tsan/lit_tests/mop_with_offset.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
@@ -33,4 +34,3 @@ int main() {
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK: Write of size 1 at [[PTR2]] by thread 2:
// CHECK: Previous write of size 4 at [[PTR1]] by thread 1:
-
diff --git a/lib/tsan/output_tests/mop_with_offset2.cc b/lib/tsan/lit_tests/mop_with_offset2.cc
index bbeda5549..2a6fde730 100644
--- a/lib/tsan/output_tests/mop_with_offset2.cc
+++ b/lib/tsan/lit_tests/mop_with_offset2.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
@@ -33,4 +34,3 @@ int main() {
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK: Write of size 4 at [[PTR1]] by thread 1:
// CHECK: Previous write of size 1 at [[PTR2]] by thread 2:
-
diff --git a/lib/tsan/output_tests/mutex_destroy_locked.cc b/lib/tsan/lit_tests/mutex_destroy_locked.cc
index f6ab874c2..427c64345 100644
--- a/lib/tsan/output_tests/mutex_destroy_locked.cc
+++ b/lib/tsan/lit_tests/mutex_destroy_locked.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <unistd.h>
@@ -26,4 +27,3 @@ int main() {
// CHECK: Mutex {{.*}} created at:
// CHECK: #0 pthread_mutex_init
// CHECK: #1 main
-
diff --git a/lib/tsan/output_tests/race_on_barrier.c b/lib/tsan/lit_tests/race_on_barrier.c
index 98d7a1d84..491201f13 100644
--- a/lib/tsan/output_tests/race_on_barrier.c
+++ b/lib/tsan/lit_tests/race_on_barrier.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <stddef.h>
@@ -28,4 +29,3 @@ int main() {
}
// CHECK: WARNING: ThreadSanitizer: data race
-
diff --git a/lib/tsan/output_tests/race_on_barrier2.c b/lib/tsan/lit_tests/race_on_barrier2.c
index dbdb6b557..46a4f50b1 100644
--- a/lib/tsan/output_tests/race_on_barrier2.c
+++ b/lib/tsan/lit_tests/race_on_barrier2.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <stddef.h>
diff --git a/lib/tsan/output_tests/race_on_heap.cc b/lib/tsan/lit_tests/race_on_heap.cc
index 09a461c59..1fdf54d84 100644
--- a/lib/tsan/output_tests/race_on_heap.cc
+++ b/lib/tsan/lit_tests/race_on_heap.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/lib/tsan/output_tests/race_on_mutex.c b/lib/tsan/lit_tests/race_on_mutex.c
index 3ee9494dc..6c6697ddf 100644
--- a/lib/tsan/output_tests/race_on_mutex.c
+++ b/lib/tsan/lit_tests/race_on_mutex.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <stddef.h>
@@ -35,7 +36,7 @@ int main() {
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK-NEXT: Read of size 1 at {{.*}} by thread 2:
// CHECK-NEXT: #0 pthread_mutex_lock
-// CHECK-NEXT: #1 Thread2{{.*}} {{.*}}race_on_mutex.c:19{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #1 Thread2{{.*}} {{.*}}race_on_mutex.c:20{{(:3)?}} ({{.*}})
// CHECK: Previous write of size 1 at {{.*}} by thread 1:
// CHECK-NEXT: #0 pthread_mutex_init {{.*}} ({{.*}})
-// CHECK-NEXT: #1 Thread1{{.*}} {{.*}}race_on_mutex.c:10{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #1 Thread1{{.*}} {{.*}}race_on_mutex.c:11{{(:3)?}} ({{.*}})
diff --git a/lib/tsan/output_tests/race_with_finished_thread.cc b/lib/tsan/lit_tests/race_with_finished_thread.cc
index 1f60f4ba3..e50c22bf0 100644
--- a/lib/tsan/output_tests/race_with_finished_thread.cc
+++ b/lib/tsan/lit_tests/race_with_finished_thread.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
@@ -40,4 +41,3 @@ int main() {
// CHECK: Thread 1 (finished) created at:
// CHECK: #0 pthread_create
// CHECK: #1 main
-
diff --git a/lib/tsan/output_tests/simple_race.c b/lib/tsan/lit_tests/simple_race.c
index ed831fd8c..44aff8974 100644
--- a/lib/tsan/output_tests/simple_race.c
+++ b/lib/tsan/lit_tests/simple_race.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
diff --git a/lib/tsan/output_tests/simple_race.cc b/lib/tsan/lit_tests/simple_race.cc
index 8d2cabff7..ec29c92ee 100644
--- a/lib/tsan/output_tests/simple_race.cc
+++ b/lib/tsan/lit_tests/simple_race.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
diff --git a/lib/tsan/output_tests/simple_stack.c b/lib/tsan/lit_tests/simple_stack.c
index 12c5f5eaa..08f5f6534 100644
--- a/lib/tsan/output_tests/simple_stack.c
+++ b/lib/tsan/lit_tests/simple_stack.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
@@ -48,18 +49,18 @@ int main() {
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK-NEXT: Write of size 4 at {{.*}} by thread 1:
-// CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack.c:8{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack.c:13{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack.c:27{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack.c:9{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack.c:14{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack.c:28{{(:3)?}} ({{.*}})
// CHECK: Previous read of size 4 at {{.*}} by thread 2:
-// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack.c:17{{(:26)?}} ({{.*}})
-// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack.c:22{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #2 Thread2{{.*}} {{.*}}simple_stack.c:32{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack.c:18{{(:26)?}} ({{.*}})
+// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack.c:23{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 Thread2{{.*}} {{.*}}simple_stack.c:33{{(:3)?}} ({{.*}})
// CHECK: Thread 1 (running) created at:
// CHECK-NEXT: #0 pthread_create {{.*}} ({{.*}})
-// CHECK-NEXT: #1 StartThread{{.*}} {{.*}}simple_stack.c:37{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack.c:42{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #1 StartThread{{.*}} {{.*}}simple_stack.c:38{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack.c:43{{(:3)?}} ({{.*}})
// CHECK: Thread 2 ({{.*}}) created at:
// CHECK-NEXT: #0 pthread_create {{.*}} ({{.*}})
-// CHECK-NEXT: #1 StartThread{{.*}} {{.*}}simple_stack.c:37{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack.c:43{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #1 StartThread{{.*}} {{.*}}simple_stack.c:38{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack.c:44{{(:3)?}} ({{.*}})
diff --git a/lib/tsan/output_tests/simple_stack2.cc b/lib/tsan/lit_tests/simple_stack2.cc
index 560541589..ed95c684b 100644
--- a/lib/tsan/output_tests/simple_stack2.cc
+++ b/lib/tsan/lit_tests/simple_stack2.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
@@ -43,10 +44,10 @@ int main() {
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK-NEXT: Write of size 4 at {{.*}} by thread 1:
-// CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack2.cc:8{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack2.cc:15{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack2.cc:33{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #0 foo1{{.*}} {{.*}}simple_stack2.cc:9{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #1 bar1{{.*}} {{.*}}simple_stack2.cc:16{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 Thread1{{.*}} {{.*}}simple_stack2.cc:34{{(:3)?}} ({{.*}})
// CHECK: Previous read of size 4 at {{.*}} by main thread:
-// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack2.cc:19{{(:28)?}} ({{.*}})
-// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack2.cc:28{{(:3)?}} ({{.*}})
-// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack2.cc:40{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack2.cc:20{{(:28)?}} ({{.*}})
+// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack2.cc:29{{(:3)?}} ({{.*}})
+// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack2.cc:41{{(:3)?}} ({{.*}})
diff --git a/lib/tsan/output_tests/sleep_sync.cc b/lib/tsan/lit_tests/sleep_sync.cc
index a130f1530..566d04b1c 100644
--- a/lib/tsan/output_tests/sleep_sync.cc
+++ b/lib/tsan/lit_tests/sleep_sync.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <unistd.h>
@@ -27,4 +28,3 @@ int main() {
// CHECK-NEXT: #0 usleep
// CHECK-NEXT: #1 MySleep
// CHECK-NEXT: #2 main
-
diff --git a/lib/tsan/output_tests/sleep_sync2.cc b/lib/tsan/lit_tests/sleep_sync2.cc
index 017b9ba48..9a5182681 100644
--- a/lib/tsan/output_tests/sleep_sync2.cc
+++ b/lib/tsan/lit_tests/sleep_sync2.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <unistd.h>
diff --git a/lib/tsan/output_tests/static_init1.cc b/lib/tsan/lit_tests/static_init1.cc
index 75d281954..4faf5bc54 100644
--- a/lib/tsan/output_tests/static_init1.cc
+++ b/lib/tsan/lit_tests/static_init1.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -20,6 +21,7 @@ int main() {
pthread_create(&t[1], 0, Thread, 0);
pthread_join(t[0], 0);
pthread_join(t[1], 0);
+ printf("PASS\n");
}
// CHECK-NOT: WARNING: ThreadSanitizer: data race
diff --git a/lib/tsan/output_tests/static_init2.cc b/lib/tsan/lit_tests/static_init2.cc
index 8d41061c1..96ef821a7 100644
--- a/lib/tsan/output_tests/static_init2.cc
+++ b/lib/tsan/lit_tests/static_init2.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -26,6 +27,7 @@ int main() {
pthread_create(&t[1], 0, Thread, 0);
pthread_join(t[0], 0);
pthread_join(t[1], 0);
+ printf("PASS\n");
}
// CHECK-NOT: WARNING: ThreadSanitizer: data race
diff --git a/lib/tsan/output_tests/static_init3.cc b/lib/tsan/lit_tests/static_init3.cc
index 718f811d0..40fd4b940 100644
--- a/lib/tsan/output_tests/static_init3.cc
+++ b/lib/tsan/lit_tests/static_init3.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/lib/tsan/output_tests/static_init4.cc b/lib/tsan/lit_tests/static_init4.cc
index 175d46425..5ecc39926 100644
--- a/lib/tsan/output_tests/static_init4.cc
+++ b/lib/tsan/lit_tests/static_init4.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -30,6 +31,7 @@ int main() {
pthread_create(&t[1], 0, Thread1, 0);
pthread_join(t[0], 0);
pthread_join(t[1], 0);
+ printf("PASS\n");
}
// CHECK-NOT: WARNING: ThreadSanitizer: data race
diff --git a/lib/tsan/output_tests/static_init5.cc b/lib/tsan/lit_tests/static_init5.cc
index 89c11373c..9d44eb240 100644
--- a/lib/tsan/output_tests/static_init5.cc
+++ b/lib/tsan/lit_tests/static_init5.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -35,6 +36,7 @@ int main() {
pthread_create(&t[1], 0, Thread1, 0);
pthread_join(t[0], 0);
pthread_join(t[1], 0);
+ printf("PASS\n");
}
// CHECK-NOT: WARNING: ThreadSanitizer: data race
diff --git a/lib/tsan/output_tests/suppress_same_address.cc b/lib/tsan/lit_tests/suppress_same_address.cc
index 6e98970a1..174d1cc8f 100644
--- a/lib/tsan/output_tests/suppress_same_address.cc
+++ b/lib/tsan/lit_tests/suppress_same_address.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
int X;
@@ -24,4 +25,3 @@ int main() {
}
// CHECK: ThreadSanitizer: reported 1 warnings
-
diff --git a/lib/tsan/output_tests/suppress_same_stacks.cc b/lib/tsan/lit_tests/suppress_same_stacks.cc
index 6046a4ea9..32bff9d50 100644
--- a/lib/tsan/output_tests/suppress_same_stacks.cc
+++ b/lib/tsan/lit_tests/suppress_same_stacks.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
volatile int N; // Prevent loop unrolling.
@@ -24,4 +25,3 @@ int main() {
}
// CHECK: ThreadSanitizer: reported 1 warnings
-
diff --git a/lib/tsan/output_tests/test_output.sh b/lib/tsan/lit_tests/test_output.sh
index bd9cd9158..e4c2a4c41 100755
--- a/lib/tsan/output_tests/test_output.sh
+++ b/lib/tsan/lit_tests/test_output.sh
@@ -32,7 +32,7 @@ test_file() {
}
if [ "$1" == "" ]; then
- for c in $ROOTDIR/output_tests/*.{c,cc}; do
+ for c in $ROOTDIR/lit_tests/*.{c,cc}; do
if [[ $c == */failing_* ]]; then
echo SKIPPING FAILING TEST $c
continue
@@ -45,5 +45,5 @@ if [ "$1" == "" ]; then
done
wait
else
- test_file $ROOTDIR/output_tests/$1 $CXX "DUMP"
+ test_file $ROOTDIR/lit_tests/$1 $CXX "DUMP"
fi
diff --git a/lib/tsan/output_tests/thread_leak.c b/lib/tsan/lit_tests/thread_leak.c
index 88a11be4e..c5e669e5d 100644
--- a/lib/tsan/output_tests/thread_leak.c
+++ b/lib/tsan/lit_tests/thread_leak.c
@@ -1,4 +1,6 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
+#include <stdio.h>
void *Thread(void *x) {
return 0;
@@ -8,8 +10,8 @@ int main() {
pthread_t t;
pthread_create(&t, 0, Thread, 0);
pthread_join(t, 0);
+ printf("PASS\n");
return 0;
}
// CHECK-NOT: WARNING: ThreadSanitizer: thread leak
-
diff --git a/lib/tsan/output_tests/thread_leak2.c b/lib/tsan/lit_tests/thread_leak2.c
index 71e9c50b8..39f6b5e02 100644
--- a/lib/tsan/output_tests/thread_leak2.c
+++ b/lib/tsan/lit_tests/thread_leak2.c
@@ -1,4 +1,6 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
+#include <stdio.h>
void *Thread(void *x) {
return 0;
@@ -8,8 +10,8 @@ int main() {
pthread_t t;
pthread_create(&t, 0, Thread, 0);
pthread_detach(t);
+ printf("PASS\n");
return 0;
}
// CHECK-NOT: WARNING: ThreadSanitizer: thread leak
-
diff --git a/lib/tsan/output_tests/thread_leak3.c b/lib/tsan/lit_tests/thread_leak3.c
index 058b6e54d..c48219fe7 100644
--- a/lib/tsan/output_tests/thread_leak3.c
+++ b/lib/tsan/lit_tests/thread_leak3.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
void *Thread(void *x) {
@@ -11,4 +12,3 @@ int main() {
}
// CHECK: WARNING: ThreadSanitizer: thread leak
-
diff --git a/lib/tsan/output_tests/tiny_race.c b/lib/tsan/lit_tests/tiny_race.c
index 3a8d192a6..44cc1332f 100644
--- a/lib/tsan/output_tests/tiny_race.c
+++ b/lib/tsan/lit_tests/tiny_race.c
@@ -1,3 +1,4 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
int Global;
void *Thread1(void *x) {
diff --git a/lib/tsan/output_tests/virtual_inheritance_compile_bug.cc b/lib/tsan/lit_tests/virtual_inheritance_compile_bug.cc
index 6198e8a87..2275b8b8d 100644
--- a/lib/tsan/output_tests/virtual_inheritance_compile_bug.cc
+++ b/lib/tsan/lit_tests/virtual_inheritance_compile_bug.cc
@@ -1,5 +1,7 @@
// Regression test for http://code.google.com/p/thread-sanitizer/issues/detail?id=3.
// The C++ variant is much more compact that the LLVM IR equivalent.
+
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <stdio.h>
struct AAA { virtual long aaa () { return 0; } }; // NOLINT
struct BBB: virtual AAA { unsigned long bbb; }; // NOLINT
diff --git a/lib/tsan/output_tests/vptr_benign_race.cc b/lib/tsan/lit_tests/vptr_benign_race.cc
index fec4ffbb6..8c9fc596e 100644
--- a/lib/tsan/output_tests/vptr_benign_race.cc
+++ b/lib/tsan/lit_tests/vptr_benign_race.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
diff --git a/lib/tsan/output_tests/vptr_harmful_race.cc b/lib/tsan/lit_tests/vptr_harmful_race.cc
index a19e6abc7..f51ba7ee5 100644
--- a/lib/tsan/output_tests/vptr_harmful_race.cc
+++ b/lib/tsan/lit_tests/vptr_harmful_race.cc
@@ -1,3 +1,4 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>