Skip to content

Commit ec30c46

Browse files
committed
test/libcephfs: move FsCrypt xattr test to dedicated test file
Switch to use XATTR_CREATE. Fixes: https://tracker.ceph.com/issues/64679 Signed-off-by: Xiubo Li <[email protected]>
1 parent 797e926 commit ec30c46

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

src/test/libcephfs/test.cc

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,39 +3520,6 @@ TEST(LibCephFS, SetMountTimeout) {
35203520
ceph_shutdown(cmount);
35213521
}
35223522

3523-
TEST(LibCephFS, FsCrypt) {
3524-
struct ceph_mount_info *cmount;
3525-
ASSERT_EQ(ceph_create(&cmount, NULL), 0);
3526-
ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
3527-
ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
3528-
ASSERT_EQ(ceph_mount(cmount, NULL), 0);
3529-
3530-
char test_xattr_file[NAME_MAX];
3531-
sprintf(test_xattr_file, "test_fscrypt_%d", getpid());
3532-
int fd = ceph_open(cmount, test_xattr_file, O_RDWR|O_CREAT, 0666);
3533-
ASSERT_GT(fd, 0);
3534-
3535-
ASSERT_EQ(0, ceph_fsetxattr(cmount, fd, "ceph.fscrypt.auth", "foo", 3, CEPH_XATTR_CREATE));
3536-
ASSERT_EQ(0, ceph_fsetxattr(cmount, fd, "ceph.fscrypt.file", "foo", 3, CEPH_XATTR_CREATE));
3537-
3538-
char buf[64];
3539-
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.auth", buf, sizeof(buf)));
3540-
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.file", buf, sizeof(buf)));
3541-
ASSERT_EQ(0, ceph_close(cmount, fd));
3542-
3543-
ASSERT_EQ(0, ceph_unmount(cmount));
3544-
ASSERT_EQ(0, ceph_mount(cmount, NULL));
3545-
3546-
fd = ceph_open(cmount, test_xattr_file, O_RDWR, 0666);
3547-
ASSERT_GT(fd, 0);
3548-
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.auth", buf, sizeof(buf)));
3549-
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.file", buf, sizeof(buf)));
3550-
3551-
ASSERT_EQ(0, ceph_close(cmount, fd));
3552-
ASSERT_EQ(0, ceph_unmount(cmount));
3553-
ceph_shutdown(cmount);
3554-
}
3555-
35563523
TEST(LibCephFS, SnapdirAttrs) {
35573524
struct ceph_mount_info *cmount;
35583525
ASSERT_EQ(ceph_create(&cmount, NULL), 0);

src/test/libcephfs/vxattr.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,37 @@ TEST(LibCephFS, GetAndSetDirRandom) {
383383

384384
ceph_shutdown(cmount);
385385
}
386+
387+
TEST(LibCephFS, FsCrypt) {
388+
struct ceph_mount_info *cmount;
389+
ASSERT_EQ(ceph_create(&cmount, NULL), 0);
390+
ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
391+
ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
392+
ASSERT_EQ(ceph_mount(cmount, NULL), 0);
393+
394+
char test_xattr_file[NAME_MAX];
395+
sprintf(test_xattr_file, "test_fscrypt_%d", getpid());
396+
int fd = ceph_open(cmount, test_xattr_file, O_RDWR|O_CREAT, 0666);
397+
ASSERT_GT(fd, 0);
398+
399+
ASSERT_EQ(0, ceph_fsetxattr(cmount, fd, "ceph.fscrypt.auth", "foo", 3, XATTR_CREATE));
400+
ASSERT_EQ(0, ceph_fsetxattr(cmount, fd, "ceph.fscrypt.file", "foo", 3, XATTR_CREATE));
401+
402+
char buf[64];
403+
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.auth", buf, sizeof(buf)));
404+
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.file", buf, sizeof(buf)));
405+
ASSERT_EQ(0, ceph_close(cmount, fd));
406+
407+
ASSERT_EQ(0, ceph_unmount(cmount));
408+
ASSERT_EQ(0, ceph_mount(cmount, NULL));
409+
410+
fd = ceph_open(cmount, test_xattr_file, O_RDWR, 0666);
411+
ASSERT_GT(fd, 0);
412+
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.auth", buf, sizeof(buf)));
413+
ASSERT_EQ(3, ceph_fgetxattr(cmount, fd, "ceph.fscrypt.file", buf, sizeof(buf)));
414+
415+
ASSERT_EQ(0, ceph_close(cmount, fd));
416+
ASSERT_EQ(0, ceph_unmount(cmount));
417+
ceph_shutdown(cmount);
418+
}
419+

0 commit comments

Comments
 (0)