Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / fd_close_norace2.cpp
blob382ae5f34a83b7169a8f9bf7ebc29d68833d417f
1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
6 int pipes[2];
8 void *Thread(void *x) {
9 // wait for shutown signal
10 while (read(pipes[0], &x, 1) != 1) {
12 close(pipes[0]);
13 close(pipes[1]);
14 return 0;
17 int main() {
18 if (pipe(pipes))
19 return 1;
20 pthread_t t;
21 pthread_create(&t, 0, Thread, 0);
22 // send shutdown signal
23 while (write(pipes[1], &t, 1) != 1) {
25 pthread_join(t, 0);
26 fprintf(stderr, "OK\n");
29 // CHECK-NOT: WARNING: ThreadSanitizer: data race
30 // CHECK: OK