aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/race_top_suppression.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/race_top_suppression.cc')
-rw-r--r--test/tsan/race_top_suppression.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/tsan/race_top_suppression.cc b/test/tsan/race_top_suppression.cc
new file mode 100644
index 000000000000..7d42dbf3b4bf
--- /dev/null
+++ b/test/tsan/race_top_suppression.cc
@@ -0,0 +1,29 @@
+// RUN: echo "race_top:TopFunction" > %t.supp
+// RUN: %clangxx_tsan -O1 %s -o %t
+// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%t.supp'" %run %t 2>&1 | FileCheck %s
+// RUN: rm %t.supp
+#include "test.h"
+
+int Global;
+
+void TopFunction(int *p) {
+ *p = 1;
+}
+
+void *Thread(void *x) {
+ barrier_wait(&barrier);
+ TopFunction(&Global);
+ return 0;
+}
+
+int main() {
+ barrier_init(&barrier, 2);
+ pthread_t t;
+ pthread_create(&t, 0, Thread, 0);
+ Global--;
+ barrier_wait(&barrier);
+ pthread_join(t, 0);
+ fprintf(stderr, "DONE\n");
+}
+
+// CHECK-NOT: WARNING: ThreadSanitizer: data race