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/vptr_harmful_race2.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/tsan/vptr_harmful_race2.cc') diff --git a/test/tsan/vptr_harmful_race2.cc b/test/tsan/vptr_harmful_race2.cc index aa53bbb90..a56b74c09 100644 --- a/test/tsan/vptr_harmful_race2.cc +++ b/test/tsan/vptr_harmful_race2.cc @@ -1,8 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include +#include "test.h" #include -#include -#include struct A { A() { @@ -29,18 +27,20 @@ struct B : A { static A *obj = new B; void *Thread1(void *x) { - sleep(1); obj->F(); + barrier_wait(&barrier); obj->Done(); return NULL; } void *Thread2(void *x) { + barrier_wait(&barrier); delete obj; return NULL; } int main() { + barrier_init(&barrier, 2); pthread_t t[2]; pthread_create(&t[0], NULL, Thread1, NULL); pthread_create(&t[1], NULL, Thread2, NULL); -- cgit v1.2.3