diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-04-01 11:37:05 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-01 11:37:05 +0200 |
| commit | 0369fb7c4baa543dfb36ebb39ab53ac7560994ba (patch) | |
| tree | 0ad2a84e831b7e06159ae610af41096813a2e7bb | |
| parent | 419f4bebff5745b46bf30092dc7a7ca43449ea2e (diff) | |
| download | teachos-0369fb7c4baa543dfb36ebb39ab53ac7560994ba.tar.xz teachos-0369fb7c4baa543dfb36ebb39ab53ac7560994ba.zip | |
kernel/test: only initialize kernel when running tests
| -rw-r--r-- | kernel/tests/src/main.cpp | 35 |
1 files 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(); } |
