X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Flibrbd%2Fexclusive_lock%2Ftest_mock_PreAcquireRequest.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Flibrbd%2Fexclusive_lock%2Ftest_mock_PreAcquireRequest.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=467dd3924942009a4a3cea30dab0ab268764c3a5;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/test/librbd/exclusive_lock/test_mock_PreAcquireRequest.cc b/src/ceph/src/test/librbd/exclusive_lock/test_mock_PreAcquireRequest.cc deleted file mode 100644 index 467dd39..0000000 --- a/src/ceph/src/test/librbd/exclusive_lock/test_mock_PreAcquireRequest.cc +++ /dev/null @@ -1,92 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#include "test/librbd/test_mock_fixture.h" -#include "test/librbd/test_support.h" -#include "test/librbd/mock/MockImageCtx.h" -#include "test/librados_test_stub/MockTestMemIoCtxImpl.h" -#include "test/librados_test_stub/MockTestMemRadosClient.h" -#include "librbd/exclusive_lock/PreAcquireRequest.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include -#include - -namespace librbd { -namespace { - -struct MockTestImageCtx : public librbd::MockImageCtx { - MockTestImageCtx(librbd::ImageCtx &image_ctx) - : librbd::MockImageCtx(image_ctx) { - } -}; - -inline ImageCtx &get_image_ctx(MockTestImageCtx &image_ctx) { - return *(image_ctx.image_ctx); -} - -} // anonymous namespace -} // namespace librbd - -// template definitions -#include "librbd/exclusive_lock/PreAcquireRequest.cc" -template class librbd::exclusive_lock::PreAcquireRequest; - -namespace librbd { -namespace exclusive_lock { - -using ::testing::_; -using ::testing::DoAll; -using ::testing::InSequence; -using ::testing::Invoke; -using ::testing::Return; -using ::testing::SetArgPointee; -using ::testing::StrEq; -using ::testing::WithArg; - -static const std::string TEST_COOKIE("auto 123"); - -class TestMockExclusiveLockPreAcquireRequest : public TestMockFixture { -public: - typedef PreAcquireRequest MockPreAcquireRequest; - - void expect_flush_notifies(MockTestImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.image_watcher, flush(_)) - .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)); - } - - void expect_prepare_lock(MockTestImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.state, prepare_lock(_)) - .WillOnce(Invoke([](Context *on_ready) { - on_ready->complete(0); - })); - } - - void expect_handle_prepare_lock_complete(MockTestImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.state, handle_prepare_lock_complete()); - } - -}; - -TEST_F(TestMockExclusiveLockPreAcquireRequest, Success) { - REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK); - - librbd::ImageCtx *ictx; - ASSERT_EQ(0, open_image(m_image_name, &ictx)); - - MockTestImageCtx mock_image_ctx(*ictx); - expect_op_work_queue(mock_image_ctx); - - InSequence seq; - expect_prepare_lock(mock_image_ctx); - expect_flush_notifies(mock_image_ctx); - - C_SaferCond ctx; - MockPreAcquireRequest *req = MockPreAcquireRequest::create(mock_image_ctx, - &ctx); - req->send(); - ASSERT_EQ(0, ctx.wait()); - } - -} // namespace exclusive_lock -} // namespace librbd