]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: Functional test for hardlink/unmount pattern
authorSam Lang <sam.lang@inktank.com>
Fri, 19 Oct 2012 16:38:33 +0000 (11:38 -0500)
committerSam Lang <sam.lang@inktank.com>
Mon, 29 Oct 2012 15:40:42 +0000 (10:40 -0500)
This test currently breaks on libcephfs as reported
in #3367.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/test/libcephfs/test.cc

index 85600f98bd7b57cdd71b41229dc9a8b8f73e4259..154c81a5c082ef538e1428637093aeb2b1c04eee 100644 (file)
@@ -551,3 +551,44 @@ TEST(LibCephFS, Symlinks) {
 
   ceph_shutdown(cmount);
 }
+
+TEST(LibCephFS, Hardlink_no_original) {
+
+  int mypid = getpid();
+
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(ceph_create(&cmount, NULL), 0);
+  ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
+  ASSERT_EQ(ceph_mount(cmount, NULL), 0);
+
+  char dir[256];
+  sprintf(dir, "/test_rmdirfail%d", mypid);
+  ASSERT_EQ(ceph_mkdir(cmount, dir, 0777), 0);
+
+  ASSERT_EQ(ceph_chdir(cmount, dir), 0);
+
+  int fd = ceph_open(cmount, "f1", O_CREAT, 0644);
+  ASSERT_GT(fd, 0);
+
+  ceph_close(cmount, fd);
+
+  // create hard link
+  ASSERT_EQ(ceph_link(cmount, "f1", "hardl1"), 0);
+
+  // remove file link points to
+  ASSERT_EQ(ceph_unlink(cmount, "f1"), 0);
+
+  ceph_shutdown(cmount);
+
+  // now cleanup
+  ASSERT_EQ(ceph_create(&cmount, NULL), 0);
+  ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
+  ASSERT_EQ(ceph_mount(cmount, NULL), 0);
+  ASSERT_EQ(ceph_chdir(cmount, dir), 0);
+  ASSERT_EQ(ceph_unlink(cmount, "hardl1"), 0);
+  ASSERT_EQ(ceph_rmdir(cmount, dir), 0);
+
+  ceph_shutdown(cmount);
+}
+
+