diff options
Diffstat (limited to 'kernel/kapi')
| -rw-r--r-- | kernel/kapi/filesystem.tests.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/kapi/filesystem.tests.cpp b/kernel/kapi/filesystem.tests.cpp index baa587e5..0a787a32 100644 --- a/kernel/kapi/filesystem.tests.cpp +++ b/kernel/kapi/filesystem.tests.cpp @@ -406,6 +406,36 @@ SCENARIO_METHOD(kernel::tests::vfs::storage_boot_module_vfs_fixture, "Kapi files REQUIRE(status->size == image::hello_size); } + THEN("a new file with an 8.3 name can be created, written to, and read back after reopening it") + { + auto const path = "/information/new.txt"; + REQUIRE(kapi::filesystem::create(path)); + + auto fd = kapi::filesystem::open(path); + REQUIRE(fd); + auto const content = std::string_view{"Hello FAT!"}; + REQUIRE(kapi::filesystem::write(*fd, std::as_bytes(std::span{content})) == kstd::bytes{content.size()}); + REQUIRE(kapi::filesystem::close(*fd)); + + fd = kapi::filesystem::open(path); + REQUIRE(fd); + REQUIRE(read_text(*fd, 4) == content); + REQUIRE(kapi::filesystem::close(*fd)); + + REQUIRE(kapi::filesystem::status(path)->size == kstd::bytes{content.size()}); + } + + THEN("a file that already exists cannot be created again, regardless of the case of its name") + { + REQUIRE(!kapi::filesystem::create("/information/hello.txt")); + REQUIRE(!kapi::filesystem::create("/information/HELLO.TXT")); + } + + THEN("a file with a name that is not a valid 8.3 name cannot be created") + { + REQUIRE(!kapi::filesystem::create("/information/new_information.txt")); + } + THEN("the mounted root directory can be listed") { auto const directory = kapi::filesystem::open("/information"); |
