From 30f297241205023b5fbac27ab307989fe3938405 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 12 Apr 2018 15:34:36 +0200 Subject: [PATCH] make lock test pass on macOS --- pdns/test-lock_hh.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pdns/test-lock_hh.cc b/pdns/test-lock_hh.cc index 707dcc183c..7f73d5e455 100644 --- a/pdns/test-lock_hh.cc +++ b/pdns/test-lock_hh.cc @@ -41,8 +41,17 @@ BOOST_AUTO_TEST_CASE(test_pdns_lock) for(auto& pp : g_locks) wlocks.emplace_back(&*pp); - TryReadLock trl(&*g_locks[0]); - BOOST_CHECK(!trl.gotIt()); + // on macOS, this TryReadLock throws (EDEADLK) instead of simply failing + // so we catch the exception and consider that success for this test + bool gotit = false; + try { + TryReadLock trl(&*g_locks[0]); + gotit = trl.gotIt(); + } + catch(const PDNSException &e) { + gotit = false; + } + BOOST_CHECK(!gotit); wlocks.clear(); TryReadLock trl2(&*g_locks[0]); -- 2.47.2