diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2018-01-29 15:10:22 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2018-01-29 15:10:22 +0000 |
commit | e64c4f418c0942eb7703d12cd47c602ecf302344 (patch) | |
tree | f90d548b53bc406e828f4f7a4ecb5dd83164ea94 /compiler-rt/test/tsan | |
parent | 01acc9d8acb2196760bc9ca0805b918a086be0a9 (diff) | |
download | bcm5719-llvm-e64c4f418c0942eb7703d12cd47c602ecf302344.tar.gz bcm5719-llvm-e64c4f418c0942eb7703d12cd47c602ecf302344.zip |
tsan: deflake a test
There was a failure on a bot:
http://lab.llvm.org:8011/builders/clang-cmake-mipsel/builds/1283
strerror test is indeed flaky. We protect all races by a barrier in other tests
to eliminate flakiness. Do the same here.
No idea why tls_race2.cc failed. Add output at the end of the test
as we do in other tests. Sometimes test process crashes somewhere
in the middle (e.g. during race reporting) and it looks like empty output.
Output at the end of test allows to understand if the process has crashed,
or it has finished but produced no race reports.
Reviewed in https://reviews.llvm.org/D42633
llvm-svn: 323657
Diffstat (limited to 'compiler-rt/test/tsan')
-rw-r--r-- | compiler-rt/test/tsan/strerror_r.cc | 16 | ||||
-rw-r--r-- | compiler-rt/test/tsan/tls_race2.cc | 3 |
2 files changed, 12 insertions, 7 deletions
diff --git a/compiler-rt/test/tsan/strerror_r.cc b/compiler-rt/test/tsan/strerror_r.cc index ad482013012..23b77454b94 100644 --- a/compiler-rt/test/tsan/strerror_r.cc +++ b/compiler-rt/test/tsan/strerror_r.cc @@ -2,25 +2,27 @@ // RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s // UNSUPPORTED: darwin -#include <assert.h> +#include "test.h" + #include <errno.h> #include <pthread.h> -#include <stdio.h> #include <string.h> char buffer[1000]; void *Thread(void *p) { + barrier_wait(&barrier); strerror_r(TEST_ERROR, buffer, sizeof(buffer)); return buffer; } int main() { - pthread_t th[2]; - pthread_create(&th[0], 0, Thread, 0); - pthread_create(&th[1], 0, Thread, 0); - pthread_join(th[0], 0); - pthread_join(th[1], 0); + barrier_init(&barrier, 2); + pthread_t th; + pthread_create(&th, 0, Thread, 0); + strerror_r(TEST_ERROR, buffer, sizeof(buffer)); + barrier_wait(&barrier); + pthread_join(th, 0); fprintf(stderr, "DONE\n"); } diff --git a/compiler-rt/test/tsan/tls_race2.cc b/compiler-rt/test/tsan/tls_race2.cc index f3139b69fc0..5968e66d5b1 100644 --- a/compiler-rt/test/tsan/tls_race2.cc +++ b/compiler-rt/test/tsan/tls_race2.cc @@ -22,6 +22,8 @@ int main() { pthread_t t; pthread_create(&t, 0, Thread, 0); pthread_join(t, 0); + fprintf(stderr, "DONE\n"); + return 0; } // CHECK: WARNING: ThreadSanitizer: data race @@ -29,3 +31,4 @@ int main() { // CHECK-FreeBSD: Location is TLS of thread T1. // CHECK-NetBSD: Location is TLS of thread T1. // CHECK-Darwin: Location is heap block of size 4 +// CHECK: DONE |