summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2014-02-24 11:45:47 +0000
committerKostya Serebryany <kcc@google.com>2014-02-24 11:45:47 +0000
commit8201b388fa2d5ac929edf7fd99e7225021571b0f (patch)
tree7185f441126b1b6212964fdc4ae8b4cf600e0b12 /test
parent48cb832dff852b16847c089465a2922699ef26bd (diff)
[tsan] one more test for deadlock detector
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/tsan/deadlock_detector_stress_test.cc31
1 files changed, 26 insertions, 5 deletions
diff --git a/test/tsan/deadlock_detector_stress_test.cc b/test/tsan/deadlock_detector_stress_test.cc
index 74dafe84b..95812df02 100644
--- a/test/tsan/deadlock_detector_stress_test.cc
+++ b/test/tsan/deadlock_detector_stress_test.cc
@@ -106,10 +106,29 @@ class LockTest {
// CHECK-NOT: WARNING: ThreadSanitizer:
}
+ void Test6() {
+ fprintf(stderr, "Starting Test6\n");
+ // CHECK: Starting Test6
+ // CHECK-NOT: WARNING: ThreadSanitizer:
+ RunThreads(&LockTest::Lock1_Loop_0, &LockTest::Lock1_Loop_1,
+ &LockTest::Lock1_Loop_2);
+ }
+
private:
void Lock2(size_t l1, size_t l2) { L(l1); L(l2); U(l2); U(l1); }
void Lock_0_1() { Lock2(0, 1); }
void Lock_1_0() { Lock2(1, 0); }
+ void Lock1_Loop(size_t i, size_t n_iter) {
+ for (size_t it = 0; it < n_iter; it++) {
+ // if ((it & (it - 1)) == 0) fprintf(stderr, "%zd", i);
+ L(i);
+ U(i);
+ }
+ // fprintf(stderr, "\n");
+ }
+ void Lock1_Loop_0() { Lock1_Loop(0, 100000); }
+ void Lock1_Loop_1() { Lock1_Loop(1, 100000); }
+ void Lock1_Loop_2() { Lock1_Loop(2, 100000); }
void CreateAndDestroyManyLocks() {
PaddedLock create_many_locks_but_never_acquire[kDeadlockGraphSize];
@@ -135,13 +154,14 @@ class LockTest {
return NULL;
}
- void RunThreads(void (LockTest::*f1)(), void (LockTest::*f2)()) {
- const int kNumThreads = 2;
+ void RunThreads(void (LockTest::*f1)(), void (LockTest::*f2)(),
+ void (LockTest::*f3)() = 0) {
+ const int kNumThreads = 3;
pthread_t t[kNumThreads];
- CB cb[2] = {{f1, this}, {f2, this}};
- for (int i = 0; i < kNumThreads; i++)
+ CB cb[kNumThreads] = {{f1, this}, {f2, this}, {f3, this}};
+ for (int i = 0; i < kNumThreads && cb[i].f; i++)
pthread_create(&t[i], 0, Thread, &cb[i]);
- for (int i = 0; i < kNumThreads; i++)
+ for (int i = 0; i < kNumThreads && cb[i].f; i++)
pthread_join(t[i], 0);
}
@@ -156,6 +176,7 @@ int main() {
{ LockTest t(5); t.Test3(); }
{ LockTest t(5); t.Test4(); }
{ LockTest t(5); t.Test5(); }
+ { LockTest t(5); t.Test6(); }
fprintf(stderr, "DONE\n");
// CHECK: DONE
}