diff options
| author | Russell Yanofsky <[email protected]> | 2017-11-08 16:21:13 -0500 |
|---|---|---|
| committer | Russell Yanofsky <[email protected]> | 2018-08-03 07:11:37 -0500 |
| commit | 1382913e61f5db6ba849b1e261e8aefcd5a1ae68 (patch) | |
| tree | 70ee8cc588dfd447f61c5153da75fbc2bc2d62e7 /src/test/sync_tests.cpp | |
| parent | MOVEONLY Move AnnotatedMixin declaration (diff) | |
| download | discoin-1382913e61f5db6ba849b1e261e8aefcd5a1ae68.tar.xz discoin-1382913e61f5db6ba849b1e261e8aefcd5a1ae68.zip | |
Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection
They should also work with any other mutex type which std::unique_lock
supports.
There is no change in behavior for current code that calls these macros with
CCriticalSection mutexes.
Diffstat (limited to 'src/test/sync_tests.cpp')
| -rw-r--r-- | src/test/sync_tests.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/test/sync_tests.cpp b/src/test/sync_tests.cpp index 2e0951c3a..539e2ff3a 100644 --- a/src/test/sync_tests.cpp +++ b/src/test/sync_tests.cpp @@ -7,16 +7,10 @@ #include <boost/test/unit_test.hpp> -BOOST_FIXTURE_TEST_SUITE(sync_tests, BasicTestingSetup) - -BOOST_AUTO_TEST_CASE(potential_deadlock_detected) +namespace { +template <typename MutexType> +void TestPotentialDeadLockDetected(MutexType& mutex1, MutexType& mutex2) { - #ifdef DEBUG_LOCKORDER - bool prev = g_debug_lockorder_abort; - g_debug_lockorder_abort = false; - #endif - - CCriticalSection mutex1, mutex2; { LOCK2(mutex1, mutex2); } @@ -32,6 +26,23 @@ BOOST_AUTO_TEST_CASE(potential_deadlock_detected) #else BOOST_CHECK(!error_thrown); #endif +} +} // namespace + +BOOST_FIXTURE_TEST_SUITE(sync_tests, BasicTestingSetup) + +BOOST_AUTO_TEST_CASE(potential_deadlock_detected) +{ + #ifdef DEBUG_LOCKORDER + bool prev = g_debug_lockorder_abort; + g_debug_lockorder_abort = false; + #endif + + CCriticalSection rmutex1, rmutex2; + TestPotentialDeadLockDetected(rmutex1, rmutex2); + + CWaitableCriticalSection mutex1, mutex2; + TestPotentialDeadLockDetected(mutex1, mutex2); #ifdef DEBUG_LOCKORDER g_debug_lockorder_abort = prev; |