diff options
author | Andrey Kuznetsov <Andrey_Kuznetsov@epam.com> | 2013-07-10 14:41:58 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-09-04 17:53:30 -0700 |
commit | a2c8067898010a2ec5767c882b53323670ff2293 (patch) | |
tree | 025691a76c76c3595d60ca7fe724841e628e3112 | |
parent | 38a31eaec3e6ddfc7aebce36a4bd346d50085fe6 (diff) | |
download | ceph-a2c8067898010a2ec5767c882b53323670ff2293.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) { |