summaryrefslogtreecommitdiff
path: root/lib/tsan/lit_tests/mutex_destroy_locked.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-09-18 07:23:54 +0000
committerAlexey Samsonov <samsonov@google.com>2012-09-18 07:23:54 +0000
commit3168586f24f2d275e6fae167d9a4d98238004f43 (patch)
treeb7b7bee981a84b27a1bec78dc6b0fc0252ce5bf0 /lib/tsan/lit_tests/mutex_destroy_locked.cc
parent53fec5d65c35f69656f30e16dbfa439d3860be68 (diff)
[TSan] port all output tests to lit and move them to lit_tests directory. This makes 'make check-tsan' command test both unit and output TSan tests. Old custom makefiles for running TSan tests are still functional as well.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@164110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/lit_tests/mutex_destroy_locked.cc')
-rw-r--r--lib/tsan/lit_tests/mutex_destroy_locked.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/tsan/lit_tests/mutex_destroy_locked.cc b/lib/tsan/lit_tests/mutex_destroy_locked.cc
new file mode 100644
index 000000000..427c64345
--- /dev/null
+++ b/lib/tsan/lit_tests/mutex_destroy_locked.cc
@@ -0,0 +1,29 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
+#include <pthread.h>
+#include <unistd.h>
+
+void *Thread(void *p) {
+ pthread_mutex_lock((pthread_mutex_t*)p);
+ return 0;
+}
+
+int main() {
+ pthread_mutex_t m;
+ pthread_mutex_init(&m, 0);
+ pthread_t t;
+ pthread_create(&t, 0, Thread, &m);
+ usleep(1000*1000);
+ pthread_mutex_destroy(&m);
+ pthread_join(t, 0);
+ return 0;
+}
+
+// CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex
+// CHECK: #0 pthread_mutex_destroy
+// CHECK: #1 main
+// CHECK: and:
+// CHECK: #0 pthread_mutex_lock
+// CHECK: #1 Thread
+// CHECK: Mutex {{.*}} created at:
+// CHECK: #0 pthread_mutex_init
+// CHECK: #1 main