[compiler-rt] r204119 - tsan: fix flaky test
Dmitry Vyukov
dvyukov at google.com
Mon Mar 17 23:37:31 PDT 2014
Author: dvyukov
Date: Tue Mar 18 01:37:31 2014
New Revision: 204119
URL: http://llvm.org/viewvc/llvm-project?rev=204119&view=rev
Log:
tsan: fix flaky test
Modified:
compiler-rt/trunk/test/tsan/SharedLibs/load_shared_lib-so.cc
compiler-rt/trunk/test/tsan/load_shared_lib.cc
Modified: compiler-rt/trunk/test/tsan/SharedLibs/load_shared_lib-so.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/SharedLibs/load_shared_lib-so.cc?rev=204119&r1=204118&r2=204119&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/SharedLibs/load_shared_lib-so.cc (original)
+++ compiler-rt/trunk/test/tsan/SharedLibs/load_shared_lib-so.cc Tue Mar 18 01:37:31 2014
@@ -12,11 +12,14 @@
//===----------------------------------------------------------------------===//
#include <stddef.h>
+#include <unistd.h>
int GLOB_SHARED = 0;
extern "C"
void *write_from_so(void *unused) {
+ if (unused)
+ sleep(1);
GLOB_SHARED++;
return NULL;
}
Modified: compiler-rt/trunk/test/tsan/load_shared_lib.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/load_shared_lib.cc?rev=204119&r1=204118&r2=204119&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/load_shared_lib.cc (original)
+++ compiler-rt/trunk/test/tsan/load_shared_lib.cc Tue Mar 18 01:37:31 2014
@@ -9,19 +9,23 @@
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
+#include <stddef.h>
+#include <unistd.h>
#include <string>
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);
More information about the llvm-commits
mailing list