diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-08-18 00:25:29 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-08-18 00:25:29 +0200 |
| commit | 493f50c697b17049b820e65664af9f4a7c9c0c2c (patch) | |
| tree | c0f3b529f1f9733f05f1095a696e32d2e84b7006 /kernel/kapi/filesystem.tests.cpp | |
| parent | a7c024e8ae449298b2805037e14184492dfb408e (diff) | |
| download | kernel-493f50c697b17049b820e65664af9f4a7c9c0c2c.tar.xz kernel-493f50c697b17049b820e65664af9f4a7c9c0c2c.zip | |
kapi: implement seek support
Diffstat (limited to 'kernel/kapi/filesystem.tests.cpp')
| -rw-r--r-- | kernel/kapi/filesystem.tests.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/kapi/filesystem.tests.cpp b/kernel/kapi/filesystem.tests.cpp index 80fc7d3f..2f975bf8 100644 --- a/kernel/kapi/filesystem.tests.cpp +++ b/kernel/kapi/filesystem.tests.cpp @@ -3,6 +3,7 @@ #include <kernel/test_support/filesystem/storage_boot_module_vfs_fixture.hpp> #include <kstd/system_error.hpp> +#include <kstd/units.hpp> #include <catch2/catch_test_macros.hpp> @@ -142,6 +143,24 @@ SCENARIO_METHOD(kernel::tests::filesystem::storage_boot_module_vfs_fixture, "Kap REQUIRE(kapi::filesystem::umount("/information")); } + AND_GIVEN("an open file") + { + auto file = kapi::filesystem::open("/closed.txt"); + REQUIRE(file); + + THEN("seeking forward from the beginning succeeds") + { + REQUIRE(kapi::filesystem::seek(*file, 100_B, kapi::filesystem::seek_direction::forward, + kapi::filesystem::seek_origin::beginning) == 100_B); + } + + THEN("seeking backward from the beginning fails") + { + REQUIRE_FALSE(kapi::filesystem::seek(*file, 100_B, kapi::filesystem::seek_direction::backward, + kapi::filesystem::seek_origin::beginning)); + } + } + THEN("device can be opened as file and read from") { auto fd = kapi::filesystem::open("/dev/ram0").value(); |
