From 6cbf128b9465ae70d02ea9552fabd9a7ac6c2363 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 4 Dec 2015 10:37:25 -0500 Subject: [PATCH] tests: wait for mocked requests to complete Fixes: #13969 Signed-off-by: Jason Dillaman --- src/test/librbd/mock/MockImageCtx.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index 9ded05dd16c6..1e70b1f27cfc 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -49,11 +49,19 @@ struct MockImageCtx { } ~MockImageCtx() { + wait_for_async_requests(); delete image_watcher; delete op_work_queue; delete aio_work_queue; } + void wait_for_async_requests() { + Mutex::Locker async_ops_locker(async_ops_lock); + while (!async_requests.empty()) { + async_requests_cond.Wait(async_ops_lock); + } + } + MOCK_CONST_METHOD1(get_snap_id, librados::snap_t(std::string in_snap_name)); MOCK_CONST_METHOD1(get_snap_info, const SnapInfo*(librados::snap_t)); MOCK_CONST_METHOD2(get_parent_spec, int(librados::snap_t in_snap_id, -- 2.47.3