tests: get rid of remaining manual critsect usage
This commit is contained in:
1 parent
2c223de2af
commit
c88b1cbf57
1 file changed
+14
-15
+14
-15
@@ -37,8 +37,7 @@ void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2)
|
|||||||
template <typename MutexType>
|
template <typename MutexType>
|
||||||
void TestDoubleLock2(MutexType& m)
|
void TestDoubleLock2(MutexType& m)
|
||||||
{
|
{
|
||||||
ENTER_CRITICAL_SECTION(m);
|
LOCK(m);
|
||||||
LEAVE_CRITICAL_SECTION(m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MutexType>
|
template <typename MutexType>
|
||||||
@@ -48,15 +47,15 @@ void TestDoubleLock(bool should_throw)
|
|||||||
g_debug_lockorder_abort = false;
|
g_debug_lockorder_abort = false;
|
||||||
|
|
||||||
MutexType m;
|
MutexType m;
|
||||||
ENTER_CRITICAL_SECTION(m);
|
{
|
||||||
if (should_throw) {
|
LOCK(m);
|
||||||
BOOST_CHECK_EXCEPTION(TestDoubleLock2(m), std::logic_error,
|
if (should_throw) {
|
||||||
|
BOOST_CHECK_EXCEPTION(TestDoubleLock2(m), std::logic_error,
|
||||||
HasReason("double lock detected"));
|
HasReason("double lock detected"));
|
||||||
} else {
|
} else {
|
||||||
BOOST_CHECK_NO_THROW(TestDoubleLock2(m));
|
BOOST_CHECK_NO_THROW(TestDoubleLock2(m));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LEAVE_CRITICAL_SECTION(m);
|
|
||||||
|
|
||||||
BOOST_CHECK(LockStackEmpty());
|
BOOST_CHECK(LockStackEmpty());
|
||||||
|
|
||||||
g_debug_lockorder_abort = prev;
|
g_debug_lockorder_abort = prev;
|
||||||
@@ -64,15 +63,15 @@ void TestDoubleLock(bool should_throw)
|
|||||||
#endif /* DEBUG_LOCKORDER */
|
#endif /* DEBUG_LOCKORDER */
|
||||||
|
|
||||||
template <typename MutexType>
|
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
|
#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
|
#endif // DEBUG_LOCKORDER
|
||||||
LEAVE_CRITICAL_SECTION(mutex2);
|
}
|
||||||
LEAVE_CRITICAL_SECTION(mutex1);
|
|
||||||
BOOST_CHECK(LockStackEmpty());
|
BOOST_CHECK(LockStackEmpty());
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in new issue
Block a user