From eac8cc7a42c5469a9af154b10f0fc19e57744656 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 18 Mar 2014 06:37:31 +0000 Subject: [PATCH] tsan: fix flaky test llvm-svn: 204119 --- compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc | 3 +++ compiler-rt/test/tsan/load_shared_lib.cc | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc b/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc index d05aa6a40d18..f449fe97a151 100644 --- a/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc +++ b/compiler-rt/test/tsan/SharedLibs/load_shared_lib-so.cc @@ -12,11 +12,14 @@ //===----------------------------------------------------------------------===// #include +#include int GLOB_SHARED = 0; extern "C" void *write_from_so(void *unused) { + if (unused) + sleep(1); GLOB_SHARED++; return NULL; } diff --git a/compiler-rt/test/tsan/load_shared_lib.cc b/compiler-rt/test/tsan/load_shared_lib.cc index d60cd5700a8a..5b6b72b6edb3 100644 --- a/compiler-rt/test/tsan/load_shared_lib.cc +++ b/compiler-rt/test/tsan/load_shared_lib.cc @@ -9,19 +9,23 @@ #include #include #include +#include +#include #include int GLOB = 0; void *write_glob(void *unused) { + if (unused) + sleep(1); GLOB++; return NULL; } void race_two_threads(void *(*access_callback)(void *unused)) { pthread_t t1, t2; - pthread_create(&t1, NULL, access_callback, NULL); + pthread_create(&t1, NULL, access_callback, (void*)1); pthread_create(&t2, NULL, access_callback, NULL); pthread_join(t1, NULL); pthread_join(t2, NULL);