Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / strerror_r.cpp
blob6adab1ef17b4a965aaba8b1dbd6c1936ef7deeb3
1 // RUN: %clangxx_tsan -O1 -DTEST_ERROR=ERANGE %s -o %t && %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYS %s
2 // RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s
3 // This test is for GNU specific version of strerror_r()
4 // UNSUPPORTED: darwin, target={{.*(netbsd|freebsd).*}}
6 #include "test.h"
8 #include <errno.h>
9 #include <pthread.h>
10 #include <string.h>
12 char buffer[1000];
14 void *Thread(void *p) {
15 barrier_wait(&barrier);
16 return strerror_r(TEST_ERROR, buffer, sizeof(buffer));
19 int main() {
20 barrier_init(&barrier, 2);
21 pthread_t th;
22 pthread_create(&th, 0, Thread, 0);
23 strerror_r(TEST_ERROR, buffer, sizeof(buffer));
24 barrier_wait(&barrier);
25 pthread_join(th, 0);
26 fprintf(stderr, "DONE\n");
29 // CHECK-USER: WARNING: ThreadSanitizer: data race
30 // CHECK-SYS-NOT: WARNING: ThreadSanitizer: data race
32 // CHECK: DONE