MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / tests

Function tests

loader/tests/src/test_map_4k_page_rx.cpp:44–82  ·  view source on GitHub ↗

<!-- description --> @brief Used to execute the actual checks. We put the checks in this function so that we can validate the tests both at compile-time and at run-time. If a bsl::ut_check fails, the tests will either fail fast at run-time, or will produce a compile-time error. <!-- inputs/outputs --> @return Always returns bsl::exit_success.

Source from the content-addressed store, hash-verified

42 /// @return Always returns bsl::exit_success.
43 ///
44 [[nodiscard]] constexpr auto
45 tests() noexcept -> bsl::exit_code
46 {
47 helpers::init();
48 constexpr auto func{&map_4k_page_rx};
49
50 bsl::ut_scenario{"success"} = [&]() noexcept {
51 bsl::ut_given{} = [&]() noexcept {
52 void const *const virt{};
53 bsl::safe_u64 const phys{};
54 root_page_table_t mut_rpt{};
55 bsl::ut_then{} = [&]() noexcept {
56 helpers::ut_check(func(virt, phys.get(), &mut_rpt));
57 };
58 bsl::ut_cleanup{} = [&]() noexcept {
59 helpers::reset();
60 };
61 };
62 };
63
64 bsl::ut_scenario{"map_4k_page fails"} = [&]() noexcept {
65 bsl::ut_given{} = [&]() noexcept {
66 void const *const virt{};
67 bsl::safe_u64 const phys{};
68 root_page_table_t mut_rpt{};
69 bsl::ut_when{} = [&]() noexcept {
70 helpers::g_mut_map_4k_page = 1;
71 bsl::ut_then{} = [&]() noexcept {
72 helpers::ut_fails(func(virt, phys.get(), &mut_rpt));
73 };
74 bsl::ut_cleanup{} = [&]() noexcept {
75 helpers::reset();
76 };
77 };
78 };
79 };
80
81 return helpers::fini();
82 }
83}
84
85/// <!-- description -->

Callers 1

mainFunction · 0.70

Calls 5

initFunction · 0.85
ut_checkFunction · 0.85
resetFunction · 0.85
ut_failsFunction · 0.85
finiFunction · 0.85

Tested by

no test coverage detected