From 0369fb7c4baa543dfb36ebb39ab53ac7560994ba Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 1 Apr 2026 11:37:05 +0200 Subject: kernel/test: only initialize kernel when running tests --- kernel/tests/src/main.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/kernel/tests/src/main.cpp b/kernel/tests/src/main.cpp index 69fd633..b3ae142 100644 --- a/kernel/tests/src/main.cpp +++ b/kernel/tests/src/main.cpp @@ -7,15 +7,32 @@ auto main(int argc, char ** argv) -> int { - kapi::cio::init(); - kapi::cpu::init(); - kapi::interrupts::enable(); + auto session = Catch::Session{}; - 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. + if (auto result = session.applyCommandLine(argc, argv); result != 0) + { + return result; + } - return Catch::Session().run(argc, argv); + 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(); } -- cgit v1.2.3