mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
tests: get rid of remaining manual critsect usage
This commit is contained in:
@@ -37,8 +37,7 @@ void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2)
|
||||
template <typename MutexType>
|
||||
void TestDoubleLock2(MutexType& m)
|
||||
{
|
||||
ENTER_CRITICAL_SECTION(m);
|
||||
LEAVE_CRITICAL_SECTION(m);
|
||||
LOCK(m);
|
||||
}
|
||||
|
||||
template <typename MutexType>
|
||||
@@ -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 <typename MutexType>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user