aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/filesystem.tests.cpp
diff options
context:
space:
mode:
authormanuel <manuel.bott@eps.ch>2026-11-27 23:39:13 +0000
committermanuel <manuel.bott@eps.ch>2026-11-27 23:39:13 +0000
commit3521bcc25c3f69d1af51b2c467ac1166386662cb (patch)
treee967d13fee000ea6d8ede830b0c51f6d3710196b /kernel/kapi/filesystem.tests.cpp
parentd260c7339080e8c72224b68b93781139c297861f (diff)
downloadkernel-3521bcc25c3f69d1af51b2c467ac1166386662cb.tar.xz
kernel-3521bcc25c3f69d1af51b2c467ac1166386662cb.zip
kernel/filesystem: create file / inodefeature/createFiles
Diffstat (limited to 'kernel/kapi/filesystem.tests.cpp')
-rw-r--r--kernel/kapi/filesystem.tests.cpp30
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");