#include "kernel/filesystem/rootfs/inode.hpp" #include #include #include #include SCENARIO("Rootfs inode creation", "[filesystem][rootfs][inode]") { GIVEN("a rootfs inode") { auto inode = kernel::filesystem::rootfs::inode{}; THEN("the inode has the correct kind") { REQUIRE(inode.is_directory()); REQUIRE_FALSE(inode.is_device()); REQUIRE_FALSE(inode.is_regular()); } THEN("the inode has no children") { REQUIRE(inode.lookup_child("child") == nullptr); } } } SCENARIO("Rootfs inode child management", "[filesystem][rootfs][inode]") { GIVEN("a rootfs inode") { auto inode = kernel::filesystem::rootfs::inode{}; WHEN("adding a child inode") { inode.add_child("child"); inode.add_child("another child"); THEN("the child can be looked up by name") { auto child_inode = inode.lookup_child("child"); REQUIRE(child_inode != nullptr); REQUIRE(child_inode->is_directory()); } THEN("looking up a non-existent child returns null") { REQUIRE(inode.lookup_child("nonexistent") == nullptr); } } } } SCENARIO("Rootfs inode read/write", "[filesystem][rootfs][inode]") { GIVEN("a rootfs inode") { auto inode = kernel::filesystem::rootfs::inode{}; WHEN("reading from the inode") { kstd::vector buffer(10); auto bytes_read = inode.read(buffer.data(), 0, buffer.size()); THEN("no bytes are read") { REQUIRE(bytes_read == 0); } } WHEN("writing to the inode") { kstd::vector buffer(10, 'x'); auto bytes_written = inode.write(buffer.data(), 0, buffer.size()); THEN("no bytes are written") { REQUIRE(bytes_written == 0); } } } }