aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/system.tests.cpp
blob: 687053e773982441fcb2fbd565331d9493cd4d00 (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
#include "kapi/system.hpp"

#include "kernel/test_support/cio.hpp"
#include "kernel/test_support/cpu.hpp"

#include <kstd/print>

#include <catch2/catch_test_macros.hpp>

SCENARIO("Kernel testing kapi::system shims", "[support]")
{
  GIVEN("the test support infrastructure is initialized")
  {
    WHEN("a the system panics")
    {
      kernel::tests::cio::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::cio::log_buffer().flat_messages().contains("[kernel:tests] Test Panic"));
      }
    }
  }
}