diff --git a/src/test/sync_tests.cpp b/src/test/sync_tests.cpp index 0576bf1633f..dcd1b1ce367 100644 --- a/src/test/sync_tests.cpp +++ b/src/test/sync_tests.cpp @@ -37,8 +37,7 @@ void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2) template void TestDoubleLock2(MutexType& m) { - ENTER_CRITICAL_SECTION(m); - LEAVE_CRITICAL_SECTION(m); + LOCK(m); } template @@ -48,15 +47,15 @@ void TestDoubleLock(bool should_throw) g_debug_lockorder_abort = false; MutexType m; - ENTER_CRITICAL_SECTION(m); - if (should_throw) { - BOOST_CHECK_EXCEPTION(TestDoubleLock2(m), std::logic_error, + { + LOCK(m); + if (should_throw) { + BOOST_CHECK_EXCEPTION(TestDoubleLock2(m), std::logic_error, HasReason("double lock detected")); - } else { - BOOST_CHECK_NO_THROW(TestDoubleLock2(m)); + } else { + BOOST_CHECK_NO_THROW(TestDoubleLock2(m)); + } } - LEAVE_CRITICAL_SECTION(m); - BOOST_CHECK(LockStackEmpty()); g_debug_lockorder_abort = prev; @@ -64,15 +63,15 @@ void TestDoubleLock(bool should_throw) #endif /* DEBUG_LOCKORDER */ template -void TestInconsistentLockOrderDetected(MutexType& mutex1, MutexType& mutex2) NO_THREAD_SAFETY_ANALYSIS +void TestInconsistentLockOrderDetected(MutexType& mutex1, MutexType& mutex2) { - ENTER_CRITICAL_SECTION(mutex1); - ENTER_CRITICAL_SECTION(mutex2); + { + WAIT_LOCK(mutex1, lock1); + LOCK(mutex2); #ifdef DEBUG_LOCKORDER - BOOST_CHECK_EXCEPTION(LEAVE_CRITICAL_SECTION(mutex1), std::logic_error, HasReason("mutex1 was not most recent critical section locked")); + BOOST_CHECK_EXCEPTION(REVERSE_LOCK(lock1, mutex1), std::logic_error, HasReason("mutex1 was not most recent critical section locked")); #endif // DEBUG_LOCKORDER - LEAVE_CRITICAL_SECTION(mutex2); - LEAVE_CRITICAL_SECTION(mutex1); + } BOOST_CHECK(LockStackEmpty()); } } // namespace