diff options
| author | Lukas Oesch <lukasoesch20@gmail.com> | 2026-05-16 14:11:49 +0200 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-05-16 14:11:49 +0200 |
| commit | 5b40e4a28307eed814adb46188c3f6783651d286 (patch) | |
| tree | f3916a9865d03ebb574bac7d5496f6ec85d638ed /kernel/kapi | |
| parent | efc7ba748b977a792188724c461852f01c111957 (diff) | |
| download | kernel-5b40e4a28307eed814adb46188c3f6783651d286.tar.xz kernel-5b40e4a28307eed814adb46188c3f6783651d286.zip | |
add kapi::filesystem tests
Diffstat (limited to 'kernel/kapi')
| -rw-r--r-- | kernel/kapi/filesystem.tests.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/kapi/filesystem.tests.cpp b/kernel/kapi/filesystem.tests.cpp index 1d1f8ee..d241afa 100644 --- a/kernel/kapi/filesystem.tests.cpp +++ b/kernel/kapi/filesystem.tests.cpp @@ -103,6 +103,19 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "Kap REQUIRE(kapi::filesystem::umount("/information") == 0); } + THEN("a filesystem cannot be unmounted if files are still open and can be unmounted after files are closed") + { + REQUIRE(kapi::filesystem::mount("/dev/ram16", "/information") == 0); + + auto fd = kapi::filesystem::open("/information/monkey_house/monkey_1.txt"); + REQUIRE(fd >= 0); + + REQUIRE(kapi::filesystem::umount("/information") < 0); + + REQUIRE(kapi::filesystem::close(fd) == 0); + REQUIRE(kapi::filesystem::umount("/information") == 0); + } + THEN("device can be opened as file and read from") { auto fd = kapi::filesystem::open("/dev/ram0"); @@ -158,6 +171,15 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "Kap REQUIRE(kapi::filesystem::close(999) < 0); } + THEN("same file cannot be closed twice") + { + auto fd = kapi::filesystem::open("/information/info_1.txt"); + REQUIRE(fd >= 0); + + REQUIRE(kapi::filesystem::close(fd) == 0); + REQUIRE(kapi::filesystem::close(fd) < 0); + } + THEN("not opened files cannot be read from") { std::vector<std::byte> buffer(10); |
