aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/mount.tests.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-07-03 09:32:30 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-07-03 09:32:30 +0200
commit3012fa5dfe5dfed5e83baf9b40934ed8e8317627 (patch)
tree00d1c60a3d5d1cdfa55e0ff1691cd3362b6064ee /kernel/src/filesystem/mount.tests.cpp
parent5d8a58d538515ffc57ddf82ba40ba763990a8696 (diff)
downloadkernel-3012fa5dfe5dfed5e83baf9b40934ed8e8317627.tar.xz
kernel-3012fa5dfe5dfed5e83baf9b40934ed8e8317627.zip
kernel: rearrange sources according to p1204
Diffstat (limited to 'kernel/src/filesystem/mount.tests.cpp')
-rw-r--r--kernel/src/filesystem/mount.tests.cpp94
1 files changed, 0 insertions, 94 deletions
diff --git a/kernel/src/filesystem/mount.tests.cpp b/kernel/src/filesystem/mount.tests.cpp
deleted file mode 100644
index c9ff82e9..00000000
--- a/kernel/src/filesystem/mount.tests.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <kernel/filesystem/mount.hpp>
-
-#include <kernel/filesystem/dentry.hpp>
-#include <kernel/test_support/cpu.hpp>
-#include <kernel/test_support/filesystem/filesystem.hpp>
-#include <kernel/test_support/filesystem/inode.hpp>
-
-#include <kstd/memory>
-#include <kstd/print>
-#include <kstd/vector>
-
-#include <catch2/catch_test_macros.hpp>
-
-#include <stdexcept>
-
-SCENARIO("Mount construction", "[filesystem][mount]")
-{
- GIVEN("a filesystem and a root dentry")
- {
- auto fs = kstd::make_shared<kernel::tests::filesystem::filesystem>();
- auto root_inode = kstd::make_shared<kernel::tests::filesystem::inode>();
- auto root_dentry = kstd::make_shared<kernel::filesystem::dentry>(nullptr, root_inode, "/");
-
- WHEN("constructing a mount with the filesystem and root dentry")
- {
- auto mount = kernel::filesystem::mount{root_dentry, root_dentry, fs, nullptr, nullptr};
-
- THEN("the mount has the correct filesystem, root dentry, mount dentry, and mount path")
- {
- REQUIRE(mount.get_filesystem() == fs);
- REQUIRE(mount.root_dentry() == root_dentry);
- REQUIRE(mount.mount_dentry() == root_dentry);
- REQUIRE(mount.mount_path() == "/");
- REQUIRE(mount.is_ready_to_unmount());
- }
-
- THEN("the mount has no parent mount and no source mount")
- {
- REQUIRE(mount.parent_mount() == nullptr);
- REQUIRE(mount.source_mount() == nullptr);
- }
- }
-
- WHEN("constructing a mount with a null filesystem")
- {
- THEN("the constructor panics")
- {
- REQUIRE_THROWS_AS((kernel::filesystem::mount{root_dentry, root_dentry, nullptr, nullptr, nullptr}),
- kernel::tests::cpu::halt);
- }
- }
- }
-}
-
-SCENARIO("Mount reference counting", "[filesystem][mount]")
-{
- GIVEN("a filesystem and a root dentry")
- {
- auto fs = kstd::make_shared<kernel::tests::filesystem::filesystem>();
- auto root_inode = kstd::make_shared<kernel::tests::filesystem::inode>();
- auto root_dentry = kstd::make_shared<kernel::filesystem::dentry>(nullptr, root_inode, "/");
-
- THEN("reference count can be incremented and decremented, the mount is ready to unmount when the reference "
- "count == 0")
- {
- auto mount = kernel::filesystem::mount{root_dentry, root_dentry, fs, nullptr, nullptr};
-
- mount.increment_ref_count();
- REQUIRE(mount.ref_count() == 1);
- REQUIRE_FALSE(mount.is_ready_to_unmount());
-
- mount.increment_ref_count();
- REQUIRE(mount.ref_count() == 2);
- REQUIRE_FALSE(mount.is_ready_to_unmount());
-
- mount.decrement_ref_count();
- REQUIRE(mount.ref_count() == 1);
- REQUIRE_FALSE(mount.is_ready_to_unmount());
-
- mount.decrement_ref_count();
- REQUIRE(mount.ref_count() == 0);
- REQUIRE(mount.is_ready_to_unmount());
- }
-
- THEN("decrementing reference count when it is already zero does not decrement it below zero")
- {
- auto mount = kernel::filesystem::mount{root_dentry, root_dentry, fs, nullptr, nullptr};
-
- REQUIRE_THROWS_AS(mount.decrement_ref_count(), std::runtime_error);
- REQUIRE(mount.ref_count() == 0);
- REQUIRE(mount.is_ready_to_unmount());
- }
- }
-} \ No newline at end of file