[llvm-commits] [compiler-rt] r164488 - /compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc

Alexey Samsonov samsonov at google.com
Mon Sep 24 06:35:46 PDT 2012


Author: samsonov
Date: Mon Sep 24 08:35:46 2012
New Revision: 164488

URL: http://llvm.org/viewvc/llvm-project?rev=164488&view=rev
Log:
[TSan] one more attempt to fix sleep_sync test: call sleep in the spawned thread so that sleep-synchronization will be detected even if child thread is started late.

Modified:
    compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc

Modified: compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc?rev=164488&r1=164487&r2=164488&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/sleep_sync.cc Mon Sep 24 08:35:46 2012
@@ -1,23 +1,22 @@
-// FIXME: Understand why this test fails if TSan is re-execed.
 // RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
 #include <pthread.h>
 #include <unistd.h>
 
 int X = 0;
 
+void MySleep() {
+  usleep(50*1000);
+}
+
 void *Thread(void *p) {
+  MySleep();  // Assume the main thread has done the write.
   X = 42;
   return 0;
 }
 
-void MySleep() {
-  usleep(300*1000);
-}
-
 int main() {
   pthread_t t;
   pthread_create(&t, 0, Thread, 0);
-  MySleep();  // Assume the thread has done the write.
   X = 43;
   pthread_join(t, 0);
   return 0;
@@ -28,4 +27,4 @@
 // CHECK:   As if synchronized via sleep:
 // CHECK-NEXT:     #0 usleep
 // CHECK-NEXT:     #1 MySleep
-// CHECK-NEXT:     #2 main
+// CHECK-NEXT:     #2 Thread





More information about the llvm-commits mailing list