]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: check listattr for snapshot btime entry 27077/head
authorDavid Disseldorp <ddiss@suse.de>
Mon, 15 Apr 2019 18:11:40 +0000 (20:11 +0200)
committerDavid Disseldorp <ddiss@suse.de>
Mon, 15 Apr 2019 23:31:04 +0000 (01:31 +0200)
Extend LibCephFS.SnapXattrs to also test ceph_listxattr() against
snapshot and non-snapshot files.

Signed-off-by: David Disseldorp <ddiss@suse.de>
src/test/libcephfs/test.cc

index 343aab9b2887eba6706f1569f178a786f00d404c..9dd0e1c69ebe25f3db5b84f4797606290766ac35 100644 (file)
@@ -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);
 }