]>
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> | |
11fdf7f2 | 12 | #include "include/ceph_assert.h" |
7c673cae FG |
13 | |
14 | namespace librados { | |
15 | class TestRadosClient; | |
11fdf7f2 | 16 | class MockTestMemCluster; |
7c673cae FG |
17 | class MockTestMemIoCtxImpl; |
18 | class MockTestMemRadosClient; | |
19 | } | |
20 | ||
21 | namespace librbd { | |
22 | class MockImageCtx; | |
23 | } | |
24 | ||
b32b8144 FG |
25 | ACTION_P(CopyInBufferlist, str) { |
26 | arg0->append(str); | |
27 | } | |
28 | ||
7c673cae FG |
29 | ACTION_P(CompleteContext, r) { |
30 | arg0->complete(r); | |
31 | } | |
32 | ||
33 | ACTION_P2(CompleteContext, wq, r) { | |
34 | ContextWQ *context_wq = reinterpret_cast<ContextWQ *>(wq); | |
35 | context_wq->queue(arg0, r); | |
36 | } | |
37 | ||
11fdf7f2 TL |
38 | ACTION_P(GetReference, ref_object) { |
39 | ref_object->get(); | |
40 | } | |
41 | ||
7c673cae FG |
42 | MATCHER_P(ContentsEqual, bl, "") { |
43 | // TODO fix const-correctness of bufferlist | |
44 | return const_cast<bufferlist &>(arg).contents_equal( | |
45 | const_cast<bufferlist &>(bl)); | |
46 | } | |
47 | ||
48 | namespace rbd { | |
49 | namespace mirror { | |
50 | ||
51 | class TestMockFixture : public TestFixture { | |
52 | public: | |
53 | typedef boost::shared_ptr<librados::TestCluster> TestClusterRef; | |
54 | ||
55 | static void SetUpTestCase(); | |
56 | static void TearDownTestCase(); | |
57 | ||
58 | void TearDown() override; | |
59 | ||
60 | void expect_test_features(librbd::MockImageCtx &mock_image_ctx); | |
61 | ||
11fdf7f2 TL |
62 | librados::MockTestMemCluster& get_mock_cluster(); |
63 | ||
7c673cae FG |
64 | private: |
65 | static TestClusterRef s_test_cluster; | |
66 | }; | |
67 | ||
68 | } // namespace mirror | |
69 | } // namespace rbd | |
70 | ||
71 | #endif // CEPH_TEST_RBD_MIRROR_TEST_MOCK_FIXTURE_H |