[compiler-rt] r323657 - tsan: deflake a test

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 07:10:22 PST 2018


Author: dvyukov
Date: Mon Jan 29 07:10:22 2018
New Revision: 323657

URL: http://llvm.org/viewvc/llvm-project?rev=323657&view=rev
Log:
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


Modified:
    compiler-rt/trunk/test/tsan/strerror_r.cc
    compiler-rt/trunk/test/tsan/tls_race2.cc

Modified: compiler-rt/trunk/test/tsan/strerror_r.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/strerror_r.cc?rev=323657&r1=323656&r2=323657&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/strerror_r.cc (original)
+++ compiler-rt/trunk/test/tsan/strerror_r.cc Mon Jan 29 07:10:22 2018
@@ -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");
 }
 

Modified: compiler-rt/trunk/test/tsan/tls_race2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/tls_race2.cc?rev=323657&r1=323656&r2=323657&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/tls_race2.cc (original)
+++ compiler-rt/trunk/test/tsan/tls_race2.cc Mon Jan 29 07:10:22 2018
@@ -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




More information about the llvm-commits mailing list