aboutsummaryrefslogtreecommitdiff
path: root/lib/tsan/lit_tests/halt_on_error.cc
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-06 22:49:13 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-06 22:49:13 +0000
commit8ef50bf3d1c287b5013c3168de77a462dfce3495 (patch)
tree3467f3372c1195b1546172d89af2205a50b1866d /lib/tsan/lit_tests/halt_on_error.cc
parent11023dc647fd8f41418da90d59db138400d0f334 (diff)
downloadsrc-8ef50bf3d1c287b5013c3168de77a462dfce3495.tar.gz
src-8ef50bf3d1c287b5013c3168de77a462dfce3495.zip
Import compiler-rt release_34 branch r197381.vendor/compiler-rt/compiler-rt-r197381
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=274201 svn path=/vendor/compiler-rt/compiler-rt-r197381/; revision=274202; tag=vendor/compiler-rt/compiler-rt-r197381
Diffstat (limited to 'lib/tsan/lit_tests/halt_on_error.cc')
-rw-r--r--lib/tsan/lit_tests/halt_on_error.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/tsan/lit_tests/halt_on_error.cc b/lib/tsan/lit_tests/halt_on_error.cc
new file mode 100644
index 000000000000..fddaffff29aa
--- /dev/null
+++ b/lib/tsan/lit_tests/halt_on_error.cc
@@ -0,0 +1,25 @@
+// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS halt_on_error=1" not %t 2>&1 | FileCheck %s
+#include <pthread.h>
+#include <stdio.h>
+
+int X;
+
+void *Thread(void *x) {
+ X = 42;
+ return 0;
+}
+
+int main() {
+ fprintf(stderr, "BEFORE\n");
+ pthread_t t;
+ pthread_create(&t, 0, Thread, 0);
+ X = 43;
+ pthread_join(t, 0);
+ fprintf(stderr, "AFTER\n");
+ return 0;
+}
+
+// CHECK: BEFORE
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NOT: AFTER
+