]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H | |
5 | #define CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H | |
6 | ||
7 | #include "test/rbd_mirror/test_fixture.h" | |
8 | #include "test/librados_test_stub/LibradosTestStub.h" | |
9 | #include "common/WorkQueue.h" | |
10 | #include <boost/shared_ptr.hpp> | |
11 | #include <gmock/gmock.h> | |
12 | #include "include/assert.h" | |
13 | ||
14 | namespace librados { | |
15 | class TestRadosClient; | |
16 | class MockTestMemIoCtxImpl; | |
17 | class MockTestMemRadosClient; | |
18 | } | |
19 | ||
20 | namespace librbd { | |
21 | class MockImageCtx; | |
22 | } | |
23 | ||
b32b8144 FG |
24 | ACTION_P(CopyInBufferlist, str) { |
25 | arg0->append(str); | |
26 | } | |
27 | ||
7c673cae FG |
28 | ACTION_P(CompleteContext, r) { |
29 | arg0->complete(r); | |
30 | } | |
31 | ||
32 | ACTION_P2(CompleteContext, wq, r) { | |
33 | ContextWQ *context_wq = reinterpret_cast<ContextWQ *>(wq); | |
34 | context_wq->queue(arg0, r); | |
35 | } | |
36 | ||
37 | MATCHER_P(ContentsEqual, bl, "") { | |
38 | // TODO fix const-correctness of bufferlist | |
39 | return const_cast<bufferlist &>(arg).contents_equal( | |
40 | const_cast<bufferlist &>(bl)); | |
41 | } | |
42 | ||
43 | namespace rbd { | |
44 | namespace mirror { | |
45 | ||
46 | class TestMockFixture : public TestFixture { | |
47 | public: | |
48 | typedef boost::shared_ptr<librados::TestCluster> TestClusterRef; | |
49 | ||
50 | static void SetUpTestCase(); | |
51 | static void TearDownTestCase(); | |
52 | ||
53 | void TearDown() override; | |
54 | ||
55 | void expect_test_features(librbd::MockImageCtx &mock_image_ctx); | |
56 | ||
57 | private: | |
58 | static TestClusterRef s_test_cluster; | |
59 | }; | |
60 | ||
61 | } // namespace mirror | |
62 | } // namespace rbd | |
63 | ||
64 | #endif // CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H |