aboutsummaryrefslogtreecommitdiff
path: root/kernel/src/filesystem/mount.tests.cpp
diff options
context:
space:
mode:
authorMarcel Braun <marcel.braun@ost.ch>2026-05-25 11:13:18 +0200
committerMarcel Braun <marcel.braun@ost.ch>2026-05-25 11:13:18 +0200
commit61d29a288334960cd9f43df91e4fd632a7f6ad66 (patch)
tree8ca81c4589ef2a2ca55a4a33527a6f12c34bd224 /kernel/src/filesystem/mount.tests.cpp
parent093074d5209f2d0062be79059f5881ee051c07d0 (diff)
downloadkernel-61d29a288334960cd9f43df91e4fd632a7f6ad66.tar.xz
kernel-61d29a288334960cd9f43df91e4fd632a7f6ad66.zip
Increase reference count of source_mount when one of its files is mounted somewhere
Diffstat (limited to 'kernel/src/filesystem/mount.tests.cpp')
-rw-r--r--kernel/src/filesystem/mount.tests.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/kernel/src/filesystem/mount.tests.cpp b/kernel/src/filesystem/mount.tests.cpp
index 6b66571..40b7cbb 100644
--- a/kernel/src/filesystem/mount.tests.cpp
+++ b/kernel/src/filesystem/mount.tests.cpp
@@ -11,6 +11,8 @@
#include <catch2/catch_test_macros.hpp>
+#include <stdexcept>
+
SCENARIO("Mount construction", "[filesystem][mount]")
{
GIVEN("a filesystem and a root dentry")
@@ -21,7 +23,7 @@ SCENARIO("Mount construction", "[filesystem][mount]")
WHEN("constructing a mount with the filesystem and root dentry")
{
- auto mount = kernel::filesystem::mount{root_dentry, root_dentry, fs, nullptr};
+ 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")
{
@@ -42,7 +44,7 @@ SCENARIO("Mount construction", "[filesystem][mount]")
{
THEN("the constructor panics")
{
- REQUIRE_THROWS_AS((kernel::filesystem::mount{root_dentry, root_dentry, nullptr, nullptr}),
+ REQUIRE_THROWS_AS((kernel::filesystem::mount{root_dentry, root_dentry, nullptr, nullptr, nullptr}),
kernel::tests::cpu::halt);
}
}
@@ -60,7 +62,7 @@ SCENARIO("Mount reference counting", "[filesystem][mount]")
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};
+ auto mount = kernel::filesystem::mount{root_dentry, root_dentry, fs, nullptr, nullptr};
mount.increment_ref_count();
REQUIRE(mount.ref_count() == 1);
@@ -70,20 +72,20 @@ SCENARIO("Mount reference counting", "[filesystem][mount]")
REQUIRE(mount.ref_count() == 2);
REQUIRE_FALSE(mount.is_ready_to_unmount());
- REQUIRE(mount.decrement_ref_count());
+ mount.decrement_ref_count();
REQUIRE(mount.ref_count() == 1);
REQUIRE_FALSE(mount.is_ready_to_unmount());
- REQUIRE(mount.decrement_ref_count());
+ 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};
+ auto mount = kernel::filesystem::mount{root_dentry, root_dentry, fs, nullptr, nullptr};
- REQUIRE_FALSE(mount.decrement_ref_count());
+ REQUIRE_THROWS_AS(mount.decrement_ref_count(), std::runtime_error);
REQUIRE(mount.ref_count() == 0);
REQUIRE(mount.is_ready_to_unmount());
}