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/global_race2.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'test/tsan/global_race2.cc') diff --git a/test/tsan/global_race2.cc b/test/tsan/global_race2.cc index ac994cc0f..6631008d8 100644 --- a/test/tsan/global_race2.cc +++ b/test/tsan/global_race2.cc @@ -1,24 +1,23 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include -#include -#include -#include +#include "test.h" int x; void *Thread(void *a) { - sleep(1); + barrier_wait(&barrier); x = 1; return 0; } int main() { + barrier_init(&barrier, 2); // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "addr2=0x%012lx\n", (unsigned long) &x); pthread_t t; pthread_create(&t, 0, Thread, 0); x = 0; + barrier_wait(&barrier); pthread_join(t, 0); } -- cgit v1.2.3