summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/tls_race.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-01-21 13:50:02 +0000
committerDmitry Vyukov <dvyukov@google.com>2015-01-21 13:50:02 +0000
commit3ab6b2347e8d940b0687fb693c861c68d1e50998 (patch)
treef09bef7d67646f964ad364f8d43a027ce82bd419 /compiler-rt/test/tsan/tls_race.cc
parent79ca0fd1a02132ef3d85aacbfc4ab5eab5911c08 (diff)
downloadbcm5719-llvm-3ab6b2347e8d940b0687fb693c861c68d1e50998.tar.gz
bcm5719-llvm-3ab6b2347e8d940b0687fb693c861c68d1e50998.zip
tsan: remove sleeps from tests
Even sleep(1) lead to episodical flakes on some machines. Use an invisible by tsan barrier to enforce required execution order instead. This makes the tests deterministic and faster. llvm-svn: 226659
Diffstat (limited to 'compiler-rt/test/tsan/tls_race.cc')
-rw-r--r--compiler-rt/test/tsan/tls_race.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler-rt/test/tsan/tls_race.cc b/compiler-rt/test/tsan/tls_race.cc
index 18589347e80..5e817227670 100644
--- a/compiler-rt/test/tsan/tls_race.cc
+++ b/compiler-rt/test/tsan/tls_race.cc
@@ -1,19 +1,19 @@
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
-#include <pthread.h>
-#include <stddef.h>
-#include <unistd.h>
+#include "test.h"
void *Thread(void *a) {
- sleep(1);
+ barrier_wait(&barrier);
*(int*)a = 43;
return 0;
}
int main() {
+ barrier_init(&barrier, 2);
static __thread int Var = 42;
pthread_t t;
pthread_create(&t, 0, Thread, &Var);
Var = 43;
+ barrier_wait(&barrier);
pthread_join(t, 0);
}
OpenPOWER on IntegriCloud