From 1d4d4c8bf4ff415c29d7dac6f947a258e429e995 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 9 Mar 2016 21:10:50 -0500 Subject: [PATCH] test: move get_mock_io_ctx helper method to common location Signed-off-by: Jason Dillaman --- src/test/librados_test_stub/LibradosTestStub.cc | 10 ++++++++++ src/test/librados_test_stub/LibradosTestStub.h | 4 ++++ src/test/librbd/test_mock_fixture.cc | 8 -------- src/test/librbd/test_mock_fixture.h | 2 +- src/test/rbd_mirror/test_mock_fixture.cc | 7 ------- src/test/rbd_mirror/test_mock_fixture.h | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index 8df054775d0d0..ad6b395199a24 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -66,6 +66,16 @@ void do_out_buffer(string& outbl, char **outbuf, size_t *outbuflen) { } // anonymous namespace +namespace librados { + +MockTestMemIoCtxImpl &get_mock_io_ctx(IoCtx &ioctx) { + MockTestMemIoCtxImpl **mock = + reinterpret_cast(&ioctx); + return **mock; +} + +} + namespace librados_test_stub { TestRadosClientPtr *rados_client() { diff --git a/src/test/librados_test_stub/LibradosTestStub.h b/src/test/librados_test_stub/LibradosTestStub.h index 9fed68df24b28..4432ec30e5c4f 100644 --- a/src/test/librados_test_stub/LibradosTestStub.h +++ b/src/test/librados_test_stub/LibradosTestStub.h @@ -7,7 +7,11 @@ #include namespace librados { +class IoCtx; class TestRadosClient; +class MockTestMemIoCtxImpl; + +MockTestMemIoCtxImpl &get_mock_io_ctx(IoCtx &ioctx); } namespace librados_test_stub { diff --git a/src/test/librbd/test_mock_fixture.cc b/src/test/librbd/test_mock_fixture.cc index cbd621b4c0de5..4cc940cad47d3 100644 --- a/src/test/librbd/test_mock_fixture.cc +++ b/src/test/librbd/test_mock_fixture.cc @@ -68,14 +68,6 @@ void TestMockFixture::expect_op_work_queue(librbd::MockImageCtx &mock_image_ctx) mock_image_ctx.image_ctx->op_work_queue)); } -librados::MockTestMemIoCtxImpl &TestMockFixture::get_mock_io_ctx( - librados::IoCtx &ioctx) { - // TODO become friend of IoCtx so that we can cleanly extract io_ctx_impl - librados::MockTestMemIoCtxImpl **mock = - reinterpret_cast(&ioctx); - return **mock; -} - void TestMockFixture::initialize_features(librbd::ImageCtx *ictx, librbd::MockImageCtx &mock_image_ctx, librbd::MockExclusiveLock &mock_exclusive_lock, diff --git a/src/test/librbd/test_mock_fixture.h b/src/test/librbd/test_mock_fixture.h index ce3e6d5abb176..bd5a2ac84c686 100644 --- a/src/test/librbd/test_mock_fixture.h +++ b/src/test/librbd/test_mock_fixture.h @@ -6,6 +6,7 @@ #include "test/librbd/test_fixture.h" #include "test/librbd/mock/MockImageCtx.h" +#include "test/librados_test_stub/LibradosTestStub.h" #include "common/WorkQueue.h" #include #include @@ -69,7 +70,6 @@ public: ::testing::NiceMock &get_mock_rados_client() { return *s_mock_rados_client; } - librados::MockTestMemIoCtxImpl &get_mock_io_ctx(librados::IoCtx &ioctx); void expect_op_work_queue(librbd::MockImageCtx &mock_image_ctx); void expect_unlock_exclusive_lock(librbd::ImageCtx &ictx); diff --git a/src/test/rbd_mirror/test_mock_fixture.cc b/src/test/rbd_mirror/test_mock_fixture.cc index e64297bb3bec3..0863c40b909da 100644 --- a/src/test/rbd_mirror/test_mock_fixture.cc +++ b/src/test/rbd_mirror/test_mock_fixture.cc @@ -41,13 +41,6 @@ void TestMockFixture::TearDown() { s_mock_rados_client->default_to_dispatch(); } -librados::MockTestMemIoCtxImpl &TestMockFixture::get_mock_io_ctx( - librados::IoCtx &ioctx) { - librados::MockTestMemIoCtxImpl **mock = - reinterpret_cast(&ioctx); - return **mock; -} - } // namespace mirror } // namespace rbd diff --git a/src/test/rbd_mirror/test_mock_fixture.h b/src/test/rbd_mirror/test_mock_fixture.h index 1609c945f805a..2231095936b13 100644 --- a/src/test/rbd_mirror/test_mock_fixture.h +++ b/src/test/rbd_mirror/test_mock_fixture.h @@ -5,6 +5,7 @@ #define CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H #include "test/rbd_mirror/test_fixture.h" +#include "test/librados_test_stub/LibradosTestStub.h" #include #include @@ -34,7 +35,6 @@ public: ::testing::NiceMock &get_mock_rados_client() { return *s_mock_rados_client; } - librados::MockTestMemIoCtxImpl &get_mock_io_ctx(librados::IoCtx &ioctx); private: static TestRadosClientPtr s_test_rados_client; -- 2.39.5