forked from OSchip/llvm-project
[RT] Make tsan tests more portable
by avoiding potential races when scanning stdout and stderr output. Patch by Maxim Kuvyrkov. llvm-svn: 262476
This commit is contained in:
parent
f0f24628cb
commit
ba29b5794c
|
@ -8,7 +8,7 @@ extern "C" void __interceptor_free(void *p);
|
|||
extern "C" void *malloc(unsigned long size) {
|
||||
static int first = 0;
|
||||
if (__sync_lock_test_and_set(&first, 1) == 0)
|
||||
printf("user malloc\n");
|
||||
fprintf(stderr, "user malloc\n");
|
||||
return __interceptor_malloc(size);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("Pass\n");
|
||||
fprintf(stderr, "Pass\n");
|
||||
// CHECK: ThreadSanitizer: data race
|
||||
// CHECK: Pass
|
||||
return 0;
|
||||
|
|
|
@ -33,7 +33,7 @@ int main() {
|
|||
Global = 43;
|
||||
WTFGlobal = 143;
|
||||
pthread_join(t, 0);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -23,7 +23,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Blacklisted_Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,6 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Blacklisted_Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(int argc, char *argv[]) {
|
|||
dlclose(lib);
|
||||
}
|
||||
pthread_join(th, 0);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -23,7 +23,7 @@ int main() {
|
|||
while (write(pipes[1], &t, 1) != 1) {
|
||||
}
|
||||
pthread_join(t, 0);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -28,7 +28,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -53,7 +53,7 @@ int main() {
|
|||
exit(printf("close failed\n"));
|
||||
if (close(fd2) == -1)
|
||||
exit(printf("close failed\n"));
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -27,7 +27,7 @@ int main() {
|
|||
exit(printf("dup2 failed\n"));
|
||||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -27,7 +27,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -38,7 +38,7 @@ int main() {
|
|||
pthread_join(t, 0);
|
||||
close(c);
|
||||
close(s);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -45,7 +45,7 @@ int main() {
|
|||
close(c);
|
||||
close(s);
|
||||
pthread_join(t, 0);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -31,7 +31,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -25,7 +25,7 @@ int main() {
|
|||
barrier_wait(&barrier);
|
||||
Global = 43;
|
||||
pthread_join(t, 0);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -24,7 +24,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, MemSetThread, x);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ int main() {
|
|||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ int main() {
|
|||
int res = __tsan_atomic32_load(&a, __tsan_memory_order_acquire);
|
||||
if (res == 100) {
|
||||
// CHECK: PASS
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -26,10 +26,10 @@ int main() {
|
|||
stress(jheap);
|
||||
pthread_join(th, 0);
|
||||
if (__tsan_java_fini() != 0) {
|
||||
printf("FAILED\n");
|
||||
fprintf(stderr, "FAILED\n");
|
||||
return 1;
|
||||
}
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ int main() {
|
|||
return printf("second mmap failed with %d\n", errno);
|
||||
__tsan_java_init(jheap, kHeapSize);
|
||||
__tsan_java_move(jheap + 16, jheap, 16);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ int main() {
|
|||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
__tsan_java_free(varaddr2, kBlockSize);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ void *Thread(void *p) {
|
|||
*(int*)varaddr = 42;
|
||||
int rec = __tsan_java_mutex_unlock_rec(lockaddr);
|
||||
if (rec != 2) {
|
||||
printf("FAILED 0 rec=%d\n", rec);
|
||||
fprintf(stderr, "FAILED 0 rec=%d\n", rec);
|
||||
exit(1);
|
||||
}
|
||||
barrier_wait(&barrier);
|
||||
barrier_wait(&barrier);
|
||||
__tsan_java_mutex_lock_rec(lockaddr, rec);
|
||||
if (*(int*)varaddr != 43) {
|
||||
printf("FAILED 3 var=%d\n", *(int*)varaddr);
|
||||
fprintf(stderr, "FAILED 3 var=%d\n", *(int*)varaddr);
|
||||
exit(1);
|
||||
}
|
||||
__tsan_java_mutex_unlock(lockaddr);
|
||||
|
@ -40,7 +40,7 @@ int main() {
|
|||
barrier_wait(&barrier);
|
||||
__tsan_java_mutex_lock(lockaddr);
|
||||
if (*(int*)varaddr != 42) {
|
||||
printf("FAILED 1 var=%d\n", *(int*)varaddr);
|
||||
fprintf(stderr, "FAILED 1 var=%d\n", *(int*)varaddr);
|
||||
exit(1);
|
||||
}
|
||||
*(int*)varaddr = 43;
|
||||
|
@ -48,7 +48,7 @@ int main() {
|
|||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
__tsan_java_free(jheap, kBlockSize);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ void *Thread(void *p) {
|
|||
__tsan_java_mutex_lock(lockaddr);
|
||||
int rec = __tsan_java_mutex_unlock_rec(lockaddr);
|
||||
if (rec != 3) {
|
||||
printf("FAILED 0 rec=%d\n", rec);
|
||||
fprintf(stderr, "FAILED 0 rec=%d\n", rec);
|
||||
exit(1);
|
||||
}
|
||||
*(int*)varaddr = 42;
|
||||
|
@ -42,7 +42,7 @@ int main() {
|
|||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
__tsan_java_free(jheap, kBlockSize);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ int main(int argc, char **argv) {
|
|||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
__tsan_java_free(varaddr1_new, kBlockSize);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char **argv) {
|
|||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
__tsan_java_free(varaddr1_new, kBlockSize);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ int main() {
|
|||
barrier_wait(&barrier);
|
||||
pthread_join(th, 0);
|
||||
__tsan_java_free(jheap, kBlockSize);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return __tsan_java_fini();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ int foo(jmp_buf env) {
|
|||
int main() {
|
||||
jmp_buf env;
|
||||
if (setjmp(env) == 42) {
|
||||
printf("JUMPED\n");
|
||||
fprintf(stderr, "JUMPED\n");
|
||||
return 0;
|
||||
}
|
||||
foo(env);
|
||||
printf("FAILED\n");
|
||||
fprintf(stderr, "FAILED\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ int main() {
|
|||
sigjmp_buf env;
|
||||
printf("env=%p\n", env);
|
||||
if (sigsetjmp(env, 1) == 42) {
|
||||
printf("JUMPED\n");
|
||||
printf(stderr, "JUMPED\n");
|
||||
return 0;
|
||||
}
|
||||
foo(env);
|
||||
printf("FAILED\n");
|
||||
fprintf(stderr, "FAILED\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void mymain() {
|
|||
return;
|
||||
}
|
||||
foo(env);
|
||||
printf("FAILED\n");
|
||||
fprintf(stderr, "FAILED\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
|
@ -37,7 +37,7 @@ void mymain() {
|
|||
return;
|
||||
}
|
||||
foo(env);
|
||||
printf("FAILED\n");
|
||||
fprintf(stderr, "FAILED\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
int main() {
|
||||
void *p = malloc((size_t)-1);
|
||||
if (p != 0)
|
||||
printf("FAIL malloc(-1) = %p\n", p);
|
||||
fprintf(stderr, "FAIL malloc(-1) = %p\n", p);
|
||||
p = malloc((size_t)-1 / 2);
|
||||
if (p != 0)
|
||||
printf("FAIL malloc(-1/2) = %p\n", p);
|
||||
fprintf(stderr, "FAIL malloc(-1/2) = %p\n", p);
|
||||
p = calloc((size_t)-1, (size_t)-1);
|
||||
if (p != 0)
|
||||
printf("FAIL calloc(-1, -1) = %p\n", p);
|
||||
fprintf(stderr, "FAIL calloc(-1, -1) = %p\n", p);
|
||||
p = calloc((size_t)-1 / 2, (size_t)-1 / 2);
|
||||
if (p != 0)
|
||||
printf("FAIL calloc(-1/2, -1/2) = %p\n", p);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "FAIL calloc(-1/2, -1/2) = %p\n", p);
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: FAIL
|
||||
|
|
|
@ -24,7 +24,7 @@ int main() {
|
|||
g = 1;
|
||||
barrier_wait(&barrier);
|
||||
pthread_join(t, 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
// CHECK-NOT: ThreadSanitizer: data race
|
||||
// CHECK: PASS
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int main() {
|
|||
pthread_create(&t[1], 0, Thread, 0);
|
||||
pthread_join(t[0], 0);
|
||||
pthread_join(t[1], 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -27,7 +27,7 @@ int main() {
|
|||
pthread_create(&t[1], 0, Thread, 0);
|
||||
pthread_join(t[0], 0);
|
||||
pthread_join(t[1], 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -31,7 +31,7 @@ int main() {
|
|||
pthread_create(&t[1], 0, Thread1, 0);
|
||||
pthread_join(t[0], 0);
|
||||
pthread_join(t[1], 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -36,7 +36,7 @@ int main() {
|
|||
pthread_create(&t[1], 0, Thread1, 0);
|
||||
pthread_join(t[0], 0);
|
||||
pthread_join(t[1], 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -36,7 +36,7 @@ int main() {
|
|||
pthread_create(&t[1], 0, Thread1, 0);
|
||||
pthread_join(t[0], 0);
|
||||
pthread_join(t[1], 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -19,7 +19,7 @@ int main(int argc, char *argv[]) {
|
|||
pthread_create(&th[1], 0, thr, 0);
|
||||
pthread_join(th[0], 0);
|
||||
pthread_join(th[1], 0);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
// CHECK: DONE
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ int main() {
|
|||
pthread_create(&t, 0, Thread, 0);
|
||||
barrier_wait(&barrier);
|
||||
pthread_detach(t);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ int main() {
|
|||
pthread_create(&t, 0, Thread, 0);
|
||||
pthread_detach(t);
|
||||
barrier_wait(&barrier);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ int main() {
|
|||
pthread_t t;
|
||||
pthread_create(&t, 0, Thread, 0);
|
||||
pthread_join(t, 0);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ int main() {
|
|||
pthread_t t;
|
||||
pthread_create(&t, 0, Thread, 0);
|
||||
pthread_detach(t);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ void *Thread(void *x) {
|
|||
int main() {
|
||||
pthread_t t;
|
||||
pthread_create(&t, 0, Thread, 0);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("PASS\n");
|
||||
fprintf(stderr, "PASS\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -77,7 +77,7 @@ int main() {
|
|||
pthread_create(&th, 0, Thread, 0);
|
||||
Test(true);
|
||||
pthread_join(th, 0);
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer:
|
||||
|
|
|
@ -27,7 +27,7 @@ int main() {
|
|||
pipe(fds);
|
||||
int pid = vfork();
|
||||
if (pid < 0) {
|
||||
printf("FAIL to vfork\n");
|
||||
fprintf(stderr, "FAIL to vfork\n");
|
||||
exit(1);
|
||||
}
|
||||
if (pid == 0) { // child
|
||||
|
@ -44,7 +44,7 @@ int main() {
|
|||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
printf("DONE\n");
|
||||
fprintf(stderr, "DONE\n");
|
||||
}
|
||||
|
||||
// CHECK-NOT: WARNING: ThreadSanitizer: data race
|
||||
|
|
|
@ -10,6 +10,6 @@ struct DDD: CCC, BBB { DDD(); }; // NOLINT
|
|||
DDD::DDD() { }
|
||||
int main() {
|
||||
DDD d;
|
||||
printf("OK\n");
|
||||
fprintf(stderr, "OK\n");
|
||||
}
|
||||
// CHECK: OK
|
||||
|
|
Loading…
Reference in New Issue