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/mop_with_offset.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/mop_with_offset.cc')
-rw-r--r-- | test/tsan/mop_with_offset.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/test/tsan/mop_with_offset.cc b/test/tsan/mop_with_offset.cc index e44c78b7d..c67e81e09 100644 --- a/test/tsan/mop_with_offset.cc +++ b/test/tsan/mop_with_offset.cc @@ -1,23 +1,22 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include <pthread.h> -#include <stddef.h> -#include <stdio.h> -#include <unistd.h> +#include "test.h" void *Thread1(void *x) { int *p = (int*)x; p[0] = 1; + barrier_wait(&barrier); return NULL; } void *Thread2(void *x) { - sleep(1); + barrier_wait(&barrier); char *p = (char*)x; p[2] = 1; return NULL; } int main() { + barrier_init(&barrier, 2); int *data = new int(42); fprintf(stderr, "ptr1=%p\n", data); fprintf(stderr, "ptr2=%p\n", (char*)data + 2); |