From: David Disseldorp Date: Mon, 15 Apr 2019 18:11:40 +0000 (+0200) Subject: test: check listattr for snapshot btime entry X-Git-Tag: v14.2.2~95^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f3dbdd3777bfd483ab1542e006bf45539d33396;p=ceph.git test: check listattr for snapshot btime entry Extend LibCephFS.SnapXattrs to also test ceph_listxattr() against snapshot and non-snapshot files. Signed-off-by: David Disseldorp (cherry picked from commit 8fd96203001f4a7263875690c66cb3808095413d) --- diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 343aab9b288..9dd0e1c69eb 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -2257,5 +2257,33 @@ TEST(LibCephFS, SnapXattrs) { utime_t new_btime = utime_t(strtoull(gxattrv2, NULL, 10), strtoull(s + 1, NULL, 10)); ASSERT_LT(btime, new_btime); + // check that the snap.btime vxattr appears in listxattr() + char xattrlist[512]; + int len = ceph_listxattr(cmount, c_temp, xattrlist, sizeof(xattrlist)); + ASSERT_GT(len, 0); + ASSERT_GE(sizeof(xattrlist), (size_t)len); + char *p = xattrlist; + int found = 0; + while (len > 0) { + if (strcmp(p, "ceph.snap.btime") == 0) + found++; + len -= strlen(p) + 1; + p += strlen(p) + 1; + } + ASSERT_EQ(found, 1); + + // listxattr() shouldn't return snap.btime vxattr for non-snaps + len = ceph_listxattr(cmount, test_snap_xattr_file, xattrlist, sizeof(xattrlist)); + ASSERT_GE(sizeof(xattrlist), (size_t)len); + p = xattrlist; + found = 0; + while (len > 0) { + if (strcmp(p, "ceph.snap.btime") == 0) + found++; + len -= strlen(p) + 1; + p += strlen(p) + 1; + } + ASSERT_EQ(found, 0); + ceph_shutdown(cmount); }