mirror of
https://github.com/ceph/ceph
synced 2024-12-18 09:25:49 +00:00
Merge pull request #130 from ceph/wip-fs-rename
test: add ceph_rename test Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
commit
0d3f065c23
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user