X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Flibrbd%2Fmock%2FMockObjectMap.h;fp=src%2Fceph%2Fsrc%2Ftest%2Flibrbd%2Fmock%2FMockObjectMap.h;h=26e979eed5c201b384d4adff61ebf6f632a1142d;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/test/librbd/mock/MockObjectMap.h b/src/ceph/src/test/librbd/mock/MockObjectMap.h new file mode 100644 index 0000000..26e979e --- /dev/null +++ b/src/ceph/src/test/librbd/mock/MockObjectMap.h @@ -0,0 +1,60 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_TEST_LIBRBD_MOCK_OBJECT_MAP_H +#define CEPH_TEST_LIBRBD_MOCK_OBJECT_MAP_H + +#include "common/RWLock.h" +#include "librbd/Utils.h" +#include "gmock/gmock.h" + +namespace librbd { + +struct MockObjectMap { + MOCK_CONST_METHOD1(enabled, bool(const RWLock &object_map_lock)); + + MOCK_METHOD1(open, void(Context *on_finish)); + MOCK_METHOD1(close, void(Context *on_finish)); + + MOCK_METHOD3(aio_resize, void(uint64_t new_size, uint8_t default_object_state, + Context *on_finish)); + + template + bool aio_update(uint64_t snap_id, uint64_t start_object_no, uint8_t new_state, + const boost::optional ¤t_state, + const ZTracer::Trace &parent_trace, T *callback_object) { + return aio_update(snap_id, start_object_no, start_object_no + 1, + new_state, current_state, parent_trace, + callback_object); + } + + template + bool aio_update(uint64_t snap_id, uint64_t start_object_no, + uint64_t end_object_no, uint8_t new_state, + const boost::optional ¤t_state, + const ZTracer::Trace &parent_trace, T *callback_object) { + auto ctx = util::create_context_callback(callback_object); + bool updated = aio_update(snap_id, start_object_no, end_object_no, + new_state, current_state, parent_trace, ctx); + if (!updated) { + delete ctx; + } + return updated; + } + MOCK_METHOD7(aio_update, bool(uint64_t snap_id, uint64_t start_object_no, + uint64_t end_object_no, uint8_t new_state, + const boost::optional ¤t_state, + const ZTracer::Trace &parent_trace, + Context *on_finish)); + + MOCK_METHOD2(snapshot_add, void(uint64_t snap_id, Context *on_finish)); + MOCK_METHOD2(snapshot_remove, void(uint64_t snap_id, Context *on_finish)); + MOCK_METHOD2(rollback, void(uint64_t snap_id, Context *on_finish)); + + MOCK_CONST_METHOD1(object_may_exist, bool(uint64_t)); + +}; + +} // namespace librbd + +#endif // CEPH_TEST_LIBRBD_MOCK_OBJECT_MAP_H