[PATCH] D18476: [tsan] Remove long sleeps from fork tests

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 09:59:16 PDT 2016


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, kcc, glider, samsonov.
kubabrecka added subscribers: llvm-commits, zaks.anna, dcoughlin.

On one of our testing machines, we're running the tests under heavy load, and especially in the fork-based TSan tests, we're seeing timeouts when a test uses `sleep(10)`, assuming that calling fork() on another thread will finish sooner than that.

This patch removes the timeouts.  I'm not sure if there is a better way, especially since these timeouts are supposed to catch deadlocks, and removing them might not be a good idea.  Dmitry, if you have a better solution, please suggest.

http://reviews.llvm.org/D18476

Files:
  test/tsan/fork_deadlock.cc
  test/tsan/fork_multithreaded.cc

Index: test/tsan/fork_multithreaded.cc
===================================================================
--- test/tsan/fork_multithreaded.cc
+++ test/tsan/fork_multithreaded.cc
@@ -6,7 +6,10 @@
 #include <sys/wait.h>
 
 static void *sleeper(void *p) {
-  sleep(10);  // not intended to exit during test
+  // not intended to exit during test
+  for (;;) {
+    sched_yield();
+  }
   return 0;
 }
 
Index: test/tsan/fork_deadlock.cc
===================================================================
--- test/tsan/fork_deadlock.cc
+++ test/tsan/fork_deadlock.cc
@@ -12,18 +12,10 @@
   return 0;
 }
 
-static void *watchdog(void *p) {
-  sleep(100);  // is not intended to exit
-  fprintf(stderr, "timed out after 100 seconds\n");
-  exit(1);
-  return 0;
-}
-
 int main() {
   barrier_init(&barrier, 2);
-  pthread_t th1, th2;
+  pthread_t th1;
   pthread_create(&th1, 0, incrementer, 0);
-  pthread_create(&th2, 0, watchdog, 0);
   for (int i = 0; i < 10; i++) {
     switch (fork()) {
     default:  // parent


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18476.51646.patch
Type: text/x-patch
Size: 1015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160325/79cacafd/attachment.bin>


More information about the llvm-commits mailing list