]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/tsan/suppressions_race2.cc
Imported Upstream version 1.0.0~0alpha
[rustc.git] / src / compiler-rt / test / tsan / suppressions_race2.cc
1 // RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions=%s.supp" %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
5
6 int Global;
7
8 void *Thread1(void *x) {
9 Global = 42;
10 return NULL;
11 }
12
13 void *Thread2(void *x) {
14 sleep(1);
15 Global = 43;
16 return NULL;
17 }
18
19 int main() {
20 pthread_t t[2];
21 pthread_create(&t[0], NULL, Thread1, NULL);
22 pthread_create(&t[1], NULL, Thread2, NULL);
23 pthread_join(t[0], NULL);
24 pthread_join(t[1], NULL);
25 printf("OK\n");
26 return 0;
27 }
28
29 // CHECK-NOT: failed to open suppressions file
30 // CHECK-NOT: WARNING: ThreadSanitizer: data race
31