mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 06:04:42 +02:00
test: [refactor] Properly use BOOST_CHECK_EXCEPTION
This commit is contained in:
@@ -18,19 +18,14 @@ void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2)
|
||||
LOCK2(mutex1, mutex2);
|
||||
}
|
||||
BOOST_CHECK(LockStackEmpty());
|
||||
bool error_thrown = false;
|
||||
try {
|
||||
{
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
BOOST_CHECK_EXCEPTION(LOCK2(mutex2, mutex1), std::logic_error, HasReason{"potential deadlock detected: mutex1 -> mutex2 -> mutex1"});
|
||||
#else
|
||||
LOCK2(mutex2, mutex1);
|
||||
} catch (const std::logic_error& e) {
|
||||
BOOST_CHECK_EQUAL(e.what(), "potential deadlock detected: mutex1 -> mutex2 -> mutex1");
|
||||
error_thrown = true;
|
||||
#endif
|
||||
}
|
||||
BOOST_CHECK(LockStackEmpty());
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
BOOST_CHECK(error_thrown);
|
||||
#else
|
||||
BOOST_CHECK(!error_thrown);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOCKORDER
|
||||
|
||||
Reference in New Issue
Block a user