From: Sage Weil Date: Tue, 1 Sep 2015 20:52:27 +0000 (-0400) Subject: ceph_test_libcephfs: fix update-after-unlink test X-Git-Tag: v10.0.0~123^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=269e2de0cd87d0b8013553806ac6d12fb38a6881;p=ceph.git ceph_test_libcephfs: fix update-after-unlink test This needs to be done with a user restricted to a path. Signed-off-by: Sage Weil --- diff --git a/src/test/libcephfs/access.cc b/src/test/libcephfs/access.cc index 6413ab7c931f..cc4e944c727a 100644 --- a/src/test/libcephfs/access.cc +++ b/src/test/libcephfs/access.cc @@ -99,7 +99,7 @@ TEST(AccessTest, Foo) { ceph_shutdown(admin); } -TEST(AccessTest, Path){ +TEST(AccessTest, Path) { struct ceph_mount_info *admin; ASSERT_EQ(0, ceph_create(&admin, NULL)); ASSERT_EQ(0, ceph_conf_parse_env(admin, NULL)); @@ -152,6 +152,15 @@ TEST(AccessTest, Path){ fd = ceph_open(cmount, "/foobar/y", O_CREAT|O_WRONLY, 0755); ASSERT_LT(fd, 0); + // update after unlink + fd = ceph_open(cmount, "/bar/unlinkme", O_CREAT|O_WRONLY, 0755); + ceph_unlink(cmount, "/bar/unlinkme"); + ASSERT_GE(ceph_write(cmount, fd, "foo", 3, 0), 0); + ASSERT_GE(ceph_fchmod(cmount, fd, 0777), 0); + ASSERT_GE(ceph_ftruncate(cmount, fd, 0), 0); + ASSERT_GE(ceph_fsetxattr(cmount, fd, "user.any", "bar", 3, 0), 0); + ceph_close(cmount, fd); + ceph_shutdown(cmount); ASSERT_EQ(0, ceph_unlink(admin, "/foobar/q")); ASSERT_EQ(0, ceph_unlink(admin, "/foobar/z")); @@ -202,25 +211,6 @@ TEST(AccessTest, ReadOnly){ ceph_shutdown(admin); } -TEST(AccessTest, update_after_unlink){ - struct ceph_mount_info *admin; - ASSERT_EQ(0, ceph_create(&admin, NULL)); - ASSERT_EQ(0, ceph_conf_parse_env(admin, NULL)); - ASSERT_EQ(0, ceph_conf_read_file(admin, NULL)); - ASSERT_EQ(0, ceph_mount(admin, "/")); - ASSERT_EQ(0, ceph_mkdir(admin, "/foo", 0755)); - int fd = ceph_open(admin, "/foo/bar", O_CREAT|O_WRONLY, 0755); - ceph_unlink(admin, "/foo/bar"); - ASSERT_GE(ceph_write(admin, fd, "foo", 3, 0), 0); - ASSERT_GE(ceph_fchmod(admin, fd, 0777), 0); - ASSERT_GE(ceph_ftruncate(admin, fd, 0), 0); - ASSERT_GE(ceph_fsetxattr(admin, fd, "user.any", "bar", 3, 0), 0); - ceph_close(admin,fd); - - ASSERT_EQ(0, ceph_rmdir(admin, "/foo")); - ceph_shutdown(admin); -} - int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv);