From a72aaff66c86b7fdfb271e65f1e087c8b52033ca Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Thu, 21 Mar 2013 12:45:12 -0700 Subject: [PATCH] test: add ceph_rename test Triggers bug in ticket #4517 Signed-off-by: Noah Watkins --- src/test/libcephfs/test.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 74d4db36275..d35cfe6a72e 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -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);