aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/vfs.tests.cpp
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-05-02 14:15:26 +0200
committerLukas Oesch <lukasoesch20@gmail.com>2026-05-05 14:38:52 +0200
commit46f3992c10e960d33dbb314dad597650902686da (patch)
treef82b65b2c25e75650c7156208dc4dc946179de51 /kernel/src/filesystem/vfs.tests.cpp
parenta096d84920aa078b5775149a95e5d3f010ae995e (diff)
downloadkernel-46f3992c10e960d33dbb314dad597650902686da.tar.xz
kernel-46f3992c10e960d33dbb314dad597650902686da.zip
add relative path tests
Diffstat (limited to 'kernel/src/filesystem/vfs.tests.cpp')
-rw-r--r--kernel/src/filesystem/vfs.tests.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/kernel/src/filesystem/vfs.tests.cpp b/kernel/src/filesystem/vfs.tests.cpp
index 979ea42..109ee89 100644
--- a/kernel/src/filesystem/vfs.tests.cpp
+++ b/kernel/src/filesystem/vfs.tests.cpp
@@ -168,6 +168,52 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS
REQUIRE(vfs.unmount("/information/nonexistent") ==
kernel::filesystem::vfs::operation_result::mount_point_not_found);
}
+
+ THEN("a file can be access if . in the path")
+ {
+ auto info_1 = vfs.open("/information/./info_1.txt");
+ REQUIRE(info_1 != nullptr);
+ }
+
+ THEN("a file can be accessed within the same mount if path contains .. ")
+ {
+ auto info_1 = vfs.open("/archiv/../information/info_1.txt");
+ REQUIRE(info_1 != nullptr);
+
+ auto img = vfs.open("/archiv/../information/../archiv/2024.img");
+ REQUIRE(img != nullptr);
+ }
+
+ THEN("a file can be accessed over multiple mounts if path contains .. or . ")
+ {
+ REQUIRE(vfs.do_mount("/dev/ram16", "/information") == kernel::filesystem::vfs::operation_result::success);
+
+ auto img = vfs.open("/information/monkey_house/caretaker/../../../archiv/2024.img");
+ REQUIRE(img != nullptr);
+
+ auto dev_32 = vfs.open("/information/monkey_house/caretaker/../../../dev/ram32");
+ REQUIRE(dev_32 != nullptr);
+
+ auto water = vfs.open("/information/./monkey_house/infrastructure/water.txt");
+ REQUIRE(water != nullptr);
+ }
+
+ THEN("a file can be accessed over multiple mounts (device and file) if path contains .. ")
+ {
+ REQUIRE(vfs.do_mount("/dev/ram16", "/information") == kernel::filesystem::vfs::operation_result::success);
+ REQUIRE(vfs.do_mount("/archiv/2024.img", "/information/monkey_house/infrastructure") ==
+ kernel::filesystem::vfs::operation_result::success);
+
+ auto pig_1 = vfs.open("/information/monkey_house/infrastructure/stable/pig_1.txt");
+ REQUIRE(pig_1 != nullptr);
+
+ auto isabelle =
+ vfs.open("/information/monkey_house/infrastructure/stable/../../../monkey_house/caretaker/isabelle.txt");
+ REQUIRE(isabelle != nullptr);
+
+ auto closed = vfs.open("/information/monkey_house/infrastructure/stable/../../../../closed.txt");
+ REQUIRE(closed != nullptr);
+ }
}
GIVEN("A real image file containing as filesystem formatted files")