aboutsummaryrefslogtreecommitdiff
path: root/kernel/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/tests/src')
-rw-r--r--kernel/tests/src/log_buffer.cpp39
-rw-r--r--kernel/tests/src/main.cpp38
-rw-r--r--kernel/tests/src/simulated_memory.cpp33
-rw-r--r--kernel/tests/src/test_support.tests.cpp51
4 files changed, 0 insertions, 161 deletions
diff --git a/kernel/tests/src/log_buffer.cpp b/kernel/tests/src/log_buffer.cpp
deleted file mode 100644
index 9e30afb..0000000
--- a/kernel/tests/src/log_buffer.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "kernel/tests/log_buffer.hpp"
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-namespace kernel::tests::log_buffer
-{
-
- namespace
- {
- std::vector<std::string> recorded_messages{};
- }
-
- auto append(std::string const & message) -> void
- {
- recorded_messages.push_back(message);
- }
-
- auto clear() -> void
- {
- recorded_messages.clear();
- }
-
- auto flat_messages() -> std::string
- {
- return std::ranges::fold_left(recorded_messages, std::string{},
- [](std::string accumulator, std::string const & message) {
- accumulator += message;
- return accumulator;
- });
- }
-
- auto messages() -> std::vector<std::string> const &
- {
- return recorded_messages;
- }
-
-} // namespace kernel::tests::log_buffer
diff --git a/kernel/tests/src/main.cpp b/kernel/tests/src/main.cpp
deleted file mode 100644
index b3ae142..0000000
--- a/kernel/tests/src/main.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "kapi/interrupts.hpp"
-#include "kapi/memory.hpp"
-#include <kapi/cio.hpp>
-#include <kapi/cpu.hpp>
-
-#include <catch2/catch_session.hpp>
-
-auto main(int argc, char ** argv) -> int
-{
- auto session = Catch::Session{};
-
- if (auto result = session.applyCommandLine(argc, argv); result != 0)
- {
- return result;
- }
-
- auto const & config = session.configData();
- auto skip_init = config.listTests || //
- config.listTags || //
- config.listReporters || //
- config.listListeners || //
- config.showHelp;
-
- if (!skip_init)
- {
- kapi::cio::init();
- kapi::cpu::init();
- kapi::interrupts::enable();
-
- kapi::memory::init();
- // note: no kernel heap is created, since we are in the test environment. Nonetheless, we still initialize the
- // memory subsystem, so that components that rely on it can be tested. No component must ever rely on the heap
- // allocator directly, rather they have to go through the new and delete. However, some components may use the frame
- // allocator and page mapper in order to perform their tasks.
- }
-
- return session.run();
-}
diff --git a/kernel/tests/src/simulated_memory.cpp b/kernel/tests/src/simulated_memory.cpp
deleted file mode 100644
index 9a9b354..0000000
--- a/kernel/tests/src/simulated_memory.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "kernel/tests/simulated_memory.hpp"
-
-#include <kstd/units>
-
-#include <cstddef>
-#include <vector>
-
-namespace kernel::tests::simulated_memory
-{
-
- namespace
- {
- auto constinit ram_storage = std::vector<std::byte>{};
- auto constinit pmm_storage = std::vector<std::byte>{};
- } // namespace
-
- auto init(kstd::units::bytes size) -> void
- {
- ram_storage.resize(size / kstd::units::bytes{1});
- pmm_storage.resize(size / kstd::units::bytes{1});
- }
-
- auto pmm_metadata_base() -> std::byte *
- {
- return pmm_storage.data();
- }
-
- auto ram_base() -> std::byte *
- {
- return ram_storage.data();
- }
-
-} // namespace kernel::tests::simulated_memory \ No newline at end of file
diff --git a/kernel/tests/src/test_support.tests.cpp b/kernel/tests/src/test_support.tests.cpp
deleted file mode 100644
index f835e65..0000000
--- a/kernel/tests/src/test_support.tests.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "kapi/cpu.hpp"
-#include "kapi/system.hpp"
-
-#include "kernel/tests/cpu.hpp"
-#include "kernel/tests/log_buffer.hpp"
-
-#include <kstd/print>
-
-#include <catch2/catch_test_macros.hpp>
-
-SCENARIO("Kernel test support infrastructure", "[support]")
-{
- GIVEN("the test support infrastructure is initialized")
- {
- WHEN("a CPU halt is requested")
- {
- THEN("the correct exception is thrown")
- {
- REQUIRE_THROWS_AS(kapi::cpu::halt(), kernel::tests::cpu::halt);
- }
- }
-
- WHEN("a the system panics")
- {
- kernel::tests::log_buffer::clear();
-
- THEN("the correct exception is thrown")
- {
- REQUIRE_THROWS_AS(kapi::system::panic("[kernel:tests] Test Panic"), kernel::tests::cpu::halt);
- }
-
- THEN("the message is appended to the log buffer")
- {
- CHECK_THROWS(kapi::system::panic("[kernel:tests] Test Panic"));
- REQUIRE(kernel::tests::log_buffer::flat_messages().contains("[kernel:tests] Test Panic"));
- }
- }
-
- WHEN("a regular print is issued")
- {
- kernel::tests::log_buffer::clear();
-
- kstd::println("[kernel:tests] Test Print");
-
- THEN("the message is appended to the log buffer")
- {
- REQUIRE(kernel::tests::log_buffer::flat_messages().contains("[kernel:tests] Test Print"));
- }
- }
- }
-} \ No newline at end of file