diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2015-01-21 13:50:02 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2015-01-21 13:50:02 +0000 |
commit | 12de706f2fd387981e5925a1e42207934613660f (patch) | |
tree | 283f74c94ee89994c1ed8bf052ae7da7d2f8dec7 /test/tsan/vptr_harmful_race3.cc | |
parent | 18422b49071ba5ea813d1b065458d6b81c6ef115 (diff) |
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
Diffstat (limited to 'test/tsan/vptr_harmful_race3.cc')
-rw-r--r-- | test/tsan/vptr_harmful_race3.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/vptr_harmful_race3.cc b/test/tsan/vptr_harmful_race3.cc index ac6ea94e5..3810a1068 100644 --- a/test/tsan/vptr_harmful_race3.cc +++ b/test/tsan/vptr_harmful_race3.cc @@ -1,8 +1,6 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include <pthread.h> +#include "test.h" #include <semaphore.h> -#include <stdio.h> -#include <unistd.h> struct A { A() { @@ -30,18 +28,20 @@ static A *obj = new B; static void (A::*fn)() = &A::F; void *Thread1(void *x) { - sleep(1); (obj->*fn)(); + 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); |