]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/rbd_mirror/test_mock_fixture.h
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / test / rbd_mirror / test_mock_fixture.h
CommitLineData
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
14namespace librados {
15class TestRadosClient;
11fdf7f2 16class MockTestMemCluster;
7c673cae
FG
17class MockTestMemIoCtxImpl;
18class MockTestMemRadosClient;
19}
20
21namespace librbd {
22class MockImageCtx;
23}
24
b32b8144
FG
25ACTION_P(CopyInBufferlist, str) {
26 arg0->append(str);
27}
28
7c673cae
FG
29ACTION_P(CompleteContext, r) {
30 arg0->complete(r);
31}
32
33ACTION_P2(CompleteContext, wq, r) {
34 ContextWQ *context_wq = reinterpret_cast<ContextWQ *>(wq);
35 context_wq->queue(arg0, r);
36}
37
11fdf7f2
TL
38ACTION_P(GetReference, ref_object) {
39 ref_object->get();
40}
41
7c673cae
FG
42MATCHER_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
48namespace rbd {
49namespace mirror {
50
51class TestMockFixture : public TestFixture {
52public:
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
64private:
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