diff options
author | John Spray <jspray@redhat.com> | 2016-10-25 12:59:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-25 12:59:11 +0200 |
commit | e5c43e9d9065e535ca1553dd713a55f9aa58535a (patch) | |
tree | 06e9429e6f9813b02d4fe8a26d45b0e2798a8ccb /src/test/libcephfs | |
parent | Merge pull request #11560 from ukernel/wip-mds-context-wrapping (diff) | |
parent | test/libcephfs: add ceph_fsetattr() test (diff) | |
download | ceph-e5c43e9d9065e535ca1553dd713a55f9aa58535a.tar.xz ceph-e5c43e9d9065e535ca1553dd713a55f9aa58535a.zip |
Merge pull request #11191 from renhwztetecs/renhw-wip-add-libcephfs
libcephfs: add ceph_fsetattr&&ceph_lchmod&&ceph_lutime
Reviewed-by: John Spray <john.spray@redhat.com>
Diffstat (limited to 'src/test/libcephfs')
-rw-r--r-- | src/test/libcephfs/test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 60999b6f40d..3fe62a79035 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -1157,6 +1157,7 @@ TEST(LibCephFS, UseUnmounted) { EXPECT_EQ(-ENOTCONN, ceph_lremovexattr(cmount, "/path", "name")); EXPECT_EQ(-ENOTCONN, ceph_setxattr(cmount, "/path", "name", NULL, 0, 0)); EXPECT_EQ(-ENOTCONN, ceph_lsetxattr(cmount, "/path", "name", NULL, 0, 0)); + EXPECT_EQ(-ENOTCONN, ceph_fsetattr(cmount, 0, &st, 0)); EXPECT_EQ(-ENOTCONN, ceph_chmod(cmount, "/path", 0)); EXPECT_EQ(-ENOTCONN, ceph_fchmod(cmount, 0, 0)); EXPECT_EQ(-ENOTCONN, ceph_chown(cmount, "/path", 0, 0)); @@ -1669,3 +1670,30 @@ TEST(LibCephFS, DirChangeAttr) { ceph_shutdown(cmount); } + +TEST(LibCephFS, SetSize) { + struct ceph_mount_info *cmount; + ASSERT_EQ(ceph_create(&cmount, NULL), 0); + ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + ASSERT_EQ(ceph_mount(cmount, "/"), 0); + + char filename[32]; + sprintf(filename, "/setsize%x", getpid()); + + ceph_unlink(cmount, filename); + int fd = ceph_open(cmount, filename, O_RDWR|O_CREAT|O_EXCL, 0666); + ASSERT_LT(0, fd); + + struct stat st; + uint64_t size = 8388608; + st.st_size = (off_t)size; + ASSERT_EQ(ceph_fsetattr(cmount, fd, &st, CEPH_SETATTR_SIZE), 0); + + struct stat stbuf; + ASSERT_EQ(ceph_fstat(cmount, fd, &stbuf), 0); + ASSERT_EQ(stbuf.st_size, (off_t)size); + + ceph_close(cmount, fd); + ceph_shutdown(cmount); +} |