From c7b0bd95f4ff80914ae03f521c9d5a3cbf4b1435 Mon Sep 17 00:00:00 2001 From: Ziao <1575538687@qq.com> Date: Tue, 21 Nov 2023 16:14:08 -0800 Subject: [PATCH] change the API of direntry (should pass new dir_API.cpp test) --- test/dir_API.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/dir_API.cpp b/test/dir_API.cpp index b6f081b..283dd04 100644 --- a/test/dir_API.cpp +++ b/test/dir_API.cpp @@ -99,6 +99,8 @@ TEST(DirTest, Add_FindFile_test) { /**********************************************************/ //add one more file under dir1 fischl_add_entry(get_dir->subdirectory, 5, "file3",&inode_file); + //add one more directory under dir1 + fischl_add_entry(get_dir->subdirectory, 6, "dir2", &inode_dir); //find get_file = fischl_find_entry(get_dir->subdirectory,"./file3"); EXPECT_TRUE(get_file != NULL); @@ -117,6 +119,15 @@ TEST(DirTest, Add_FindFile_test) { EXPECT_TRUE(get_dir != NULL);//detect this should find success EXPECT_STREQ(get_dir->name, "/"); ASSERT_TRUE(get_dir->subdirectory != NULL);//secure it is directory + //use .. to access parent directory + get_dir = fischl_find_entry(root, "/dir1/dir2/.."); + EXPECT_TRUE(get_dir != NULL); + EXPECT_STREQ(get_dir->name, "dir1"); + FileNode *get_rootdir = fischl_find_entry(root, "/dir1/dir2/../.."); + EXPECT_TRUE(get_rootdir != NULL); + EXPECT_STREQ(get_rootdir->name, "/"); + EXPECT_TRUE(get_rootdir->subdirectory != NULL); + EXPECT_TRUE(get_rootdir->subdirectory->self_info == get_rootdir); } int main(int argc, char **argv) {