<!-- 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.
| 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 --> |
no test coverage detected