[compiler-rt] r204036 - [sanitizer] one more output test for the deadlock detector

Kostya Serebryany kcc at google.com
Mon Mar 17 02:32:48 PDT 2014


Author: kcc
Date: Mon Mar 17 04:32:48 2014
New Revision: 204036

URL: http://llvm.org/viewvc/llvm-project?rev=204036&view=rev
Log:
[sanitizer] one more output test for the deadlock detector

Modified:
    compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc

Modified: compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc?rev=204036&r1=204035&r2=204036&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc (original)
+++ compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc Mon Mar 17 04:32:48 2014
@@ -417,9 +417,9 @@ class LockTest {
     fprintf(stderr, "Starting Test16: detailed output test with two locks\n");
     // CHECK: Starting Test16
     // CHECK: WARNING: ThreadSanitizer: lock-order-inversion
-    // CHECK: LockTest::Acquire_1
+    // CHECK: LockTest::Acquire1
     // CHECK-NEXT: LockTest::Acquire_0_then_1
-    // CHECK: LockTest::Acquire_0
+    // CHECK: LockTest::Acquire0
     // CHECK-NEXT: LockTest::Acquire_1_then_0
     Init(5);
     Acquire_0_then_1();
@@ -428,17 +428,35 @@ class LockTest {
     U(0); U(1);
   }
 
-  __attribute__((noinline)) void Acquire_1() { L(1); }
-  __attribute__((noinline)) void Acquire_0() { L(0); }
-  __attribute__((noinline)) void Acquire_1_then_0() {
-    Acquire_1();
-    Acquire_0();
-  }
-  __attribute__((noinline)) void Acquire_0_then_1() {
-    Acquire_0();
-    Acquire_1();
+  // More detailed output test.
+  void Test17() {
+    if (test_number > 0 && test_number != 17) return;
+    fprintf(stderr, "Starting Test17: detailed output test with three locks\n");
+    // CHECK: Starting Test17
+    // CHECK: WARNING: ThreadSanitizer: lock-order-inversion
+    // CHECK: LockTest::Acquire1
+    // CHECK-NEXT: LockTest::Acquire_0_then_1
+    // CHECK: LockTest::Acquire2
+    // CHECK-NEXT: LockTest::Acquire_1_then_2
+    // CHECK: LockTest::Acquire0
+    // CHECK-NEXT: LockTest::Acquire_2_then_0
+    Init(5);
+    Acquire_0_then_1();
+    U(0); U(1);
+    Acquire_1_then_2();
+    U(1); U(2);
+    Acquire_2_then_0();
+    U(0); U(2);
   }
 
+  __attribute__((noinline)) void Acquire2() { L(2); }
+  __attribute__((noinline)) void Acquire1() { L(1); }
+  __attribute__((noinline)) void Acquire0() { L(0); }
+  __attribute__((noinline)) void Acquire_1_then_0() { Acquire1(); Acquire0(); }
+  __attribute__((noinline)) void Acquire_0_then_1() { Acquire0(); Acquire1(); }
+  __attribute__((noinline)) void Acquire_1_then_2() { Acquire1(); Acquire2(); }
+  __attribute__((noinline)) void Acquire_2_then_0() { Acquire2(); Acquire0(); }
+
  private:
   void Lock2(size_t l1, size_t l2) { L(l1); L(l2); U(l2); U(l1); }
   void Lock_0_1() { Lock2(0, 1); }
@@ -527,6 +545,7 @@ int main(int argc, char **argv) {
   LockTest().Test14();
   LockTest().Test15();
   LockTest().Test16();
+  LockTest().Test17();
   fprintf(stderr, "ALL-DONE\n");
   // CHECK: ALL-DONE
 }





More information about the llvm-commits mailing list