From 12de706f2fd387981e5925a1e42207934613660f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 21 Jan 2015 13:50:02 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226659 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tsan/mutexset6.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/tsan/mutexset6.cc') diff --git a/test/tsan/mutexset6.cc b/test/tsan/mutexset6.cc index 07dcc0a73..f4251db69 100644 --- a/test/tsan/mutexset6.cc +++ b/test/tsan/mutexset6.cc @@ -1,7 +1,5 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include -#include -#include +#include "test.h" int Global; pthread_mutex_t mtx1; @@ -9,7 +7,7 @@ pthread_spinlock_t mtx2; pthread_rwlock_t mtx3; void *Thread1(void *x) { - sleep(1); + barrier_wait(&barrier); pthread_mutex_lock(&mtx1); Global++; pthread_mutex_unlock(&mtx1); @@ -24,10 +22,12 @@ void *Thread2(void *x) { Global--; pthread_spin_unlock(&mtx2); pthread_rwlock_unlock(&mtx3); + barrier_wait(&barrier); return NULL; } int main() { + barrier_init(&barrier, 2); // CHECK: WARNING: ThreadSanitizer: data race // CHECK: Write of size 4 at {{.*}} by thread T1 // CHECK: (mutexes: write [[M1:M[0-9]+]]): -- cgit v1.2.3