8#include <boost/test/unit_test.hpp>
14template <
typename MutexType>
15void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2)
18 LOCK2(mutex1, mutex2);
25 LOCK2(mutex2, mutex1);
32template <
typename MutexType>
33void TestDoubleLock2(MutexType& m)
38template <
typename MutexType>
39void TestDoubleLock(
bool should_throw)
41 const bool prev = g_debug_lockorder_abort;
42 g_debug_lockorder_abort =
false;
56 g_debug_lockorder_abort = prev;
60template <
typename MutexType>
61void TestInconsistentLockOrderDetected(MutexType& mutex1, MutexType& mutex2)
74BOOST_AUTO_TEST_SUITE(sync_tests)
78 #ifdef DEBUG_LOCKORDER
79 bool prev = g_debug_lockorder_abort;
80 g_debug_lockorder_abort =
false;
84 TestPotentialDeadLockDetected(rmutex1, rmutex2);
86 TestPotentialDeadLockDetected(rmutex1, rmutex2);
89 TestPotentialDeadLockDetected(mutex1, mutex2);
91 TestPotentialDeadLockDetected(mutex1, mutex2);
93 #ifdef DEBUG_LOCKORDER
94 g_debug_lockorder_abort = prev;
101#ifdef DEBUG_LOCKORDER
104 TestDoubleLock<Mutex>(
true);
109 TestDoubleLock<RecursiveMutex>(
false);
115#ifdef DEBUG_LOCKORDER
116 bool prev = g_debug_lockorder_abort;
117 g_debug_lockorder_abort =
false;
121 TestInconsistentLockOrderDetected(rmutex1, rmutex2);
124 TestInconsistentLockOrderDetected(rmutex1, rmutex2);
126 Mutex mutex1, mutex2;
127 TestInconsistentLockOrderDetected(mutex1, mutex2);
130 TestInconsistentLockOrderDetected(mutex1, mutex2);
132#ifdef DEBUG_LOCKORDER
133 g_debug_lockorder_abort = prev;
BOOST_CHECK_EXCEPTION predicates to check the specific validation error.
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EXCEPTION(HTTPHeaders{}.Read(reader), std::runtime_error, HasReason{"Empty HTTP header name"})
#define BOOST_CHECK_NO_THROW(stmt)
#define BOOST_CHECK(expr)
#define WAIT_LOCK(cs, name)
#define REVERSE_LOCK(g, cs)
BOOST_AUTO_TEST_CASE(potential_deadlock_detected)