summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/tsan/stack_sync_reuse.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/stack_sync_reuse.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/stack_sync_reuse.cc')
-rw-r--r--compiler-rt/test/tsan/stack_sync_reuse.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler-rt/test/tsan/stack_sync_reuse.cc b/compiler-rt/test/tsan/stack_sync_reuse.cc
index b1d5619df27..5ea9e84b085 100644
--- a/compiler-rt/test/tsan/stack_sync_reuse.cc
+++ b/compiler-rt/test/tsan/stack_sync_reuse.cc
@@ -1,8 +1,5 @@
// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include "test.h"
// Test case https://code.google.com/p/thread-sanitizer/issues/detail?id=87
// Tsan sees false HB edge on address pointed to by syncp variable.
@@ -26,7 +23,7 @@ long sink;
void *Thread(void *x) {
while (__atomic_load_n(&syncp, __ATOMIC_ACQUIRE) == 0)
- usleep(1000);
+ usleep(1000); // spin wait
global = 42;
__atomic_store_n(syncp, 1, __ATOMIC_RELEASE);
__atomic_store_n(&syncp, 0, __ATOMIC_RELAXED);
@@ -39,7 +36,7 @@ void __attribute__((noinline)) foobar() {
__atomic_store_n(&s, 0, __ATOMIC_RELAXED);
__atomic_store_n(&syncp, &s, __ATOMIC_RELEASE);
while (__atomic_load_n(&syncp, __ATOMIC_RELAXED) != 0)
- usleep(1000);
+ usleep(1000); // spin wait
}
void __attribute__((noinline)) barfoo() {
OpenPOWER on IntegriCloud