diff options
author | Andrey Kuznetsov <Andrey_Kuznetsov@epam.com> | 2013-07-10 14:41:58 -0700 |
---|---|---|
committer | David Zafman <david.zafman@inktank.com> | 2013-10-03 15:23:02 -0700 |
commit | d82b0bb3dff5e8872c1171ac28e3c01894e62882 (patch) | |
tree | a729bb56f73c03c7d3c8c099d7a128f297709cf5 | |
parent | 838c344bad79e40023a93572ad663c48331d0512 (diff) | |
download | ceph-d82b0bb3dff5e8872c1171ac28e3c01894e62882.tar.gz |
libcephfs: add an xattr ll test
Signed-off-by: Andrey Kuznetsov <Andrey_Kuznetsov@epam.com>
-rw-r--r-- | src/test/libcephfs/test.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 597d049e2a4..6de52c20d00 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -471,6 +471,45 @@ TEST(LibCephFS, Xattrs) { ceph_close(cmount, fd); ceph_shutdown(cmount); + +} + +TEST(LibCephFS, Xattrs_ll) { + struct ceph_mount_info *cmount; + ASSERT_EQ(ceph_create(&cmount, NULL), 0); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0); + ASSERT_EQ(ceph_mount(cmount, NULL), 0); + + char test_xattr_file[256]; + sprintf(test_xattr_file, "test_xattr_%d", getpid()); + int fd = ceph_open(cmount, test_xattr_file, O_CREAT, 0666); + ASSERT_GT(fd, 0); + ceph_close(cmount, fd); + + Inode *root = NULL; + Inode *existent_file_handle = NULL; + struct stat attr; + + int res = ceph_ll_lookup_root(cmount, &root); + ASSERT_EQ(res, 0); + res = ceph_ll_lookup(cmount, root, test_xattr_file, &attr, &existent_file_handle, 0, 0); + ASSERT_EQ(res, 0); + + const char *valid_name = "user.attrname"; + const char *value = "attrvalue"; + char value_buf[256] = { 0 }; + + res = ceph_ll_setxattr(cmount, existent_file_handle, valid_name, value, strlen(value), 0, 0, 0); + ASSERT_EQ(res, 0); + + res = ceph_ll_getxattr(cmount, existent_file_handle, valid_name, value_buf, 256, 0, 0); + ASSERT_EQ(res, (int)strlen(value)); + + value_buf[res] = '\0'; + ASSERT_STREQ(value_buf, value); + + ceph_shutdown(cmount); } TEST(LibCephFS, LstatSlashdot) { |