From: Jeff Layton Date: Wed, 7 Feb 2018 20:59:47 +0000 (-0500) Subject: test: new testcase for ceph_ll_readv and ceph_ll_writev X-Git-Tag: v13.0.2~282^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b431d2879abdaad768df2b09b08cfc085825af80;p=ceph.git test: new testcase for ceph_ll_readv and ceph_ll_writev Just copy the PreadvPwritev test and alter accordingly. Tracker: http://tracker.ceph.com/issues/22948 Signed-off-by: Jeff Layton --- diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 30acadb9f7ed..1ccd84a0b877 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -1081,6 +1081,53 @@ TEST(LibCephFS, PreadvPwritev) { ceph_shutdown(cmount); } +TEST(LibCephFS, LlreadvLlwritev) { + struct ceph_mount_info *cmount; + ASSERT_EQ(ceph_create(&cmount, NULL), 0); + ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + ASSERT_EQ(ceph_mount(cmount, NULL), 0); + + int mypid = getpid(); + char filename[256]; + + sprintf(filename, "test_llreadvllwritevfile%u", mypid); + + Inode *root, *file; + ASSERT_EQ(ceph_ll_lookup_root(cmount, &root), 0); + + Fh *fh; + struct ceph_statx stx; + UserPerm *perms = ceph_mount_perms(cmount); + + ASSERT_EQ(ceph_ll_create(cmount, root, filename, 0666, + O_RDWR|O_CREAT|O_TRUNC, &file, &fh, &stx, 0, 0, perms), 0); + + /* Reopen read-only */ + char out0[] = "hello "; + char out1[] = "world\n"; + struct iovec iov_out[2] = { + {out0, sizeof(out0)}, + {out1, sizeof(out1)}, + }; + char in0[sizeof(out0)]; + char in1[sizeof(out1)]; + struct iovec iov_in[2] = { + {in0, sizeof(in0)}, + {in1, sizeof(in1)}, + }; + ssize_t nwritten = iov_out[0].iov_len + iov_out[1].iov_len; + ssize_t nread = iov_in[0].iov_len + iov_in[1].iov_len; + + ASSERT_EQ(ceph_ll_writev(cmount, fh, iov_out, 2, 0), nwritten); + ASSERT_EQ(ceph_ll_readv(cmount, fh, iov_in, 2, 0), nread); + ASSERT_EQ(0, strncmp((const char*)iov_in[0].iov_base, (const char*)iov_out[0].iov_base, iov_out[0].iov_len)); + ASSERT_EQ(0, strncmp((const char*)iov_in[1].iov_base, (const char*)iov_out[1].iov_base, iov_out[1].iov_len)); + + ceph_ll_close(cmount, fh); + ceph_shutdown(cmount); +} + TEST(LibCephFS, StripeUnitGran) { struct ceph_mount_info *cmount; ASSERT_EQ(ceph_create(&cmount, NULL), 0);