From 3afae90cd3ecdbf7489d1589e572460966e87c48 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 27 Oct 2023 19:29:04 +0800 Subject: [PATCH] ceph_test_rados_api_io_pp: add multiple extents test for sparse-read Just test more with a larger size to test the sparse-read to find some corner case bugs. Signed-off-by: Xiubo Li --- src/test/librados/io_cxx.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/test/librados/io_cxx.cc b/src/test/librados/io_cxx.cc index d9606d16bcaad..f205181110108 100644 --- a/src/test/librados/io_cxx.cc +++ b/src/test/librados/io_cxx.cc @@ -218,6 +218,39 @@ TEST_F(LibRadosIoPP, SparseReadOpPP) { } } +TEST_F(LibRadosIoPP, SparseReadExtentArrayOpPP) { + int buf_len = 32; + char buf[buf_len], zbuf[buf_len]; + memset(buf, 0xcc, buf_len); + memset(zbuf, 0, buf_len); + bufferlist bl; + int i, len = 1024, skip = 5; + bl.append(buf, buf_len); + for (i = 0; i < len; i++) { + if (!(i % skip) || i == (len - 1)) { + ASSERT_EQ(0, ioctx.write("sparse-read", bl, bl.length(), i * buf_len)); + } + } + + bufferlist expect_bl; + for (i = 0; i < len; i++) { + if (!(i % skip) || i == (len - 1)) { + expect_bl.append(buf, buf_len); + } else { + expect_bl.append(zbuf, buf_len); + } + } + + std::map extents; + bufferlist read_bl; + int rval = -1; + ObjectReadOperation op; + op.sparse_read(0, len * buf_len, &extents, &read_bl, &rval); + ASSERT_EQ(0, ioctx.operate("sparse-read", &op, nullptr)); + ASSERT_EQ(0, rval); + assert_eq_sparse(expect_bl, extents, read_bl); +} + TEST_F(LibRadosIoPP, RoundTripPP) { char buf[128]; Rados cluster; -- 2.47.3