1 // Test blacklist functionality for TSan.
2 
3 // RUN: echo "fun:*Blacklisted_Thread2*" > %t.blacklist
4 // RUN: %clangxx_tsan -O1 %s -fsanitize-blacklist=%t.blacklist -o %t && %run %t 2>&1 | FileCheck %s
5 #include <pthread.h>
6 #include <stdio.h>
7 
8 int Global;
9 
Thread1(void * x)10 void *Thread1(void *x) {
11   Global++;
12   return NULL;
13 }
14 
Blacklisted_Thread2(void * x)15 void *Blacklisted_Thread2(void *x) {
16   Global--;
17   return NULL;
18 }
19 
main()20 int main() {
21   pthread_t t[2];
22   pthread_create(&t[0], NULL, Thread1, NULL);
23   pthread_create(&t[1], NULL, Blacklisted_Thread2, NULL);
24   pthread_join(t[0], NULL);
25   pthread_join(t[1], NULL);
26   printf("PASS\n");
27   return 0;
28 }
29 
30 // CHECK-NOT: ThreadSanitizer: data race
31