diff options
| author | Marcel Braun <marcel.braun@ost.ch> | 2026-05-25 14:13:11 +0200 |
|---|---|---|
| committer | Marcel Braun <marcel.braun@ost.ch> | 2026-05-25 14:13:11 +0200 |
| commit | 0ab7525951b0116241f393090987bedc07a18c33 (patch) | |
| tree | fdd1d16c7de4f35dfc6d527cb9caa554e0db2c0c /kernel/src/filesystem/vfs.tests.cpp | |
| parent | 093074d5209f2d0062be79059f5881ee051c07d0 (diff) | |
| parent | adb1b5f2d6858097227fa610e86d1152b79d0bfa (diff) | |
| download | kernel-0ab7525951b0116241f393090987bedc07a18c33.tar.xz kernel-0ab7525951b0116241f393090987bedc07a18c33.zip | |
Merge branch 'improve-mount-reference-count' into 'develop-BA-FS26'
Increase reference count of source_mount when one of its files is mounted somewhere
See merge request teachos/kernel!42
Diffstat (limited to 'kernel/src/filesystem/vfs.tests.cpp')
| -rw-r--r-- | kernel/src/filesystem/vfs.tests.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/kernel/src/filesystem/vfs.tests.cpp b/kernel/src/filesystem/vfs.tests.cpp index 6fcc84e..962e067 100644 --- a/kernel/src/filesystem/vfs.tests.cpp +++ b/kernel/src/filesystem/vfs.tests.cpp @@ -10,6 +10,7 @@ #include <cstddef> #include <filesystem> +#include <stdexcept> #include <string_view> SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS with dummy modules", @@ -156,7 +157,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS THEN("file with invalid path or not opened file cannot be closed") { REQUIRE(vfs.close("invalid_path") == kernel::filesystem::vfs::operation_result::invalid_path); - REQUIRE(vfs.close("/information/info_1.txt") == kernel::filesystem::vfs::operation_result::close_failed); + REQUIRE_THROWS_AS(vfs.close("/information/info_1.txt"), std::runtime_error); } THEN("file cannot be closed twice") @@ -165,7 +166,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(info_1 != nullptr); REQUIRE(vfs.close(info_1->absolute_path().view()) == kernel::filesystem::vfs::operation_result::success); - REQUIRE(vfs.close(info_1->absolute_path().view()) == kernel::filesystem::vfs::operation_result::close_failed); + REQUIRE_THROWS_AS(vfs.close(info_1->absolute_path().view()), std::runtime_error); } THEN("images can be stacked mounted and correct file system is unmounted again") @@ -415,6 +416,37 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS } } + GIVEN("two real image files where the second contains as filesystem formatted files") + { + REQUIRE(std::filesystem::exists(image_path_1)); + REQUIRE(std::filesystem::exists(image_path_3)); + REQUIRE_NOTHROW( + setup_modules_from_img_and_init_vfs({"test_img_module_3", "test_img_module_1"}, {image_path_3, image_path_1})); + + auto & vfs = kernel::filesystem::vfs::get(); + + THEN("cannot unmount a filesystem if files are mounted") + { + REQUIRE(vfs.do_mount("/dev/ram16", "/entrance") == kernel::filesystem::vfs::operation_result::success); + REQUIRE(vfs.do_mount("/entrance/archiv/2024.img", "/enclosures") == + kernel::filesystem::vfs::operation_result::success); + + REQUIRE(vfs.unmount("/entrance") == kernel::filesystem::vfs::operation_result::unmount_failed); + REQUIRE(vfs.unmount("/enclosures") == kernel::filesystem::vfs::operation_result::success); + REQUIRE(vfs.unmount("/entrance") == kernel::filesystem::vfs::operation_result::success); + } + + THEN("can mount filesystem onto the directory that contains it") + { + REQUIRE(vfs.do_mount("/dev/ram16", "/entrance") == kernel::filesystem::vfs::operation_result::success); + REQUIRE(vfs.do_mount("/entrance/archiv/2024.img", "/entrance") == + kernel::filesystem::vfs::operation_result::success); + + REQUIRE(vfs.unmount("/entrance") == kernel::filesystem::vfs::operation_result::success); + REQUIRE(vfs.unmount("/entrance") == kernel::filesystem::vfs::operation_result::success); + } + } + GIVEN("A real image files, containing symbolic links") { REQUIRE(std::filesystem::exists(image_path_1)); |
