aboutsummaryrefslogtreecommitdiff
path: root/kernel/tests/src/main.cpp
blob: b3ae142cbae1bc59cd575a10a613677538ba7cd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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();
}