]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
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_LIBRBD_MOCK_IO_OBJECT_DISPATCH_H | |
5 | #define CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCH_H | |
6 | ||
7 | #include "gmock/gmock.h" | |
20effc67 | 8 | #include "common/ceph_mutex.h" |
11fdf7f2 TL |
9 | #include "librbd/io/ObjectDispatchInterface.h" |
10 | #include "librbd/io/Types.h" | |
11 | ||
12 | class Context; | |
13 | ||
14 | namespace librbd { | |
15 | namespace io { | |
16 | ||
17 | struct MockObjectDispatch : public ObjectDispatchInterface { | |
18 | public: | |
20effc67 | 19 | ceph::shared_mutex lock = ceph::make_shared_mutex("MockObjectDispatch::lock"); |
11fdf7f2 | 20 | |
20effc67 | 21 | MockObjectDispatch() {} |
11fdf7f2 | 22 | |
f67539c2 | 23 | MOCK_CONST_METHOD0(get_dispatch_layer, ObjectDispatchLayer()); |
11fdf7f2 TL |
24 | |
25 | MOCK_METHOD1(shut_down, void(Context*)); | |
26 | ||
f67539c2 TL |
27 | MOCK_METHOD6(execute_read, |
28 | bool(uint64_t, ReadExtents*, IOContext io_context, uint64_t*, | |
29 | DispatchResult*, Context*)); | |
11fdf7f2 | 30 | bool read( |
f67539c2 TL |
31 | uint64_t object_no, ReadExtents* extents, IOContext io_context, |
32 | int op_flags, int read_flags, const ZTracer::Trace& parent_trace, | |
33 | uint64_t* version, int* dispatch_flags, | |
11fdf7f2 TL |
34 | DispatchResult* dispatch_result, Context** on_finish, |
35 | Context* on_dispatched) { | |
f67539c2 TL |
36 | return execute_read(object_no, extents, io_context, version, |
37 | dispatch_result, on_dispatched); | |
11fdf7f2 TL |
38 | } |
39 | ||
40 | MOCK_METHOD9(execute_discard, | |
f67539c2 | 41 | bool(uint64_t, uint64_t, uint64_t, IOContext, int, |
11fdf7f2 TL |
42 | int*, uint64_t*, DispatchResult*, Context*)); |
43 | bool discard( | |
9f95a23c | 44 | uint64_t object_no, uint64_t object_off, uint64_t object_len, |
f67539c2 | 45 | IOContext io_context, int discard_flags, |
11fdf7f2 TL |
46 | const ZTracer::Trace &parent_trace, int* dispatch_flags, |
47 | uint64_t* journal_tid, DispatchResult* dispatch_result, | |
48 | Context** on_finish, Context* on_dispatched) { | |
f67539c2 | 49 | return execute_discard(object_no, object_off, object_len, io_context, |
11fdf7f2 TL |
50 | discard_flags, dispatch_flags, journal_tid, |
51 | dispatch_result, on_dispatched); | |
52 | } | |
53 | ||
f67539c2 | 54 | MOCK_METHOD10(execute_write, |
11fdf7f2 | 55 | bool(uint64_t, uint64_t, const ceph::bufferlist&, |
f67539c2 TL |
56 | IOContext, int, std::optional<uint64_t>, int*, |
57 | uint64_t*, DispatchResult*, Context *)); | |
11fdf7f2 | 58 | bool write( |
9f95a23c | 59 | uint64_t object_no, uint64_t object_off, ceph::bufferlist&& data, |
f67539c2 TL |
60 | IOContext io_context, int op_flags, int write_flags, |
61 | std::optional<uint64_t> assert_version, | |
11fdf7f2 TL |
62 | const ZTracer::Trace &parent_trace, int* dispatch_flags, |
63 | uint64_t* journal_tid, DispatchResult* dispatch_result, | |
64 | Context** on_finish, Context* on_dispatched) override { | |
f67539c2 TL |
65 | return execute_write(object_no, object_off, data, io_context, write_flags, |
66 | assert_version, dispatch_flags, journal_tid, | |
67 | dispatch_result, on_dispatched); | |
11fdf7f2 TL |
68 | } |
69 | ||
70 | MOCK_METHOD10(execute_write_same, | |
9f95a23c TL |
71 | bool(uint64_t, uint64_t, uint64_t, |
72 | const LightweightBufferExtents&, | |
f67539c2 | 73 | const ceph::bufferlist&, IOContext, int*, |
11fdf7f2 TL |
74 | uint64_t*, DispatchResult*, Context *)); |
75 | bool write_same( | |
9f95a23c TL |
76 | uint64_t object_no, uint64_t object_off, uint64_t object_len, |
77 | LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data, | |
f67539c2 | 78 | IOContext io_context, int op_flags, |
11fdf7f2 TL |
79 | const ZTracer::Trace &parent_trace, int* dispatch_flags, |
80 | uint64_t* journal_tid, DispatchResult* dispatch_result, | |
81 | Context* *on_finish, Context* on_dispatched) override { | |
82 | return execute_write_same(object_no, object_off, object_len, buffer_extents, | |
f67539c2 | 83 | data, io_context, dispatch_flags, journal_tid, |
11fdf7f2 TL |
84 | dispatch_result, on_dispatched); |
85 | } | |
86 | ||
87 | MOCK_METHOD9(execute_compare_and_write, | |
88 | bool(uint64_t, uint64_t, const ceph::bufferlist&, | |
89 | const ceph::bufferlist&, uint64_t*, int*, uint64_t*, | |
90 | DispatchResult*, Context *)); | |
91 | bool compare_and_write( | |
9f95a23c | 92 | uint64_t object_no, uint64_t object_off, ceph::bufferlist&& cmp_data, |
f67539c2 | 93 | ceph::bufferlist&& write_data, IOContext io_context, int op_flags, |
11fdf7f2 TL |
94 | const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset, |
95 | int* dispatch_flags, uint64_t* journal_tid, | |
96 | DispatchResult* dispatch_result, Context** on_finish, | |
97 | Context* on_dispatched) override { | |
98 | return execute_compare_and_write(object_no, object_off, cmp_data, | |
99 | write_data, mismatch_offset, | |
100 | dispatch_flags, journal_tid, | |
101 | dispatch_result, on_dispatched); | |
102 | } | |
103 | ||
9f95a23c | 104 | MOCK_METHOD4(execute_flush, bool(FlushSource, uint64_t*, DispatchResult*, |
11fdf7f2 TL |
105 | Context*)); |
106 | bool flush(FlushSource flush_source, const ZTracer::Trace &parent_trace, | |
9f95a23c TL |
107 | uint64_t* journal_tid, DispatchResult* dispatch_result, |
108 | Context** on_finish, Context* on_dispatched) { | |
109 | return execute_flush(flush_source, journal_tid, dispatch_result, | |
110 | on_dispatched); | |
11fdf7f2 TL |
111 | } |
112 | ||
f67539c2 TL |
113 | MOCK_METHOD7(execute_list_snaps, bool(uint64_t, const Extents&, |
114 | const SnapIds&, int, SnapshotDelta*, | |
115 | DispatchResult*, Context*)); | |
116 | bool list_snaps( | |
117 | uint64_t object_no, io::Extents&& extents, SnapIds&& snap_ids, | |
118 | int list_snaps_flags, const ZTracer::Trace &parent_trace, | |
119 | SnapshotDelta* snapshot_delta, int* object_dispatch_flags, | |
120 | DispatchResult* dispatch_result, Context** on_finish, | |
121 | Context* on_dispatched) override { | |
122 | return execute_list_snaps(object_no, extents, snap_ids, list_snaps_flags, | |
123 | snapshot_delta, dispatch_result, on_dispatched); | |
124 | } | |
125 | ||
11fdf7f2 TL |
126 | MOCK_METHOD1(invalidate_cache, bool(Context*)); |
127 | MOCK_METHOD1(reset_existence_cache, bool(Context*)); | |
128 | ||
129 | MOCK_METHOD5(extent_overwritten, void(uint64_t, uint64_t, uint64_t, uint64_t, | |
130 | uint64_t)); | |
f67539c2 | 131 | MOCK_METHOD2(prepare_copyup, int(uint64_t, SnapshotSparseBufferlist*)); |
11fdf7f2 TL |
132 | }; |
133 | ||
134 | } // namespace io | |
135 | } // namespace librbd | |
136 | ||
137 | #endif // CEPH_TEST_LIBRBD_MOCK_IO_OBJECT_DISPATCH_H |