tsan: add system tests for suppressions
llvm-svn: 183673
This commit is contained in:
28
compiler-rt/lib/tsan/lit_tests/suppressions_global.cc
Normal file
28
compiler-rt/lib/tsan/lit_tests/suppressions_global.cc
Normal file
@@ -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
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
race:RacyGlobal
|
||||
|
||||
30
compiler-rt/lib/tsan/lit_tests/suppressions_race.cc
Normal file
30
compiler-rt/lib/tsan/lit_tests/suppressions_race.cc
Normal file
@@ -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
|
||||
|
||||
2
compiler-rt/lib/tsan/lit_tests/suppressions_race.cc.supp
Normal file
2
compiler-rt/lib/tsan/lit_tests/suppressions_race.cc.supp
Normal file
@@ -0,0 +1,2 @@
|
||||
race:Thread1
|
||||
|
||||
30
compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc
Normal file
30
compiler-rt/lib/tsan/lit_tests/suppressions_race2.cc
Normal file
@@ -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
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
race:Thread2
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user