]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: ensure unique template specializations per test case 9990/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 28 Jun 2016 19:18:51 +0000 (15:18 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 28 Jun 2016 19:18:51 +0000 (15:18 -0400)
With optimizations disabled, there can be cross translation unit
symbol leaking that is not present when inlining is enabled.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/image_sync/test_mock_ImageCopyRequest.cc
src/test/rbd_mirror/image_sync/test_mock_ObjectCopyRequest.cc
src/test/rbd_mirror/image_sync/test_mock_SnapshotCopyRequest.cc
src/test/rbd_mirror/image_sync/test_mock_SnapshotCreateRequest.cc
src/test/rbd_mirror/image_sync/test_mock_SyncPointCreateRequest.cc
src/test/rbd_mirror/image_sync/test_mock_SyncPointPruneRequest.cc
src/test/rbd_mirror/test_mock_ImageSync.cc
src/test/rbd_mirror/test_mock_ImageSyncThrottler.cc

index 3d0855f31af72d0bf3b79848c8e521561d862ff2..d924a3cab287269895c944fb05b1a0b33cf03f5e 100644 (file)
 #include <boost/scope_exit.hpp>
 
 namespace librbd {
+
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+
 namespace journal {
 
 template <>
-struct TypeTraits<librbd::MockImageCtx> {
+struct TypeTraits<librbd::MockTestImageCtx> {
   typedef ::journal::MockJournaler Journaler;
 };
 
@@ -31,11 +42,11 @@ namespace mirror {
 namespace image_sync {
 
 template <>
-struct ObjectCopyRequest<librbd::MockImageCtx> {
+struct ObjectCopyRequest<librbd::MockTestImageCtx> {
   static ObjectCopyRequest* s_instance;
-  static ObjectCopyRequest* create(librbd::MockImageCtx *local_image_ctx,
-                                   librbd::MockImageCtx *remote_image_ctx,
-                                   const ImageCopyRequest<librbd::MockImageCtx>::SnapMap *snap_map,
+  static ObjectCopyRequest* create(librbd::MockTestImageCtx *local_image_ctx,
+                                   librbd::MockTestImageCtx *remote_image_ctx,
+                                   const ImageCopyRequest<librbd::MockTestImageCtx>::SnapMap *snap_map,
                                    uint64_t object_number, Context *on_finish) {
     assert(s_instance != nullptr);
     Mutex::Locker locker(s_instance->lock);
@@ -50,7 +61,7 @@ struct ObjectCopyRequest<librbd::MockImageCtx> {
   Mutex lock;
   Cond cond;
 
-  const ImageCopyRequest<librbd::MockImageCtx>::SnapMap *snap_map = nullptr;
+  const ImageCopyRequest<librbd::MockTestImageCtx>::SnapMap *snap_map = nullptr;
   std::map<uint64_t, Context *> object_contexts;
 
   ObjectCopyRequest() : lock("lock") {
@@ -58,7 +69,7 @@ struct ObjectCopyRequest<librbd::MockImageCtx> {
   }
 };
 
-ObjectCopyRequest<librbd::MockImageCtx>* ObjectCopyRequest<librbd::MockImageCtx>::s_instance = nullptr;
+ObjectCopyRequest<librbd::MockTestImageCtx>* ObjectCopyRequest<librbd::MockTestImageCtx>::s_instance = nullptr;
 
 } // namespace image_sync
 } // namespace mirror
@@ -66,7 +77,7 @@ ObjectCopyRequest<librbd::MockImageCtx>* ObjectCopyRequest<librbd::MockImageCtx>
 
 // template definitions
 #include "tools/rbd_mirror/image_sync/ImageCopyRequest.cc"
-template class rbd::mirror::image_sync::ImageCopyRequest<librbd::MockImageCtx>;
+template class rbd::mirror::image_sync::ImageCopyRequest<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -81,8 +92,8 @@ using ::testing::InvokeWithoutArgs;
 
 class TestMockImageSyncImageCopyRequest : public TestMockFixture {
 public:
-  typedef ImageCopyRequest<librbd::MockImageCtx> MockImageCopyRequest;
-  typedef ObjectCopyRequest<librbd::MockImageCtx> MockObjectCopyRequest;
+  typedef ImageCopyRequest<librbd::MockTestImageCtx> MockImageCopyRequest;
+  typedef ObjectCopyRequest<librbd::MockTestImageCtx> MockObjectCopyRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -95,7 +106,7 @@ public:
     ASSERT_EQ(0, open_image(m_local_io_ctx, m_image_name, &m_local_image_ctx));
   }
 
-  void expect_get_snap_id(librbd::MockImageCtx &mock_image_ctx) {
+  void expect_get_snap_id(librbd::MockTestImageCtx &mock_image_ctx) {
     EXPECT_CALL(mock_image_ctx, get_snap_id(_))
       .WillRepeatedly(Invoke([&mock_image_ctx](std::string snap_name) {
         RWLock::RLocker snap_locker(mock_image_ctx.image_ctx->snap_lock);
@@ -103,7 +114,7 @@ public:
       }));
   }
 
-  void expect_get_object_count(librbd::MockImageCtx &mock_image_ctx,
+  void expect_get_object_count(librbd::MockTestImageCtx &mock_image_ctx,
                                uint64_t count) {
     EXPECT_CALL(mock_image_ctx, get_object_count(_))
       .WillOnce(Return(count)).RetiresOnSaturation();
@@ -151,8 +162,8 @@ public:
     return *mock_object_copy_request.snap_map;
   }
 
-  MockImageCopyRequest *create_request(librbd::MockImageCtx &mock_remote_image_ctx,
-                                       librbd::MockImageCtx &mock_local_image_ctx,
+  MockImageCopyRequest *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
+                                       librbd::MockTestImageCtx &mock_local_image_ctx,
                                        journal::MockJournaler &mock_journaler,
                                        librbd::journal::MirrorPeerSyncPoint &sync_point,
                                        Context *ctx) {
@@ -199,8 +210,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, SimpleImage) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -244,8 +255,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, Throttled) {
 
   uint64_t object_count = 55;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -306,8 +317,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, SnapshotSubset) {
   ASSERT_EQ(0, create_snap("snap3"));
   m_client_meta.sync_points = {{"snap3", "snap2", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -344,8 +355,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, RestartCatchup) {
   m_client_meta.sync_points = {{"snap1", boost::none},
                                {"snap2", "snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -376,8 +387,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, RestartPartialSync) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"snap1", librbd::journal::MirrorPeerSyncPoint::ObjectNumber{0U}}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -413,8 +424,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, Cancel) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -459,8 +470,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, Cancel_Inflight_Sync) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -507,8 +518,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, Cancel1) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockObjectCopyRequest mock_object_copy_request;
 
@@ -538,8 +549,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, MissingSnap) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"missing-snap", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   expect_get_snap_id(mock_remote_image_ctx);
@@ -558,8 +569,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, MissingFromSnap) {
   ASSERT_EQ(0, create_snap("snap1"));
   m_client_meta.sync_points = {{"snap1", "missing-snap", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   expect_get_snap_id(mock_remote_image_ctx);
@@ -580,8 +591,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, EmptySnapMap) {
   m_client_meta.snap_seqs = {{0, 0}};
   m_client_meta.sync_points = {{"snap2", "snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   expect_get_snap_id(mock_remote_image_ctx);
@@ -602,8 +613,8 @@ TEST_F(TestMockImageSyncImageCopyRequest, EmptySnapSeqs) {
   m_client_meta.snap_seqs = {};
   m_client_meta.sync_points = {{"snap2", "snap1", boost::none}};
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   expect_get_snap_id(mock_remote_image_ctx);
index 69c4c646465245b09a905609813893d3f91557a8..c0d60db3bf8989ccf5435829d8ac7c11426b1d1b 100644 (file)
 #include "tools/rbd_mirror/Threads.h"
 #include "tools/rbd_mirror/image_sync/ObjectCopyRequest.h"
 
+namespace librbd {
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+} // namespace librbd
+
 // template definitions
 #include "tools/rbd_mirror/image_sync/ObjectCopyRequest.cc"
-template class rbd::mirror::image_sync::ObjectCopyRequest<librbd::MockImageCtx>;
+template class rbd::mirror::image_sync::ObjectCopyRequest<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -56,7 +68,7 @@ void scribble(librbd::ImageCtx *image_ctx, int num_ops, size_t max_size,
 
 class TestMockImageSyncObjectCopyRequest : public TestMockFixture {
 public:
-  typedef ObjectCopyRequest<librbd::MockImageCtx> MockObjectCopyRequest;
+  typedef ObjectCopyRequest<librbd::MockTestImageCtx> MockObjectCopyRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -69,7 +81,7 @@ public:
     ASSERT_EQ(0, open_image(m_local_io_ctx, m_image_name, &m_local_image_ctx));
   }
 
-  void expect_list_snaps(librbd::MockImageCtx &mock_image_ctx,
+  void expect_list_snaps(librbd::MockTestImageCtx &mock_image_ctx,
                          librados::MockTestMemIoCtxImpl &mock_io_ctx, int r) {
     auto &expect = EXPECT_CALL(mock_io_ctx,
                                list_snaps(mock_image_ctx.image_ctx->get_object_name(0),
@@ -81,13 +93,13 @@ public:
     }
   }
 
-  void expect_get_object_name(librbd::MockImageCtx &mock_image_ctx) {
+  void expect_get_object_name(librbd::MockTestImageCtx &mock_image_ctx) {
     EXPECT_CALL(mock_image_ctx, get_object_name(0))
                   .WillOnce(Return(mock_image_ctx.image_ctx->get_object_name(0)));
   }
 
-  MockObjectCopyRequest *create_request(librbd::MockImageCtx &mock_remote_image_ctx,
-                                        librbd::MockImageCtx &mock_local_image_ctx,
+  MockObjectCopyRequest *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
+                                        librbd::MockTestImageCtx &mock_local_image_ctx,
                                         Context *on_finish) {
     expect_get_object_name(mock_local_image_ctx);
     expect_get_object_name(mock_remote_image_ctx);
@@ -155,7 +167,7 @@ public:
     }
   }
 
-  void expect_update_object_map(librbd::MockImageCtx &mock_image_ctx,
+  void expect_update_object_map(librbd::MockTestImageCtx &mock_image_ctx,
                                 librbd::MockObjectMap &mock_object_map,
                                 librados::snap_t snap_id, uint8_t state,
                                 int r) {
@@ -289,8 +301,8 @@ public:
 
 TEST_F(TestMockImageSyncObjectCopyRequest, DNE) {
   ASSERT_EQ(0, create_snap("sync"));
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
@@ -317,8 +329,8 @@ TEST_F(TestMockImageSyncObjectCopyRequest, Write) {
   scribble(m_remote_image_ctx, 10, 102400, &one);
 
   ASSERT_EQ(0, create_snap("sync"));
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
@@ -352,8 +364,8 @@ TEST_F(TestMockImageSyncObjectCopyRequest, ReadError) {
   scribble(m_remote_image_ctx, 10, 102400, &one);
 
   ASSERT_EQ(0, create_snap("sync"));
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
@@ -381,8 +393,8 @@ TEST_F(TestMockImageSyncObjectCopyRequest, WriteError) {
   scribble(m_remote_image_ctx, 10, 102400, &one);
 
   ASSERT_EQ(0, create_snap("sync"));
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
@@ -424,8 +436,8 @@ TEST_F(TestMockImageSyncObjectCopyRequest, WriteSnaps) {
   }
 
   ASSERT_EQ(0, create_snap("sync"));
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
@@ -471,8 +483,8 @@ TEST_F(TestMockImageSyncObjectCopyRequest, Trim) {
     trim_offset, one.range_end() - trim_offset));
   ASSERT_EQ(0, create_snap("sync"));
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
@@ -513,8 +525,8 @@ TEST_F(TestMockImageSyncObjectCopyRequest, Remove) {
   uint64_t object_size = 1 << m_remote_image_ctx->order;
   ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->discard(0, object_size));
   ASSERT_EQ(0, create_snap("sync"));
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   librbd::MockObjectMap mock_object_map;
   mock_local_image_ctx.object_map = &mock_object_map;
index bcb9fd69d14679690bf8a1884a0cfd337e879017..2fd026a7c5f663307db5c212d5442cb3d0892721 100644 (file)
 #include "tools/rbd_mirror/Threads.h"
 
 namespace librbd {
+
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+
 namespace journal {
 
 template <>
-struct TypeTraits<librbd::MockImageCtx> {
+struct TypeTraits<librbd::MockTestImageCtx> {
   typedef ::journal::MockJournaler Journaler;
 };
 
@@ -30,9 +41,9 @@ namespace mirror {
 namespace image_sync {
 
 template <>
-struct SnapshotCreateRequest<librbd::MockImageCtx> {
+struct SnapshotCreateRequest<librbd::MockTestImageCtx> {
   static SnapshotCreateRequest* s_instance;
-  static SnapshotCreateRequest* create(librbd::MockImageCtx* image_ctx,
+  static SnapshotCreateRequest* create(librbd::MockTestImageCtx* image_ctx,
                                        const std::string &snap_name,
                                        uint64_t size,
                                        const librbd::parent_spec &parent_spec,
@@ -52,7 +63,7 @@ struct SnapshotCreateRequest<librbd::MockImageCtx> {
   MOCK_METHOD0(send, void());
 };
 
-SnapshotCreateRequest<librbd::MockImageCtx>* SnapshotCreateRequest<librbd::MockImageCtx>::s_instance = nullptr;
+SnapshotCreateRequest<librbd::MockTestImageCtx>* SnapshotCreateRequest<librbd::MockTestImageCtx>::s_instance = nullptr;
 
 } // namespace image_sync
 } // namespace mirror
@@ -60,7 +71,7 @@ SnapshotCreateRequest<librbd::MockImageCtx>* SnapshotCreateRequest<librbd::MockI
 
 // template definitions
 #include "tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc"
-template class rbd::mirror::image_sync::SnapshotCopyRequest<librbd::MockImageCtx>;
+template class rbd::mirror::image_sync::SnapshotCopyRequest<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -79,8 +90,8 @@ using ::testing::WithArg;
 
 class TestMockImageSyncSnapshotCopyRequest : public TestMockFixture {
 public:
-  typedef SnapshotCopyRequest<librbd::MockImageCtx> MockSnapshotCopyRequest;
-  typedef SnapshotCreateRequest<librbd::MockImageCtx> MockSnapshotCreateRequest;
+  typedef SnapshotCopyRequest<librbd::MockTestImageCtx> MockSnapshotCopyRequest;
+  typedef SnapshotCreateRequest<librbd::MockTestImageCtx> MockSnapshotCreateRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -93,7 +104,7 @@ public:
     ASSERT_EQ(0, open_image(m_local_io_ctx, m_image_name, &m_local_image_ctx));
   }
 
-  void expect_snap_create(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_create(librbd::MockTestImageCtx &mock_image_ctx,
                           MockSnapshotCreateRequest &mock_snapshot_create_request,
                           const std::string &snap_name, uint64_t snap_id, int r) {
     EXPECT_CALL(mock_snapshot_create_request, send())
@@ -105,7 +116,7 @@ public:
                       })));
   }
 
-  void expect_snap_remove(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_remove(librbd::MockTestImageCtx &mock_image_ctx,
                           const std::string &snap_name, int r) {
     EXPECT_CALL(*mock_image_ctx.operations, execute_snap_remove(StrEq(snap_name), _))
                   .WillOnce(WithArg<1>(Invoke([this, r](Context *ctx) {
@@ -113,7 +124,7 @@ public:
                             })));
   }
 
-  void expect_snap_protect(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_protect(librbd::MockTestImageCtx &mock_image_ctx,
                            const std::string &snap_name, int r) {
     EXPECT_CALL(*mock_image_ctx.operations, execute_snap_protect(StrEq(snap_name), _))
                   .WillOnce(WithArg<1>(Invoke([this, r](Context *ctx) {
@@ -121,7 +132,7 @@ public:
                             })));
   }
 
-  void expect_snap_unprotect(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_unprotect(librbd::MockTestImageCtx &mock_image_ctx,
                              const std::string &snap_name, int r) {
     EXPECT_CALL(*mock_image_ctx.operations, execute_snap_unprotect(StrEq(snap_name), _))
                   .WillOnce(WithArg<1>(Invoke([this, r](Context *ctx) {
@@ -129,14 +140,14 @@ public:
                             })));
   }
 
-  void expect_snap_is_protected(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_is_protected(librbd::MockTestImageCtx &mock_image_ctx,
                                 uint64_t snap_id, bool is_protected, int r) {
     EXPECT_CALL(mock_image_ctx, is_snap_protected(snap_id, _))
                   .WillOnce(DoAll(SetArgPointee<1>(is_protected),
                                   Return(r)));
   }
 
-  void expect_snap_is_unprotected(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_is_unprotected(librbd::MockTestImageCtx &mock_image_ctx,
                                   uint64_t snap_id, bool is_unprotected, int r) {
     EXPECT_CALL(mock_image_ctx, is_snap_unprotected(snap_id, _))
                   .WillOnce(DoAll(SetArgPointee<1>(is_unprotected),
@@ -148,13 +159,13 @@ public:
                   .WillOnce(WithArg<1>(CompleteContext(r)));
   }
 
-  static void inject_snap(librbd::MockImageCtx &mock_image_ctx,
-                   uint64_t snap_id, const std::string &snap_name) {
+  static void inject_snap(librbd::MockTestImageCtx &mock_image_ctx,
+                          uint64_t snap_id, const std::string &snap_name) {
     mock_image_ctx.snap_ids[snap_name] = snap_id;
   }
 
-  MockSnapshotCopyRequest *create_request(librbd::MockImageCtx &mock_remote_image_ctx,
-                                          librbd::MockImageCtx &mock_local_image_ctx,
+  MockSnapshotCopyRequest *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
+                                          librbd::MockTestImageCtx &mock_local_image_ctx,
                                           journal::MockJournaler &mock_journaler,
                                           Context *on_finish) {
     return new MockSnapshotCopyRequest(&mock_local_image_ctx,
@@ -200,8 +211,8 @@ public:
 };
 
 TEST_F(TestMockImageSyncSnapshotCopyRequest, Empty) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -219,8 +230,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, Empty) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCopyRequest, UpdateClientError) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -235,8 +246,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, UpdateClientError) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCopyRequest, UpdateClientCancel) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   C_SaferCond ctx;
@@ -261,8 +272,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapCreate) {
   uint64_t remote_snap_id1 = m_remote_image_ctx->snap_ids["snap1"];
   uint64_t remote_snap_id2 = m_remote_image_ctx->snap_ids["snap2"];
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   MockSnapshotCreateRequest mock_snapshot_create_request;
   journal::MockJournaler mock_journaler;
 
@@ -287,8 +298,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapCreate) {
 TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapCreateError) {
   ASSERT_EQ(0, create_snap(m_remote_image_ctx, "snap1"));
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   MockSnapshotCreateRequest mock_snapshot_create_request;
   journal::MockJournaler mock_journaler;
 
@@ -306,8 +317,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapCreateError) {
 TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapCreateCancel) {
   ASSERT_EQ(0, create_snap(m_remote_image_ctx, "snap1"));
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   MockSnapshotCreateRequest mock_snapshot_create_request;
   journal::MockJournaler mock_journaler;
 
@@ -334,8 +345,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapRemoveAndCreate) {
 
   uint64_t remote_snap_id1 = m_remote_image_ctx->snap_ids["snap1"];
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   MockSnapshotCreateRequest mock_snapshot_create_request;
   journal::MockJournaler mock_journaler;
 
@@ -361,8 +372,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapRemoveAndCreate) {
 TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapRemoveError) {
   ASSERT_EQ(0, create_snap(m_local_image_ctx, "snap1"));
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -386,8 +397,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapUnprotect) {
   uint64_t local_snap_id1 = m_local_image_ctx->snap_ids["snap1"];
   m_client_meta.snap_seqs[remote_snap_id1] = local_snap_id1;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -416,8 +427,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapUnprotectError) {
   uint64_t local_snap_id1 = m_local_image_ctx->snap_ids["snap1"];
   m_client_meta.snap_seqs[remote_snap_id1] = local_snap_id1;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -441,8 +452,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapUnprotectCancel) {
   uint64_t local_snap_id1 = m_local_image_ctx->snap_ids["snap1"];
   m_client_meta.snap_seqs[remote_snap_id1] = local_snap_id1;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   C_SaferCond ctx;
@@ -471,8 +482,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapUnprotectRemove) {
 
   uint64_t remote_snap_id1 = m_remote_image_ctx->snap_ids["snap1"];
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   MockSnapshotCreateRequest mock_snapshot_create_request;
   journal::MockJournaler mock_journaler;
 
@@ -501,8 +512,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapCreateProtect) {
 
   uint64_t remote_snap_id1 = m_remote_image_ctx->snap_ids["snap1"];
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   MockSnapshotCreateRequest mock_snapshot_create_request;
   journal::MockJournaler mock_journaler;
 
@@ -532,8 +543,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapProtect) {
   uint64_t local_snap_id1 = m_local_image_ctx->snap_ids["snap1"];
   m_client_meta.snap_seqs[remote_snap_id1] = local_snap_id1;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -562,8 +573,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapProtectError) {
   uint64_t local_snap_id1 = m_local_image_ctx->snap_ids["snap1"];
   m_client_meta.snap_seqs[remote_snap_id1] = local_snap_id1;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -588,8 +599,8 @@ TEST_F(TestMockImageSyncSnapshotCopyRequest, SnapProtectCancel) {
   uint64_t local_snap_id1 = m_local_image_ctx->snap_ids["snap1"];
   m_client_meta.snap_seqs[remote_snap_id1] = local_snap_id1;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
 
   C_SaferCond ctx;
index 8cf6217bf75bc49b52c5646a01be77f7bc501a57..c0105aeaa210b22af0f579a8d40c179173d484d2 100644 (file)
 #include "tools/rbd_mirror/image_sync/SnapshotCreateRequest.h"
 #include "tools/rbd_mirror/Threads.h"
 
+namespace librbd {
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+} // namespace librbd
+
 // template definitions
 #include "tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc"
-template class rbd::mirror::image_sync::SnapshotCreateRequest<librbd::MockImageCtx>;
+template class rbd::mirror::image_sync::SnapshotCreateRequest<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -32,7 +44,7 @@ using ::testing::WithArg;
 
 class TestMockImageSyncSnapshotCreateRequest : public TestMockFixture {
 public:
-  typedef SnapshotCreateRequest<librbd::MockImageCtx> MockSnapshotCreateRequest;
+  typedef SnapshotCreateRequest<librbd::MockTestImageCtx> MockSnapshotCreateRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -42,31 +54,31 @@ public:
     ASSERT_EQ(0, open_image(m_local_io_ctx, m_image_name, &m_local_image_ctx));
   }
 
-  void expect_test_features(librbd::MockImageCtx &mock_image_ctx,
+  void expect_test_features(librbd::MockTestImageCtx &mock_image_ctx,
                             uint64_t features, bool enabled) {
     EXPECT_CALL(mock_image_ctx, test_features(features))
                   .WillOnce(Return(enabled));
   }
 
-  void expect_set_size(librbd::MockImageCtx &mock_image_ctx, int r) {
+  void expect_set_size(librbd::MockTestImageCtx &mock_image_ctx, int r) {
     EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
                 exec(mock_image_ctx.header_oid, _, StrEq("rbd"), StrEq("set_size"), _, _, _))
                   .WillOnce(Return(r));
   }
 
-  void expect_remove_parent(librbd::MockImageCtx &mock_image_ctx, int r) {
+  void expect_remove_parent(librbd::MockTestImageCtx &mock_image_ctx, int r) {
     EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
                 exec(mock_image_ctx.header_oid, _, StrEq("rbd"), StrEq("remove_parent"), _, _, _))
                   .WillOnce(Return(r));
   }
 
-  void expect_set_parent(librbd::MockImageCtx &mock_image_ctx, int r) {
+  void expect_set_parent(librbd::MockTestImageCtx &mock_image_ctx, int r) {
     EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
                 exec(mock_image_ctx.header_oid, _, StrEq("rbd"), StrEq("set_parent"), _, _, _))
                   .WillOnce(Return(r));
   }
 
-  void expect_snap_create(librbd::MockImageCtx &mock_image_ctx,
+  void expect_snap_create(librbd::MockTestImageCtx &mock_image_ctx,
                           const std::string &snap_name, uint64_t snap_id, int r) {
     EXPECT_CALL(*mock_image_ctx.operations, execute_snap_create(StrEq(snap_name), _, 0, true))
                   .WillOnce(DoAll(InvokeWithoutArgs([&mock_image_ctx, snap_id, snap_name]() {
@@ -77,7 +89,7 @@ public:
                                   }))));
   }
 
-  void expect_object_map_resize(librbd::MockImageCtx &mock_image_ctx,
+  void expect_object_map_resize(librbd::MockTestImageCtx &mock_image_ctx,
                                 librados::snap_t snap_id, int r) {
     std::string oid(librbd::ObjectMap::object_map_name(mock_image_ctx.id,
                                                        snap_id));
@@ -86,12 +98,12 @@ public:
                   .WillOnce(Return(r));
   }
 
-  static void inject_snap(librbd::MockImageCtx &mock_image_ctx,
+  static void inject_snap(librbd::MockTestImageCtx &mock_image_ctx,
                    uint64_t snap_id, const std::string &snap_name) {
     mock_image_ctx.snap_ids[snap_name] = snap_id;
   }
 
-  MockSnapshotCreateRequest *create_request(librbd::MockImageCtx &mock_local_image_ctx,
+  MockSnapshotCreateRequest *create_request(librbd::MockTestImageCtx &mock_local_image_ctx,
                                             const std::string &snap_name,
                                             uint64_t size,
                                             const librbd::parent_spec &spec,
@@ -105,7 +117,7 @@ public:
 };
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, Resize) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_set_size(mock_local_image_ctx, 0);
@@ -121,7 +133,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, Resize) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, ResizeError) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_set_size(mock_local_image_ctx, -EINVAL);
@@ -135,7 +147,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, ResizeError) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, RemoveParent) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   mock_local_image_ctx.parent_md.spec.pool_id = 213;
 
   InSequence seq;
@@ -153,7 +165,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, RemoveParent) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, RemoveParentError) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   mock_local_image_ctx.parent_md.spec.pool_id = 213;
 
   InSequence seq;
@@ -169,7 +181,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, RemoveParentError) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, RemoveSetParent) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   mock_local_image_ctx.parent_md.spec.pool_id = 213;
 
   InSequence seq;
@@ -189,7 +201,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, RemoveSetParent) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, SetParentSpec) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_set_parent(mock_local_image_ctx, 0);
@@ -207,7 +219,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, SetParentSpec) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, SetParentOverlap) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   mock_local_image_ctx.parent_md.spec = {123, "test", 0};
 
   InSequence seq;
@@ -226,7 +238,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, SetParentOverlap) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, SetParentError) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_set_parent(mock_local_image_ctx, -ESTALE);
@@ -242,7 +254,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, SetParentError) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, SnapCreate) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_snap_create(mock_local_image_ctx, "snap1", 10, 0);
@@ -258,7 +270,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, SnapCreate) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, SnapCreateError) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_snap_create(mock_local_image_ctx, "snap1", 10, -EINVAL);
@@ -273,7 +285,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, SnapCreateError) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, ResizeObjectMap) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_snap_create(mock_local_image_ctx, "snap1", 10, 0);
@@ -290,7 +302,7 @@ TEST_F(TestMockImageSyncSnapshotCreateRequest, ResizeObjectMap) {
 }
 
 TEST_F(TestMockImageSyncSnapshotCreateRequest, ResizeObjectMapError) {
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
 
   InSequence seq;
   expect_snap_create(mock_local_image_ctx, "snap1", 10, 0);
index faff6a73e906a71c3e878c5f98fdf1d4e31c3e2b..7fd32d4efe4061a2a76246767b7247e67bc96620 100644 (file)
 #include "tools/rbd_mirror/image_sync/SyncPointCreateRequest.h"
 
 namespace librbd {
+
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+
 namespace journal {
 
 template <>
-struct TypeTraits<librbd::MockImageCtx> {
+struct TypeTraits<librbd::MockTestImageCtx> {
   typedef ::journal::MockJournaler Journaler;
 };
 
@@ -23,7 +34,7 @@ struct TypeTraits<librbd::MockImageCtx> {
 
 // template definitions
 #include "tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc"
-template class rbd::mirror::image_sync::SyncPointCreateRequest<librbd::MockImageCtx>;
+template class rbd::mirror::image_sync::SyncPointCreateRequest<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -35,7 +46,7 @@ using ::testing::WithArg;
 
 class TestMockImageSyncSyncPointCreateRequest : public TestMockFixture {
 public:
-  typedef SyncPointCreateRequest<librbd::MockImageCtx> MockSyncPointCreateRequest;
+  typedef SyncPointCreateRequest<librbd::MockTestImageCtx> MockSyncPointCreateRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -50,17 +61,17 @@ public:
       .WillOnce(WithArg<1>(CompleteContext(r)));
   }
 
-  void expect_image_refresh(librbd::MockImageCtx &mock_remote_image_ctx, int r) {
+  void expect_image_refresh(librbd::MockTestImageCtx &mock_remote_image_ctx, int r) {
     EXPECT_CALL(*mock_remote_image_ctx.state, refresh(_))
       .WillOnce(CompleteContext(r));
   }
 
-  void expect_snap_create(librbd::MockImageCtx &mock_remote_image_ctx, int r) {
+  void expect_snap_create(librbd::MockTestImageCtx &mock_remote_image_ctx, int r) {
     EXPECT_CALL(*mock_remote_image_ctx.operations, snap_create(_, _))
       .WillOnce(WithArg<1>(CompleteContext(r)));
   }
 
-  MockSyncPointCreateRequest *create_request(librbd::MockImageCtx &mock_remote_image_ctx,
+  MockSyncPointCreateRequest *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
                                              journal::MockJournaler &mock_journaler,
                                              Context *ctx) {
     return new MockSyncPointCreateRequest(&mock_remote_image_ctx, "uuid",
@@ -72,7 +83,7 @@ public:
 };
 
 TEST_F(TestMockImageSyncSyncPointCreateRequest, Success) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -94,7 +105,7 @@ TEST_F(TestMockImageSyncSyncPointCreateRequest, ResyncSuccess) {
   m_client_meta.sync_points.emplace_front("start snap", "", boost::none);
   auto sync_point = m_client_meta.sync_points.front();
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -115,7 +126,7 @@ TEST_F(TestMockImageSyncSyncPointCreateRequest, ResyncSuccess) {
 }
 
 TEST_F(TestMockImageSyncSyncPointCreateRequest, SnapshotExists) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -137,7 +148,7 @@ TEST_F(TestMockImageSyncSyncPointCreateRequest, SnapshotExists) {
 }
 
 TEST_F(TestMockImageSyncSyncPointCreateRequest, ClientUpdateError) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
index 76844dcd617e0850c1c070d4c89dcbd9dc904721..7d037654640b88f79e51c1a1544cc90133a3d546 100644 (file)
 #include "tools/rbd_mirror/image_sync/SyncPointPruneRequest.h"
 
 namespace librbd {
+
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+
 namespace journal {
 
 template <>
-struct TypeTraits<librbd::MockImageCtx> {
+struct TypeTraits<librbd::MockTestImageCtx> {
   typedef ::journal::MockJournaler Journaler;
 };
 
@@ -23,7 +34,7 @@ struct TypeTraits<librbd::MockImageCtx> {
 
 // template definitions
 #include "tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc"
-template class rbd::mirror::image_sync::SyncPointPruneRequest<librbd::MockImageCtx>;
+template class rbd::mirror::image_sync::SyncPointPruneRequest<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -37,7 +48,7 @@ using ::testing::WithArg;
 
 class TestMockImageSyncSyncPointPruneRequest : public TestMockFixture {
 public:
-  typedef SyncPointPruneRequest<librbd::MockImageCtx> MockSyncPointPruneRequest;
+  typedef SyncPointPruneRequest<librbd::MockTestImageCtx> MockSyncPointPruneRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -52,24 +63,24 @@ public:
       .WillOnce(WithArg<1>(CompleteContext(r)));
   }
 
-  void expect_get_snap_id(librbd::MockImageCtx &mock_remote_image_ctx,
+  void expect_get_snap_id(librbd::MockTestImageCtx &mock_remote_image_ctx,
                           const std::string &snap_name, uint64_t snap_id) {
     EXPECT_CALL(mock_remote_image_ctx, get_snap_id(StrEq(snap_name)))
       .WillOnce(Return(snap_id));
   }
 
-  void expect_image_refresh(librbd::MockImageCtx &mock_remote_image_ctx, int r) {
+  void expect_image_refresh(librbd::MockTestImageCtx &mock_remote_image_ctx, int r) {
     EXPECT_CALL(*mock_remote_image_ctx.state, refresh(_))
       .WillOnce(CompleteContext(r));
   }
 
-  void expect_snap_remove(librbd::MockImageCtx &mock_remote_image_ctx,
+  void expect_snap_remove(librbd::MockTestImageCtx &mock_remote_image_ctx,
                           const std::string &snap_name, int r) {
     EXPECT_CALL(*mock_remote_image_ctx.operations, snap_remove(StrEq(snap_name), _))
       .WillOnce(WithArg<1>(CompleteContext(r)));
   }
 
-  MockSyncPointPruneRequest *create_request(librbd::MockImageCtx &mock_remote_image_ctx,
+  MockSyncPointPruneRequest *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
                                             journal::MockJournaler &mock_journaler,
                                             bool sync_complete, Context *ctx) {
     return new MockSyncPointPruneRequest(&mock_remote_image_ctx, sync_complete,
@@ -85,7 +96,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, SyncInProgressSuccess) {
   client_meta.sync_points.emplace_front("snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -107,7 +118,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, RestartedSyncInProgressSuccess) {
   client_meta.sync_points.emplace_front("snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -132,7 +143,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, SyncInProgressMissingSnapSuccess)
   client_meta.sync_points.emplace_front("snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -157,7 +168,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, SyncInProgressUnexpectedFromSnapS
   client_meta.sync_points.emplace_front("snap2", "snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -183,7 +194,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, SyncCompleteSuccess) {
   m_client_meta = client_meta;
   ASSERT_EQ(librbd::journal::MIRROR_PEER_STATE_SYNCING, m_client_meta.state);
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -206,7 +217,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, RestartedSyncCompleteSuccess) {
   client_meta.sync_points.emplace_front("snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -228,7 +239,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, RestartedCatchUpSyncCompleteSucce
   client_meta.sync_points.emplace_front("snap2", "snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -250,7 +261,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, SnapshotDNE) {
   client_meta.sync_points.emplace_front("snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
@@ -272,7 +283,7 @@ TEST_F(TestMockImageSyncSyncPointPruneRequest, ClientUpdateError) {
   client_meta.sync_points.emplace_front("snap1", boost::none);
   m_client_meta = client_meta;
 
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
   journal::MockJournaler mock_journaler;
 
   InSequence seq;
index 4e58ac76cb77ddcd163078961afc168bf719e4c1..3d3983adf76ce277e41d8bc56f7267b0b18278e2 100644 (file)
 #include "tools/rbd_mirror/image_sync/SyncPointPruneRequest.h"
 
 namespace librbd {
+
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+
 namespace journal {
 
 template <>
-struct TypeTraits<librbd::MockImageCtx> {
+struct TypeTraits<librbd::MockTestImageCtx> {
   typedef ::journal::MockJournaler Journaler;
 };
 
@@ -29,7 +40,7 @@ struct TypeTraits<librbd::MockImageCtx> {
 
 // template definitions
 #include "tools/rbd_mirror/ImageSync.cc"
-template class rbd::mirror::ImageSync<librbd::MockImageCtx>;
+template class rbd::mirror::ImageSync<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
@@ -37,13 +48,13 @@ namespace mirror {
 namespace image_sync {
 
 template <>
-class ImageCopyRequest<librbd::MockImageCtx> {
+class ImageCopyRequest<librbd::MockTestImageCtx> {
 public:
   static ImageCopyRequest* s_instance;
   Context *on_finish;
 
-  static ImageCopyRequest* create(librbd::MockImageCtx *local_image_ctx,
-                                  librbd::MockImageCtx *remote_image_ctx,
+  static ImageCopyRequest* create(librbd::MockTestImageCtx *local_image_ctx,
+                                  librbd::MockTestImageCtx *remote_image_ctx,
                                   SafeTimer *timer, Mutex *timer_lock,
                                   journal::MockJournaler *journaler,
                                   librbd::journal::MirrorPeerClientMeta *client_meta,
@@ -70,13 +81,13 @@ public:
 };
 
 template <>
-class SnapshotCopyRequest<librbd::MockImageCtx> {
+class SnapshotCopyRequest<librbd::MockTestImageCtx> {
 public:
   static SnapshotCopyRequest* s_instance;
   Context *on_finish;
 
-  static SnapshotCopyRequest* create(librbd::MockImageCtx *local_image_ctx,
-                                     librbd::MockImageCtx *remote_image_ctx,
+  static SnapshotCopyRequest* create(librbd::MockTestImageCtx *local_image_ctx,
+                                     librbd::MockTestImageCtx *remote_image_ctx,
                                      SnapshotCopyRequest<librbd::ImageCtx>::SnapMap *snap_map,
                                      journal::MockJournaler *journaler,
                                      librbd::journal::MirrorPeerClientMeta *client_meta,
@@ -102,12 +113,12 @@ public:
 };
 
 template <>
-class SyncPointCreateRequest<librbd::MockImageCtx> {
+class SyncPointCreateRequest<librbd::MockTestImageCtx> {
 public:
   static SyncPointCreateRequest *s_instance;
   Context *on_finish;
 
-  static SyncPointCreateRequest* create(librbd::MockImageCtx *remote_image_ctx,
+  static SyncPointCreateRequest* create(librbd::MockTestImageCtx *remote_image_ctx,
                                         const std::string &mirror_uuid,
                                         journal::MockJournaler *journaler,
                                         librbd::journal::MirrorPeerClientMeta *client_meta,
@@ -124,13 +135,13 @@ public:
 };
 
 template <>
-class SyncPointPruneRequest<librbd::MockImageCtx> {
+class SyncPointPruneRequest<librbd::MockTestImageCtx> {
 public:
   static SyncPointPruneRequest *s_instance;
   Context *on_finish;
   bool sync_complete;
 
-  static SyncPointPruneRequest* create(librbd::MockImageCtx *remote_image_ctx,
+  static SyncPointPruneRequest* create(librbd::MockTestImageCtx *remote_image_ctx,
                                        bool sync_complete,
                                        journal::MockJournaler *journaler,
                                        librbd::journal::MirrorPeerClientMeta *client_meta,
@@ -147,10 +158,10 @@ public:
   MOCK_METHOD0(send, void());
 };
 
-ImageCopyRequest<librbd::MockImageCtx>* ImageCopyRequest<librbd::MockImageCtx>::s_instance = nullptr;
-SnapshotCopyRequest<librbd::MockImageCtx>* SnapshotCopyRequest<librbd::MockImageCtx>::s_instance = nullptr;
-SyncPointCreateRequest<librbd::MockImageCtx>* SyncPointCreateRequest<librbd::MockImageCtx>::s_instance = nullptr;
-SyncPointPruneRequest<librbd::MockImageCtx>* SyncPointPruneRequest<librbd::MockImageCtx>::s_instance = nullptr;
+ImageCopyRequest<librbd::MockTestImageCtx>* ImageCopyRequest<librbd::MockTestImageCtx>::s_instance = nullptr;
+SnapshotCopyRequest<librbd::MockTestImageCtx>* SnapshotCopyRequest<librbd::MockTestImageCtx>::s_instance = nullptr;
+SyncPointCreateRequest<librbd::MockTestImageCtx>* SyncPointCreateRequest<librbd::MockTestImageCtx>::s_instance = nullptr;
+SyncPointPruneRequest<librbd::MockTestImageCtx>* SyncPointPruneRequest<librbd::MockTestImageCtx>::s_instance = nullptr;
 
 } // namespace image_sync
 
@@ -163,11 +174,11 @@ using ::testing::InvokeWithoutArgs;
 
 class TestMockImageSync : public TestMockFixture {
 public:
-  typedef ImageSync<librbd::MockImageCtx> MockImageSync;
-  typedef image_sync::ImageCopyRequest<librbd::MockImageCtx> MockImageCopyRequest;
-  typedef image_sync::SnapshotCopyRequest<librbd::MockImageCtx> MockSnapshotCopyRequest;
-  typedef image_sync::SyncPointCreateRequest<librbd::MockImageCtx> MockSyncPointCreateRequest;
-  typedef image_sync::SyncPointPruneRequest<librbd::MockImageCtx> MockSyncPointPruneRequest;
+  typedef ImageSync<librbd::MockTestImageCtx> MockImageSync;
+  typedef image_sync::ImageCopyRequest<librbd::MockTestImageCtx> MockImageCopyRequest;
+  typedef image_sync::SnapshotCopyRequest<librbd::MockTestImageCtx> MockSnapshotCopyRequest;
+  typedef image_sync::SyncPointCreateRequest<librbd::MockTestImageCtx> MockSyncPointCreateRequest;
+  typedef image_sync::SyncPointPruneRequest<librbd::MockTestImageCtx> MockSyncPointPruneRequest;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -180,7 +191,7 @@ public:
     ASSERT_EQ(0, open_image(m_local_io_ctx, m_image_name, &m_local_image_ctx));
   }
 
-  void expect_create_sync_point(librbd::MockImageCtx &mock_local_image_ctx,
+  void expect_create_sync_point(librbd::MockTestImageCtx &mock_local_image_ctx,
                                 MockSyncPointCreateRequest &mock_sync_point_create_request,
                                 int r) {
     EXPECT_CALL(mock_sync_point_create_request, send())
@@ -216,13 +227,13 @@ public:
     }
   }
 
-  void expect_create_object_map(librbd::MockImageCtx &mock_image_ctx,
+  void expect_create_object_map(librbd::MockTestImageCtx &mock_image_ctx,
                                 librbd::MockObjectMap *mock_object_map) {
     EXPECT_CALL(mock_image_ctx, create_object_map(CEPH_NOSNAP))
       .WillOnce(Return(mock_object_map));
   }
 
-  void expect_open_object_map(librbd::MockImageCtx &mock_image_ctx,
+  void expect_open_object_map(librbd::MockTestImageCtx &mock_image_ctx,
                               librbd::MockObjectMap &mock_object_map) {
     EXPECT_CALL(mock_object_map, open(_))
       .WillOnce(Invoke([this](Context *ctx) {
@@ -248,8 +259,8 @@ public:
         }));
   }
 
-  MockImageSync *create_request(librbd::MockImageCtx &mock_remote_image_ctx,
-                                librbd::MockImageCtx &mock_local_image_ctx,
+  MockImageSync *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
+                                librbd::MockTestImageCtx &mock_local_image_ctx,
                                 journal::MockJournaler &mock_journaler,
                                 Context *ctx) {
     return new MockImageSync(&mock_local_image_ctx, &mock_remote_image_ctx,
@@ -264,8 +275,8 @@ public:
 };
 
 TEST_F(TestMockImageSync, SimpleSync) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockImageCopyRequest mock_image_copy_request;
   MockSnapshotCopyRequest mock_snapshot_copy_request;
@@ -294,8 +305,8 @@ TEST_F(TestMockImageSync, SimpleSync) {
 }
 
 TEST_F(TestMockImageSync, RestartSync) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockImageCopyRequest mock_image_copy_request;
   MockSnapshotCopyRequest mock_snapshot_copy_request;
@@ -329,8 +340,8 @@ TEST_F(TestMockImageSync, RestartSync) {
 }
 
 TEST_F(TestMockImageSync, CancelImageCopy) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockImageCopyRequest mock_image_copy_request;
   MockSnapshotCopyRequest mock_snapshot_copy_request;
@@ -367,8 +378,8 @@ TEST_F(TestMockImageSync, CancelImageCopy) {
 }
 
 TEST_F(TestMockImageSync, CancelAfterCopySnapshots) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockSnapshotCopyRequest mock_snapshot_copy_request;
   MockSyncPointCreateRequest mock_sync_point_create_request;
@@ -397,8 +408,8 @@ TEST_F(TestMockImageSync, CancelAfterCopySnapshots) {
 }
 
 TEST_F(TestMockImageSync, CancelAfterCopyImage) {
-  librbd::MockImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
-  librbd::MockImageCtx mock_local_image_ctx(*m_local_image_ctx);
+  librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx);
+  librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx);
   journal::MockJournaler mock_journaler;
   MockImageCopyRequest mock_image_copy_request;
   MockSnapshotCopyRequest mock_snapshot_copy_request;
index 31829bda23f7cda22da0305214214cf1f91bf6ff..01f875c93977835c9ae2c68e5733493fa7b3fc73 100644 (file)
 #include "tools/rbd_mirror/ImageSync.h"
 
 namespace librbd {
+
+namespace {
+
+struct MockTestImageCtx : public librbd::MockImageCtx {
+  MockTestImageCtx(librbd::ImageCtx &image_ctx)
+    : librbd::MockImageCtx(image_ctx) {
+  }
+};
+
+} // anonymous namespace
+
 namespace journal {
 
 template <>
-struct TypeTraits<librbd::MockImageCtx> {
+struct TypeTraits<librbd::MockTestImageCtx> {
   typedef ::journal::MockJournaler Journaler;
 };
 
@@ -36,18 +47,18 @@ namespace mirror {
 
 using ::testing::Invoke;
 
-typedef ImageSync<librbd::MockImageCtx> MockImageSync;
+typedef ImageSync<librbd::MockTestImageCtx> MockImageSync;
 
 template<>
-class ImageSync<librbd::MockImageCtx> {
+class ImageSync<librbd::MockTestImageCtx> {
 public:
   static std::vector<MockImageSync *> instances;
 
   Context *on_finish;
   bool syncing = false;
 
-  static ImageSync* create(librbd::MockImageCtx *local_image_ctx,
-                           librbd::MockImageCtx *remote_image_ctx,
+  static ImageSync* create(librbd::MockTestImageCtx *local_image_ctx,
+                           librbd::MockTestImageCtx *remote_image_ctx,
                            SafeTimer *timer, Mutex *timer_lock,
                            const std::string &mirror_uuid,
                            journal::MockJournaler *journaler,
@@ -90,14 +101,14 @@ std::vector<MockImageSync *> MockImageSync::instances;
 
 // template definitions
 #include "tools/rbd_mirror/ImageSyncThrottler.cc"
-template class rbd::mirror::ImageSyncThrottler<librbd::MockImageCtx>;
+template class rbd::mirror::ImageSyncThrottler<librbd::MockTestImageCtx>;
 
 namespace rbd {
 namespace mirror {
 
 class TestMockImageSyncThrottler : public TestMockFixture {
 public:
-  typedef ImageSyncThrottler<librbd::MockImageCtx> MockImageSyncThrottler;
+  typedef ImageSyncThrottler<librbd::MockTestImageCtx> MockImageSyncThrottler;
 
   virtual void SetUp() {
     TestMockFixture::SetUp();
@@ -111,8 +122,8 @@ public:
 
     mock_sync_throttler = new MockImageSyncThrottler();
 
-    m_mock_local_image_ctx = new librbd::MockImageCtx(*m_local_image_ctx);
-    m_mock_remote_image_ctx = new librbd::MockImageCtx(*m_remote_image_ctx);
+    m_mock_local_image_ctx = new librbd::MockTestImageCtx(*m_local_image_ctx);
+    m_mock_remote_image_ctx = new librbd::MockTestImageCtx(*m_remote_image_ctx);
     m_mock_journaler = new journal::MockJournaler();
   }
 
@@ -153,8 +164,8 @@ public:
 
   librbd::ImageCtx *m_remote_image_ctx;
   librbd::ImageCtx *m_local_image_ctx;
-  librbd::MockImageCtx *m_mock_local_image_ctx;
-  librbd::MockImageCtx *m_mock_remote_image_ctx;
+  librbd::MockTestImageCtx *m_mock_local_image_ctx;
+  librbd::MockTestImageCtx *m_mock_remote_image_ctx;
   journal::MockJournaler *m_mock_journaler;
   librbd::journal::MirrorPeerClientMeta m_client_meta;
   MockImageSyncThrottler *mock_sync_throttler;