Skip to content

Commit 28bdb8e

Browse files
committed
test/libcephfs: test getcwd with case insensitive dir
Unfortunately, it's not easy to refactor this test into a shared method without setting up an explicit test class which has been avoided up to this point. So I'm going to just copy the code. Sorry. Signed-off-by: Patrick Donnelly <[email protected]>
1 parent d62a379 commit 28bdb8e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/test/libcephfs/test.cc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,55 @@ TEST(LibCephFS, ManyNestedDirs) {
562562
ceph_shutdown(cmount);
563563
}
564564

565+
TEST(LibCephFS, ManyNestedDirsCaseInsensitive) {
566+
struct ceph_mount_info *cmount;
567+
ASSERT_EQ(ceph_create(&cmount, NULL), 0);
568+
ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
569+
ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
570+
ASSERT_EQ(ceph_mount(cmount, NULL), 0);
571+
572+
static const char many_path[] = "/ManyNestedDirsCaseInsensitive/A/a/a/a/a/b/B/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/Aa";
573+
const filepath mfp = filepath(many_path);
574+
ASSERT_EQ(0, ceph_mkdir(cmount, mfp[0].c_str(), 0755));
575+
ASSERT_EQ(0, ceph_setxattr(cmount, mfp[0].c_str(), "ceph.dir.casesensitive", (void *) "0", 1, XATTR_CREATE));
576+
ASSERT_EQ(ceph_mkdirs(cmount, many_path, 0755), 0);
577+
578+
for (auto& component : mfp) {
579+
struct ceph_dir_result *dirp;
580+
ASSERT_EQ(ceph_opendir(cmount, ".", &dirp), 0);
581+
struct dirent *dent = ceph_readdir(cmount, dirp);
582+
ASSERT_TRUE(dent != NULL);
583+
ASSERT_STREQ(dent->d_name, ".");
584+
dent = ceph_readdir(cmount, dirp);
585+
ASSERT_TRUE(dent != NULL);
586+
ASSERT_STREQ(dent->d_name, "..");
587+
if (component == "ManyNestedDirsCaseInsensitive"sv) {
588+
ASSERT_EQ(0, ceph_chdir(cmount, component.c_str()));
589+
continue;
590+
}
591+
dent = ceph_readdir(cmount, dirp);
592+
ASSERT_TRUE(dent != NULL);
593+
ASSERT_STREQ(component.c_str(), dent->d_name);
594+
ASSERT_EQ(ceph_chdir(cmount, dent->d_name), 0);
595+
ASSERT_EQ(ceph_closedir(cmount, dirp), 0);
596+
}
597+
598+
{
599+
auto* cwd = ceph_getcwd(cmount);
600+
ASSERT_STREQ(cwd, many_path);
601+
}
602+
603+
for (auto it = mfp.rbegin(); it != mfp.rend(); ++it) {
604+
auto& component = *it;
605+
ASSERT_EQ(ceph_chdir(cmount, ".."), 0);
606+
ASSERT_EQ(ceph_rmdir(cmount, component.c_str()), 0);
607+
}
608+
609+
ASSERT_STREQ(ceph_getcwd(cmount), "/");
610+
611+
ceph_shutdown(cmount);
612+
}
613+
565614
TEST(LibCephFS, Xattrs) {
566615
struct ceph_mount_info *cmount;
567616
ASSERT_EQ(ceph_create(&cmount, NULL), 0);

0 commit comments

Comments
 (0)