[TSan] Add a test case for r209939
[blocksruntime.git] / test / tsan / blacklist2.cc
blobb39eef8bd3312efbe4be796f784dfb4cf13520a5
1 // Test that blacklisted functions are still contained in the stack trace.
3 // RUN: %clangxx_tsan -O1 %s -fsanitize-blacklist=%p/Helpers/blacklist.txt -o %t
4 // RUN: %deflake %run %t 2>&1 | FileCheck %s
5 #include <pthread.h>
6 #include <stdio.h>
7 #include <unistd.h>
9 int Global;
11 void *Thread1(void *x) {
12 sleep(1);
13 // CHECK: ThreadSanitizer: data race
14 // CHECK: Write of size 4
15 // CHECK: #0 Thread1{{.*}}blacklist2.cc:[[@LINE+1]]
16 Global++;
17 return NULL;
20 void TouchGlobal() {
21 // CHECK: Previous write of size 4
22 // CHECK: #0 TouchGlobal(){{.*}}blacklist2.cc:[[@LINE+1]]
23 Global--;
26 void CallTouchGlobal() {
27 // CHECK: #1 CallTouchGlobal{{.*}}blacklist2.cc:[[@LINE+1]]
28 TouchGlobal();
31 void *Blacklisted_Thread2(void *x) {
32 Global--;
33 // CHECK: #2 Blacklisted_Thread2{{.*}}blacklist2.cc:[[@LINE+1]]
34 CallTouchGlobal();
35 return NULL;
38 int main() {
39 pthread_t t[2];
40 pthread_create(&t[0], NULL, Thread1, NULL);
41 pthread_create(&t[1], NULL, Blacklisted_Thread2, NULL);
42 pthread_join(t[0], NULL);
43 pthread_join(t[1], NULL);
44 printf("PASS\n");
45 return 0;