summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/malloc_stack.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/malloc_stack.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/malloc_stack.cc')
-rw-r--r--compiler-rt/test/tsan/malloc_stack.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler-rt/test/tsan/malloc_stack.cc b/compiler-rt/test/tsan/malloc_stack.cc
index 6027360754a..ba1d62bcd9e 100644
--- a/compiler-rt/test/tsan/malloc_stack.cc
+++ b/compiler-rt/test/tsan/malloc_stack.cc
@@ -1,20 +1,21 @@
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
-#include <pthread.h>
-#include <unistd.h>
+#include "test.h"
_Atomic(int*) p;
void *thr(void *a) {
- sleep(1);
+ barrier_wait(&barrier);
int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED);
*pp = 42;
return 0;
}
int main() {
+ barrier_init(&barrier, 2);
pthread_t th;
pthread_create(&th, 0, thr, p);
__c11_atomic_store(&p, new int, __ATOMIC_RELAXED);
+ barrier_wait(&barrier);
pthread_join(th, 0);
}
OpenPOWER on IntegriCloud