<!-- 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{&map_mk_stack}; |
| 52 | |
| 53 | bsl::ut_scenario{"success"} = [&]() noexcept { |
| 54 | bsl::ut_given{} = [&]() noexcept { |
| 55 | span_t mut_stack{}; |
| 56 | root_page_table_t mut_rpt{}; |
| 57 | constexpr auto buf_size{0x2042_umx}; |
| 58 | bsl::array<bsl::uint8, buf_size.get()> mut_buf{}; |
| 59 | bsl::ut_when{} = [&]() noexcept { |
| 60 | mut_stack.addr = mut_buf.data(); |
| 61 | mut_stack.size = mut_buf.size().get(); |
| 62 | bsl::ut_then{} = [&]() noexcept { |
| 63 | helpers::ut_check(func(&mut_stack, {}, &mut_rpt)); |
| 64 | }; |
| 65 | bsl::ut_cleanup{} = [&]() noexcept { |
| 66 | helpers::reset(); |
| 67 | }; |
| 68 | }; |
| 69 | }; |
| 70 | }; |
| 71 | |
| 72 | bsl::ut_scenario{"platform_virt_to_phys fails"} = [&]() noexcept { |
| 73 | bsl::ut_given{} = [&]() noexcept { |
| 74 | span_t mut_stack{}; |
| 75 | root_page_table_t mut_rpt{}; |
| 76 | constexpr auto buf_size{0x2042_umx}; |
| 77 | bsl::array<bsl::uint8, buf_size.get()> mut_buf{}; |
| 78 | bsl::ut_when{} = [&]() noexcept { |
| 79 | mut_stack.addr = mut_buf.data(); |
| 80 | mut_stack.size = mut_buf.size().get(); |
| 81 | helpers::g_mut_platform_virt_to_phys = 1; |
| 82 | bsl::ut_then{} = [&]() noexcept { |
| 83 | helpers::ut_fails(func(&mut_stack, {}, &mut_rpt)); |
| 84 | }; |
| 85 | bsl::ut_cleanup{} = [&]() noexcept { |
| 86 | helpers::reset(); |
| 87 | }; |
| 88 | }; |
| 89 | }; |
| 90 | }; |
| 91 | |
| 92 | bsl::ut_scenario{"map_4k_page fails"} = [&]() noexcept { |
| 93 | bsl::ut_given{} = [&]() noexcept { |
| 94 | span_t mut_stack{}; |
| 95 | root_page_table_t mut_rpt{}; |
| 96 | constexpr auto buf_size{0x2042_umx}; |
| 97 | bsl::array<bsl::uint8, buf_size.get()> mut_buf{}; |
| 98 | bsl::ut_when{} = [&]() noexcept { |
| 99 | mut_stack.addr = mut_buf.data(); |
| 100 | mut_stack.size = mut_buf.size().get(); |
| 101 | helpers::g_mut_map_4k_page = 1; |
| 102 | bsl::ut_then{} = [&]() noexcept { |
| 103 | helpers::ut_fails(func(&mut_stack, {}, &mut_rpt)); |
| 104 | }; |