]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph_test_rados_api_io_pp: add multiple extents test for sparse-read
authorXiubo Li <xiubli@redhat.com>
Fri, 27 Oct 2023 11:29:04 +0000 (19:29 +0800)
committerXiubo Li <xiubli@redhat.com>
Mon, 6 Nov 2023 01:41:42 +0000 (09:41 +0800)
Just test more with a larger size to test the sparse-read to find
some corner case bugs.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/test/librados/io_cxx.cc

index d9606d16bcaad8d165bc48e9a198f56e8b36d3a6..f20518111010857d3f3486e6154fa5ea9796dbbb 100644 (file)
@@ -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<uint64_t, uint64_t> 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;