]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add ceph_rename test 130/head
authorNoah Watkins <noahwatkins@gmail.com>
Thu, 21 Mar 2013 19:45:12 +0000 (12:45 -0700)
committerNoah Watkins <noahwatkins@gmail.com>
Thu, 21 Mar 2013 19:54:17 +0000 (12:54 -0700)
Triggers bug in ticket #4517

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/test/libcephfs/test.cc

index 74d4db36275443b982d0255672a5afe9d78298ac..d35cfe6a72e9dec9f47e5e80ad9d4a857bc29c2d 100644 (file)
@@ -821,6 +821,37 @@ TEST(LibCephFS, StripeUnitGran) {
   ceph_shutdown(cmount);
 }
 
+TEST(LibCephFS, Rename) {
+  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);
+
+  int mypid = getpid();
+  char path_src[256];
+  char path_dst[256];
+
+  /* make a source file */
+  sprintf(path_src, "test_rename_src%d", mypid);
+  int fd = ceph_open(cmount, path_src, O_CREAT|O_TRUNC|O_WRONLY, 0777);
+  ASSERT_GT(fd, 0);
+  ASSERT_EQ(0, ceph_close(cmount, fd));
+
+  /* rename to a new dest path */
+  sprintf(path_dst, "test_rename_dst%d", mypid);
+  ASSERT_EQ(0, ceph_rename(cmount, path_src, path_dst));
+
+  /* test that dest path exists */
+  struct stat st;
+  ASSERT_EQ(0, ceph_lstat(cmount, path_dst, &st));
+
+  /* test that src path doesn't exist */
+  ASSERT_EQ(-ENOENT, ceph_lstat(cmount, path_src, &st));
+
+  ASSERT_EQ(0, ceph_unlink(cmount, path_dst));
+  ceph_shutdown(cmount);
+}
+
 TEST(LibCephFS, UseUnmounted) {
   struct ceph_mount_info *cmount;
   ASSERT_EQ(ceph_create(&cmount, NULL), 0);