From 03b79abd123eb2b4692c2d647eeb0ca45d7dab42 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 7 Dec 2015 16:11:27 -0500 Subject: [PATCH] librados_test_stub: additional definitions and mock functions Signed-off-by: Jason Dillaman --- src/test/librados_test_stub/LibradosTestStub.cc | 13 +++++++++++++ src/test/librados_test_stub/MockTestMemIoCtxImpl.h | 8 ++++++++ .../librados_test_stub/MockTestMemRadosClient.h | 8 ++++++++ 3 files changed, 29 insertions(+) diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index 220a0ea94e11a..99a8f444be2de 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -661,6 +661,19 @@ void ObjectReadOperation::list_snaps(snap_set_t *out_snaps, int *prval) { o->ops.push_back(op); } +void ObjectReadOperation::list_watchers(std::list *out_watchers, + int *prval) { + TestObjectOperationImpl *o = reinterpret_cast(impl); + + ObjectOperationTestImpl op = boost::bind(&TestIoCtxImpl::list_watchers, _1, + _2, out_watchers); + if (prval != NULL) { + op = boost::bind(save_operation_result, + boost::bind(op, _1, _2, _3, _4), prval); + } + o->ops.push_back(op); +} + void ObjectReadOperation::read(size_t off, uint64_t len, bufferlist *pbl, int *prval) { TestObjectOperationImpl *o = reinterpret_cast(impl); diff --git a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h index 596436b33e727..b0a481b56708b 100644 --- a/src/test/librados_test_stub/MockTestMemIoCtxImpl.h +++ b/src/test/librados_test_stub/MockTestMemIoCtxImpl.h @@ -48,6 +48,13 @@ public: snapc); } + MOCK_METHOD2(list_watchers, int(const std::string& o, + std::list *out_watchers)); + int do_list_watchers(const std::string& o, + std::list *out_watchers) { + return TestMemIoCtxImpl::list_watchers(o, out_watchers); + } + MOCK_METHOD4(read, int(const std::string& oid, size_t len, uint64_t off, @@ -92,6 +99,7 @@ public: using namespace ::testing; ON_CALL(*this, exec(_, _, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_exec)); + ON_CALL(*this, list_watchers(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_list_watchers)); ON_CALL(*this, read(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_read)); ON_CALL(*this, remove(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_remove)); ON_CALL(*this, selfmanaged_snap_create(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_create)); diff --git a/src/test/librados_test_stub/MockTestMemRadosClient.h b/src/test/librados_test_stub/MockTestMemRadosClient.h index 1d0b994afa629..9afde338f62fd 100644 --- a/src/test/librados_test_stub/MockTestMemRadosClient.h +++ b/src/test/librados_test_stub/MockTestMemRadosClient.h @@ -24,10 +24,18 @@ public: this, this, pool_id, pool_name, get_pool(pool_name)); } + MOCK_METHOD2(blacklist_add, int(const std::string& client_address, + uint32_t expire_seconds)); + int do_blacklist_add(const std::string& client_address, + uint32_t expire_seconds) { + return TestMemRadosClient::blacklist_add(client_address, expire_seconds); + } + void default_to_dispatch() { using namespace ::testing; ON_CALL(*this, create_ioctx(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_create_ioctx)); + ON_CALL(*this, blacklist_add(_, _)).WillByDefault(Invoke(this, &MockTestMemRadosClient::do_blacklist_add)); } }; -- 2.39.5