tsan: add system tests for suppressions

llvm-svn: 183673
This commit is contained in:
Dmitry Vyukov
2013-06-10 15:39:28 +00:00
parent 315bb0e687
commit b08e72913a
7 changed files with 98 additions and 0 deletions

View 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

View File

@@ -0,0 +1,2 @@
race:RacyGlobal

View 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

View File

@@ -0,0 +1,2 @@
race:Thread1

View 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

View File

@@ -0,0 +1,2 @@
race:Thread2

View File

@@ -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