From 7b8a95ef78f6f44a3678a560985c21230534c8e6 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Thu, 31 Jan 2019 13:51:32 +0000 Subject: [PATCH] librados_test_stub: enable sparse_read Although it actually does not do sparse read, enabling it makes possible to link the same test code with both librados_test_stub and real librados. Signed-off-by: Mykola Golub --- src/test/librados_test_stub/LibradosTestStub.cc | 7 +++++++ src/test/librados_test_stub/TestMemIoCtxImpl.cc | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index f3cb4f864bc5a..cad42a3188167 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -655,6 +655,13 @@ void IoCtx::snap_set_read(snap_t seq) { ctx->set_snap_read(seq); } +int IoCtx::sparse_read(const std::string& oid, std::map& m, + bufferlist& bl, size_t len, uint64_t off) { + TestIoCtxImpl *ctx = reinterpret_cast(io_ctx_impl); + return ctx->execute_operation( + oid, boost::bind(&TestIoCtxImpl::sparse_read, _1, _2, off, len, &m, &bl)); +} + int IoCtx::stat(const std::string& oid, uint64_t *psize, time_t *pmtime) { TestIoCtxImpl *ctx = reinterpret_cast(io_ctx_impl); return ctx->execute_operation( diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index 9e160015ff066..4d6426293d783 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.cc @@ -468,6 +468,7 @@ int TestMemIoCtxImpl::sparse_read(const std::string& oid, uint64_t off, RWLock::RLocker l(file->lock); len = clip_io(off, len, file->data.length()); + // TODO support sparse read if (m != NULL) { m->clear(); if (len > 0) { @@ -479,7 +480,7 @@ int TestMemIoCtxImpl::sparse_read(const std::string& oid, uint64_t off, bit.substr_of(file->data, off, len); append_clone(bit, data_bl); } - return 0; + return len > 0 ? 1 : 0; } int TestMemIoCtxImpl::stat(const std::string& oid, uint64_t *psize, -- 2.39.5