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

Function tests

loader/tests/src/test_get_mk_page_pool_addr.cpp:47–86  ·  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

45 /// @return Always returns bsl::exit_success.
46 ///
47 [[nodiscard]] constexpr auto
48 tests() noexcept -> bsl::exit_code
49 {
50 helpers::init();
51 constexpr auto func{&get_mk_page_pool_addr};
52 constexpr bsl::safe_u64 addr{HYPERVISOR_MK_HUGE_POOL_ADDR};
53
54 bsl::ut_scenario{"success"} = [&]() noexcept {
55 mutable_span_t mut_pool{};
56 bsl::uint8 *pmut_mut_addr{};
57 bsl::ut_given{} = [&]() noexcept {
58 bsl::ut_then{} = [&]() noexcept {
59 helpers::ut_check(alloc_mk_page_pool({}, &mut_pool));
60 helpers::ut_check(func(&mut_pool, addr.get(), &pmut_mut_addr));
61 };
62 bsl::ut_cleanup{} = [&]() noexcept {
63 free_mk_page_pool(&mut_pool);
64 helpers::reset();
65 };
66 };
67 };
68
69 bsl::ut_scenario{"platform_virt_to_phys fails"} = [&]() noexcept {
70 bsl::ut_given{} = [&]() noexcept {
71 mutable_span_t const pool{};
72 bsl::uint8 *pmut_mut_addr{};
73 bsl::ut_when{} = [&]() noexcept {
74 helpers::g_mut_platform_virt_to_phys = 1;
75 bsl::ut_then{} = [&]() noexcept {
76 helpers::ut_fails(func(&pool, addr.get(), &pmut_mut_addr));
77 };
78 bsl::ut_cleanup{} = [&]() noexcept {
79 helpers::reset();
80 };
81 };
82 };
83 };
84
85 return helpers::fini();
86 }
87}
88
89/// <!-- description -->

Callers 1

mainFunction · 0.70

Calls 7

initFunction · 0.85
ut_checkFunction · 0.85
alloc_mk_page_poolFunction · 0.85
free_mk_page_poolFunction · 0.85
resetFunction · 0.85
ut_failsFunction · 0.85
finiFunction · 0.85

Tested by

no test coverage detected