]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_libcephfs: fix update-after-unlink test
authorSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 20:52:27 +0000 (16:52 -0400)
committerSage Weil <sage@redhat.com>
Thu, 1 Oct 2015 13:42:35 +0000 (09:42 -0400)
This needs to be done with a user restricted to a path.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/libcephfs/access.cc

index 6413ab7c931f16179f98232b8daf502e6d6edb35..cc4e944c727a09506c9546cdd09c5a89a3b56d9c 100644 (file)
@@ -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);