X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Flibrbd%2Ftest_BlockGuard.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Flibrbd%2Ftest_BlockGuard.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=e41e58825494bb202fa82e1dce25d5e77b259069;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/test/librbd/test_BlockGuard.cc b/src/ceph/src/test/librbd/test_BlockGuard.cc deleted file mode 100644 index e41e588..0000000 --- a/src/ceph/src/test/librbd/test_BlockGuard.cc +++ /dev/null @@ -1,98 +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_fixture.h" -#include "test/librbd/test_support.h" -#include "librbd/BlockGuard.h" - -namespace librbd { - -class TestIOBlockGuard : public TestFixture { -public: - static uint32_t s_index; - - struct Operation { - uint32_t index; - Operation() : index(++s_index) { - } - Operation(Operation &&rhs) : index(rhs.index) { - } - Operation(const Operation &) = delete; - - Operation& operator=(Operation &&rhs) { - index = rhs.index; - return *this; - } - - bool operator==(const Operation &rhs) const { - return index == rhs.index; - } - }; - - typedef std::list Operations; - - typedef BlockGuard OpBlockGuard; - - void SetUp() override { - TestFixture::SetUp(); - m_cct = reinterpret_cast(m_ioctx.cct()); - } - - CephContext *m_cct; -}; - -TEST_F(TestIOBlockGuard, NonDetainedOps) { - OpBlockGuard op_block_guard(m_cct); - - Operation op1; - BlockGuardCell *cell1; - ASSERT_EQ(0, op_block_guard.detain({1, 3}, &op1, &cell1)); - - Operation op2; - BlockGuardCell *cell2; - ASSERT_EQ(0, op_block_guard.detain({0, 1}, &op2, &cell2)); - - Operation op3; - BlockGuardCell *cell3; - ASSERT_EQ(0, op_block_guard.detain({3, 6}, &op3, &cell3)); - - Operations released_ops; - op_block_guard.release(cell1, &released_ops); - ASSERT_TRUE(released_ops.empty()); - - op_block_guard.release(cell2, &released_ops); - ASSERT_TRUE(released_ops.empty()); - - op_block_guard.release(cell3, &released_ops); - ASSERT_TRUE(released_ops.empty()); -} - -TEST_F(TestIOBlockGuard, DetainedOps) { - OpBlockGuard op_block_guard(m_cct); - - Operation op1; - BlockGuardCell *cell1; - ASSERT_EQ(0, op_block_guard.detain({1, 3}, &op1, &cell1)); - - Operation op2; - BlockGuardCell *cell2; - ASSERT_EQ(1, op_block_guard.detain({2, 6}, &op2, &cell2)); - ASSERT_EQ(nullptr, cell2); - - Operation op3; - BlockGuardCell *cell3; - ASSERT_EQ(2, op_block_guard.detain({0, 2}, &op3, &cell3)); - ASSERT_EQ(nullptr, cell3); - - Operations expected_ops; - expected_ops.push_back(std::move(op2)); - expected_ops.push_back(std::move(op3)); - Operations released_ops; - op_block_guard.release(cell1, &released_ops); - ASSERT_EQ(expected_ops, released_ops); -} - -uint32_t TestIOBlockGuard::s_index = 0; - -} // namespace librbd -