[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / fd_pipe_norace.cc
blob2da69ea2111228e7a764e0a638e1a19734573520
1 // RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
6 int fds[2];
7 int X;
9 void *Thread1(void *x) {
10 X = 42;
11 write(fds[1], "a", 1);
12 return NULL;
15 void *Thread2(void *x) {
16 char buf;
17 while (read(fds[0], &buf, 1) != 1) {
19 X = 43;
20 return NULL;
23 int main() {
24 pipe(fds);
25 pthread_t t[2];
26 pthread_create(&t[0], NULL, Thread1, NULL);
27 pthread_create(&t[1], NULL, Thread2, NULL);
28 pthread_join(t[0], NULL);
29 pthread_join(t[1], NULL);
30 printf("OK\n");
33 // CHECK-NOT: WARNING: ThreadSanitizer: data race