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 | 2b93db0ed15988a26f675f9fce258f4803b28c56 (patch) | |
tree | 66895fb03ccf71e37627725a41671889128c1591 /test/tsan | |
parent | 180c7ddfacde608fd9bd7565d6c53a4a7db5034c (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@323657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan')
-rw-r--r-- | test/tsan/strerror_r.cc | 16 | ||||
-rw-r--r-- | test/tsan/tls_race2.cc | 3 |
2 files changed, 12 insertions, 7 deletions
diff --git a/test/tsan/strerror_r.cc b/test/tsan/strerror_r.cc index ad4820130..23b77454b 100644 --- a/test/tsan/strerror_r.cc +++ b/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/test/tsan/tls_race2.cc b/test/tsan/tls_race2.cc index f3139b69f..5968e66d5 100644 --- a/test/tsan/tls_race2.cc +++ b/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 |