[clang-format] Rename ExportBlockIndentation -> IndentExportBlock (#123493)
[llvm-project.git] / compiler-rt / test / tsan / mutex_held_wrong_context.cpp
blob68a67618917567b615630dbe0ec5cdc70fde4d48
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
4 pthread_mutex_t mtx;
6 __attribute__((noinline)) void Func1() {
7 pthread_mutex_lock(&mtx);
8 __tsan_check_no_mutexes_held();
9 pthread_mutex_unlock(&mtx);
12 __attribute__((noinline)) void Func2() {
13 pthread_mutex_lock(&mtx);
14 pthread_mutex_unlock(&mtx);
15 __tsan_check_no_mutexes_held();
18 int main() {
19 pthread_mutex_init(&mtx, NULL);
20 Func1();
21 Func2();
22 return 0;
25 // CHECK: WARNING: ThreadSanitizer: mutex held in the wrong context
26 // CHECK: {{.*}}__tsan_check_no_mutexes_held{{.*}}
27 // CHECK: {{.*}}Func1{{.*}}
28 // CHECK: {{.*}}main{{.*}}
29 // CHECK: Mutex {{.*}} created at:
30 // CHECK: {{.*}}pthread_mutex_init{{.*}}
31 // CHECK: {{.*}}main{{.*}}
32 // CHECK: SUMMARY: ThreadSanitizer: mutex held in the wrong context {{.*}}mutex_held_wrong_context.cpp{{.*}}Func1
34 // CHECK-NOT: SUMMARY: ThreadSanitizer: mutex held in the wrong context {{.*}}mutex_held_wrong_context.cpp{{.*}}Func2