diff options
Diffstat (limited to 'kernel/kernel/filesystem/vfs.tests.cpp')
| -rw-r--r-- | kernel/kernel/filesystem/vfs.tests.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/kernel/kernel/filesystem/vfs.tests.cpp b/kernel/kernel/filesystem/vfs.tests.cpp index c99cea90..ace1bd1f 100644 --- a/kernel/kernel/filesystem/vfs.tests.cpp +++ b/kernel/kernel/filesystem/vfs.tests.cpp @@ -331,6 +331,53 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "VFS } } + GIVEN("A real image file within which new files and directories can be created") + { + REQUIRE(std::filesystem::exists(image_path_1)); + REQUIRE_NOTHROW(setup_modules_from_img_and_init_vfs({"test_img_module_1"}, {image_path_1})); + + THEN("a new file can be created and read again") + { + auto & vfs = kernel::filesystem::vfs::get(); + REQUIRE(vfs.create("/information/new_file.txt")); + + auto new_file = vfs.open("/information/new_file.txt"); + REQUIRE(new_file != nullptr); + } + + THEN("a new directory can be created and read again") + { + auto & vfs = kernel::filesystem::vfs::get(); + REQUIRE(vfs.mkdir("/information/new_directory")); + } + + THEN("a new file cannot be created if it already exists") + { + auto & vfs = kernel::filesystem::vfs::get(); + REQUIRE(!vfs.create("/information/info_1.txt")); + } + + THEN("a new directory cannot be created if it already exists") + { + auto & vfs = kernel::filesystem::vfs::get(); + REQUIRE(!vfs.mkdir("/information")); + } + + THEN("a new file cannot be created if path does not exist or is invalid") + { + auto & vfs = kernel::filesystem::vfs::get(); + REQUIRE(!vfs.create("")); + REQUIRE(!vfs.create("invalid_path")); + } + + THEN("a new directory cannot be created if path does not exist or is invalid") + { + auto & vfs = kernel::filesystem::vfs::get(); + REQUIRE(!vfs.mkdir("")); + REQUIRE(!vfs.mkdir("invalid_path")); + } + } + GIVEN("A real image file containing as filesystem formatted files") { REQUIRE(std::filesystem::exists(image_path_1)); |
