diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2014-02-27 12:05:17 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2014-02-27 12:05:17 +0000 |
commit | 40b9a48567745bccd9b2c745782c46f3a55030d4 (patch) | |
tree | ea884b50390122d963cf6ae7752679389b78be0a /test/tsan/deadlock_detector_stress_test.cc | |
parent | df8360c258258c518292378d0fedea81c2fa3fd3 (diff) |
tsan: 2 more deadlock detector benchmarks
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/deadlock_detector_stress_test.cc')
-rw-r--r-- | test/tsan/deadlock_detector_stress_test.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/tsan/deadlock_detector_stress_test.cc b/test/tsan/deadlock_detector_stress_test.cc index 864d22833..91a804e03 100644 --- a/test/tsan/deadlock_detector_stress_test.cc +++ b/test/tsan/deadlock_detector_stress_test.cc @@ -341,6 +341,54 @@ class LockTest { } } + void Test12() { + if (test_number > 0 && test_number != 12) return; + if (!LockType::supports_read_lock()) return; + fprintf(stderr, "Starting Test12: 4 threads read lock/unlock 4 shared mutexes, one under another\n"); + // CHECK-RD: Starting Test12 + Init(500); + // CHECK-RD-NOT: WARNING: ThreadSanitizer: + RunThreads(&LockTest::Test12_Thread, &LockTest::Test12_Thread, + &LockTest::Test12_Thread, &LockTest::Test12_Thread); + } + void Test12_Thread() { + for (int i = 0; i < iter_count; i++) { + RL(000); + RL(100); + RL(200); + RL(300); + RU(300); + RU(200); + RU(100); + RU(000); + } + } + + void Test13() { + if (test_number > 0 && test_number != 13) return; + if (!LockType::supports_read_lock()) return; + fprintf(stderr, "Starting Test13: 4 threads read lock/unlock 4 shared mutexes, all under another shared mutex\n"); + // CHECK-RD: Starting Test13 + Init(500); + // CHECK-RD-NOT: WARNING: ThreadSanitizer: + RunThreads(&LockTest::Test13_Thread, &LockTest::Test13_Thread, + &LockTest::Test13_Thread, &LockTest::Test13_Thread); + } + void Test13_Thread() { + for (int i = 0; i < iter_count; i++) { + RL(0); + RL(100); + RU(100); + RL(200); + RU(200); + RL(300); + RU(300); + RL(400); + RU(400); + RU(0); + } + } + private: void Lock2(size_t l1, size_t l2) { L(l1); L(l2); U(l2); U(l1); } void Lock_0_1() { Lock2(0, 1); } @@ -416,6 +464,8 @@ int main(int argc, char **argv) { LockTest().Test9(); LockTest().Test10(); LockTest().Test11(); + LockTest().Test12(); + LockTest().Test13(); fprintf(stderr, "ALL-DONE\n"); // CHECK: ALL-DONE } |