diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-06-10 15:39:28 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-06-10 15:39:28 +0000 |
commit | b08e72913ad05024191b22d6f36a68f473c5142f (patch) | |
tree | f9c5bd8773db4feff0cd327a8d2e002cc78696a5 | |
parent | 315bb0e6876e11def2b2e6648970d8805831e38d (diff) | |
download | bcm5719-llvm-b08e72913ad05024191b22d6f36a68f473c5142f.tar.gz bcm5719-llvm-b08e72913ad05024191b22d6f36a68f473c5142f.zip |
tsan: add system tests for suppressions
llvm-svn: 183673
7 files changed, 98 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/suppressions_global.cc b/compiler-rt/lib/tsan/lit_tests/suppressions_global.cc new file mode 100644 index 00000000000..7330f03e73e --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/suppressions_global.cc @@ -0,0 +1,28 @@ +// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" %t 2>&1 | FileCheck %s +#include <pthread.h> +#include <stdio.h> + +int RacyGlobal; + +void *Thread1(void *x) { + RacyGlobal = 42; + return NULL; +} + +void *Thread2(void *x) { + RacyGlobal = 43; + return NULL; +} + +int main() { + pthread_t t[2]; + pthread_create(&t[0], NULL, Thread1, NULL); + pthread_create(&t[1], NULL, Thread2, NULL); + pthread_join(t[0], NULL); + pthread_join(t[1], NULL); + return 0; +} + +// CHECK-NOT: failed to open suppressions file +// CHECK-NOT: WARNING: ThreadSanitizer: data race + diff --git a/compiler-rt/lib/tsan/lit_tests/suppressions_global.cc.supp b/compiler-rt/lib/tsan/lit_tests/suppressions_global.cc.supp new file mode 100644 index 00000000000..5fa8a2e43a9 --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/suppressions_global.cc.supp @@ -0,0 +1,2 @@ +race:RacyGlobal + diff --git a/compiler-rt/lib/tsan/lit_tests/suppressions_race.cc b/compiler-rt/lib/tsan/lit_tests/suppressions_race.cc new file mode 100644 index 00000000000..8b565d03b3f --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/suppressions_race.cc @@ -0,0 +1,30 @@ +// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" %t 2>&1 | FileCheck %s +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +int Global; + +void *Thread1(void *x) { + sleep(1); + Global = 42; + return NULL; +} + +void *Thread2(void *x) { + Global = 43; + return NULL; +} + +int main() { + pthread_t t[2]; + pthread_create(&t[0], NULL, Thread1, NULL); + pthread_create(&t[1], NULL, Thread2, NULL); + pthread_join(t[0], NULL); + pthread_join(t[1], NULL); + return 0; +} + +// CHECK-NOT: failed to open suppressions file +// CHECK-NOT: WARNING: ThreadSanitizer: data race + diff --git a/compiler-rt/lib/tsan/lit_tests/suppressions_race.cc.supp b/compiler-rt/lib/tsan/lit_tests/suppressions_race.cc.supp new file mode 100644 index 00000000000..cbdba76ea93 --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/suppressions_race.cc.supp @@ -0,0 +1,2 @@ +race:Thread1 + diff --git a/compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc b/compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc new file mode 100644 index 00000000000..267e434343f --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc @@ -0,0 +1,30 @@ +// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" %t 2>&1 | FileCheck %s +#include <pthread.h> +#include <stdio.h> +#include <unistd.h> + +int Global; + +void *Thread1(void *x) { + Global = 42; + return NULL; +} + +void *Thread2(void *x) { + sleep(1); + Global = 43; + return NULL; +} + +int main() { + pthread_t t[2]; + pthread_create(&t[0], NULL, Thread1, NULL); + pthread_create(&t[1], NULL, Thread2, NULL); + pthread_join(t[0], NULL); + pthread_join(t[1], NULL); + return 0; +} + +// CHECK-NOT: failed to open suppressions file +// CHECK-NOT: WARNING: ThreadSanitizer: data race + diff --git a/compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc.supp b/compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc.supp new file mode 100644 index 00000000000..b3c4dbc5936 --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc.supp @@ -0,0 +1,2 @@ +race:Thread2 + diff --git a/compiler-rt/lib/tsan/lit_tests/test_output.sh b/compiler-rt/lib/tsan/lit_tests/test_output.sh index 1eedf6eb20a..94b742a97ba 100755 --- a/compiler-rt/lib/tsan/lit_tests/test_output.sh +++ b/compiler-rt/lib/tsan/lit_tests/test_output.sh @@ -40,6 +40,10 @@ if [ "$1" == "" ]; then echo TEST $c is not supported continue fi + if [ "`grep "TSAN_OPTIONS" $c`" ]; then + echo SKIPPING $c -- requires TSAN_OPTIONS + continue + fi COMPILER=$CXX case $c in *.c) COMPILER=$CC |