diff options
Diffstat (limited to 'kernel/kernel/filesystem/vfs.tests.cpp')
| -rw-r--r-- | kernel/kernel/filesystem/vfs.tests.cpp | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/kernel/kernel/filesystem/vfs.tests.cpp b/kernel/kernel/filesystem/vfs.tests.cpp index e4f042e7..7ec70d9c 100644 --- a/kernel/kernel/filesystem/vfs.tests.cpp +++ b/kernel/kernel/filesystem/vfs.tests.cpp @@ -75,7 +75,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS auto & vfs = kernel::filesystem::vfs::get(); auto image_1 = vfs.open("/dev/image_1.txt"); - REQUIRE(image_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(image_1.error() == kstd::errc::no_such_file_or_directory); auto dev = vfs.open("/dev/ram0"); REQUIRE(dev != nullptr); @@ -112,7 +112,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.unmount("/information")); auto unmounted_monkey_1 = vfs.open("/information/monkey_house/monkey_1.txt"); - REQUIRE(unmounted_monkey_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(unmounted_monkey_1.error() == kstd::errc::no_such_file_or_directory); auto info_1 = vfs.open("/information/info_1.txt"); REQUIRE(info_1 != nullptr); @@ -178,7 +178,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.unmount("/information")); mounted_tickets = vfs.open("/information/entrance/tickets.txt"); - REQUIRE(mounted_tickets.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(mounted_tickets.error() == kstd::errc::no_such_file_or_directory); auto mounted_monkey = vfs.open("/information/monkey_house/monkey_1.txt"); REQUIRE(mounted_monkey); @@ -192,7 +192,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.do_mount("/dev/ram16", "/")); info_1 = vfs.open("/information/info_1.txt"); - REQUIRE(info_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(info_1.error() == kstd::errc::no_such_file_or_directory); auto water = vfs.open("/monkey_house/infrastructure/water.txt"); REQUIRE(water != nullptr); @@ -213,7 +213,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.do_mount("/dev/ram16", "/")); info_1 = vfs.open("/information/info_1.txt"); - REQUIRE(info_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(info_1.error() == kstd::errc::no_such_file_or_directory); auto water = vfs.open("/monkey_house/infrastructure/water.txt"); REQUIRE(water != nullptr); @@ -221,10 +221,9 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.close(water.value()->absolute_path())); auto dev_ram_16 = vfs.open("/dev/ram16"); - REQUIRE(dev_ram_16.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(dev_ram_16.error() == kstd::errc::no_such_file_or_directory); - REQUIRE(vfs.do_mount("/dev/ram32", "/").error() == - make_error_code(kernel::filesystem::vfs_errc::non_existent_path)); + REQUIRE(vfs.do_mount("/dev/ram32", "/").error() == kstd::errc::no_such_file_or_directory); REQUIRE(vfs.unmount("/")); @@ -243,7 +242,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.unmount("/")); info_1 = vfs.open("/information/info_1.txt"); - REQUIRE(info_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(info_1.error() == kstd::errc::no_such_file_or_directory); REQUIRE(vfs.do_mount("/dev/ram0", "/")); @@ -251,44 +250,39 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(info_1 != nullptr); auto dev_ram_0 = vfs.open("/dev/ram0"); - REQUIRE(dev_ram_0.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(dev_ram_0.error() == kstd::errc::no_such_file_or_directory); } THEN("mount with null file system fails") { - REQUIRE(vfs.do_mount("/closed.txt", "/information").error() == make_error_condition(kstd::errc::not_supported)); + REQUIRE(vfs.do_mount("/closed.txt", "/information").error() == kstd::errc::not_supported); } THEN("mount with invalid path fails") { - REQUIRE(vfs.do_mount("/dev/ram16", "").error() == make_error_code(kernel::filesystem::vfs_errc::invalid_path)); - REQUIRE(vfs.do_mount("/dev/ram16", "information").error() == - make_error_code(kernel::filesystem::vfs_errc::invalid_path)); + REQUIRE(vfs.do_mount("/dev/ram16", "").error() == kstd::errc::invalid_argument); + REQUIRE(vfs.do_mount("/dev/ram16", "information").error() == kstd::errc::invalid_argument); } THEN("mount with non-existent source path fails") { - REQUIRE(vfs.do_mount("/dev/nonexistent", "/information").error() == - make_error_code(kernel::filesystem::vfs_errc::non_existent_path)); + REQUIRE(vfs.do_mount("/dev/nonexistent", "/information").error() == kstd::errc::no_such_file_or_directory); } THEN("mount with non-existent mount point fails") { - REQUIRE(vfs.do_mount("/dev/ram16", "/information/nonexistent").error() == - make_error_code(kernel::filesystem::vfs_errc::non_existent_path)); + REQUIRE(vfs.do_mount("/dev/ram16", "/information/nonexistent").error() == kstd::errc::no_such_file_or_directory); } THEN("unmount with invalid path fails") { - REQUIRE(vfs.unmount("").error() == make_error_code(kernel::filesystem::vfs_errc::invalid_path)); - REQUIRE(vfs.unmount("information").error() == - make_error_code(kernel::filesystem::vfs_errc::mount_point_not_found)); + REQUIRE(vfs.unmount("").error() == kstd::errc::invalid_argument); + REQUIRE(vfs.unmount("information").error() == kstd::errc::no_such_file_or_directory); } THEN("unmounting non-existent mount point returns expected error code") { - REQUIRE(vfs.unmount("/information/nonexistent").error() == - make_error_code(kernel::filesystem::vfs_errc::mount_point_not_found)); + REQUIRE(vfs.unmount("/information/nonexistent").error() == kstd::errc::no_such_file_or_directory); } THEN("a file can be access if . in the path") @@ -348,7 +342,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.do_mount("/archiv/2024.img", "/information")); auto info_1 = vfs.open("/information/info_1.txt"); - REQUIRE(info_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(info_1.error() == kstd::errc::no_such_file_or_directory); auto dentry = vfs.open("/information/sheep_1.txt"); REQUIRE(dentry != nullptr); @@ -363,7 +357,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.unmount("/information")); auto unmounted_sheep_1 = vfs.open("/information/sheep_1.txt"); - REQUIRE(unmounted_sheep_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(unmounted_sheep_1.error() == kstd::errc::no_such_file_or_directory); } THEN("the file-filesystem in the image can be mounted and in this filesystem can another file-filesystem be " @@ -394,11 +388,11 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.close(sheep_1.value()->absolute_path())); REQUIRE(vfs.close(goat_1.value()->absolute_path())); - REQUIRE(vfs.unmount("/information").error() == make_error_code(kernel::filesystem::vfs_errc::unmount_failed)); + REQUIRE(vfs.unmount("/information").error() == kstd::errc::device_or_resource_busy); REQUIRE(vfs.unmount("/information/stable")); auto unmounted_goat_1 = vfs.open("/information/stable/petting_zoo/goat_1.txt"); - REQUIRE(unmounted_goat_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(unmounted_goat_1.error() == kstd::errc::no_such_file_or_directory); auto still_mounted_sheep_1 = vfs.open("/information/sheep_1.txt"); REQUIRE(still_mounted_sheep_1 != nullptr); @@ -407,7 +401,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.unmount("/information")); auto unmounted_sheep_1 = vfs.open("/information/sheep_1.txt"); - REQUIRE(unmounted_sheep_1.error() == make_error_condition(kstd::errc::no_such_file_or_directory)); + REQUIRE(unmounted_sheep_1.error() == kstd::errc::no_such_file_or_directory); } } @@ -425,7 +419,7 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS REQUIRE(vfs.do_mount("/dev/ram16", "/entrance")); REQUIRE(vfs.do_mount("/entrance/archiv/2024.img", "/enclosures")); - REQUIRE(vfs.unmount("/entrance").error() == make_error_code(kernel::filesystem::vfs_errc::unmount_failed)); + REQUIRE(vfs.unmount("/entrance").error() == kstd::errc::device_or_resource_busy); REQUIRE(vfs.unmount("/enclosures")); REQUIRE(vfs.unmount("/entrance")); } @@ -484,21 +478,21 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS { auto & vfs = kernel::filesystem::vfs::get(); auto invalid_symlink = vfs.open("/symlinks/invalid_absolute"); - REQUIRE(invalid_symlink.error() == make_error_code(kernel::filesystem::vfs_errc::non_existent_path)); + REQUIRE(invalid_symlink.error() == kstd::errc::no_such_file_or_directory); } THEN("symbolic link containing an invalid relative path is handled correctly") { auto & vfs = kernel::filesystem::vfs::get(); auto invalid_symlink = vfs.open("/symlinks/invalid_relative"); - REQUIRE(invalid_symlink.error() == make_error_code(kernel::filesystem::vfs_errc::non_existent_path)); + REQUIRE(invalid_symlink.error() == kstd::errc::no_such_file_or_directory); } THEN("circular symbolic links are detected and handled correctly") { auto & vfs = kernel::filesystem::vfs::get(); auto circular_symlink = vfs.open("/symlinks/symloop_a"); - REQUIRE(circular_symlink.error() == make_error_code(kstd::errc::too_many_symbolic_link_levels)); + REQUIRE(circular_symlink.error() == kstd::errc::too_many_symbolic_link_levels); } } |
