<!-- 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.
| 47 | /// @return Always returns bsl::exit_success. |
| 48 | /// |
| 49 | [[nodiscard]] constexpr auto |
| 50 | tests() noexcept -> bsl::exit_code |
| 51 | { |
| 52 | helpers::init(); |
| 53 | constexpr auto func{&stop_vmm_per_cpu}; |
| 54 | |
| 55 | bsl::ut_scenario{"success"} = [&]() noexcept { |
| 56 | bsl::ut_given{} = [&]() noexcept { |
| 57 | start_vmm_args_t mut_args{}; |
| 58 | helpers::file_t mut_mk_elf_file{}; |
| 59 | helpers::file_t mut_ext_elf_files{}; |
| 60 | bsl::ut_when{} = [&]() noexcept { |
| 61 | helpers::init_file(mut_mk_elf_file); |
| 62 | helpers::init_file(mut_ext_elf_files); |
| 63 | mut_args.ver = bsl::safe_u64::magic_1().get(); |
| 64 | mut_args.num_pages_in_page_pool = bsl::safe_u32::magic_1().get(); |
| 65 | mut_args.mk_elf_file.addr = helpers::to_u8_ptr(&mut_mk_elf_file); |
| 66 | mut_args.mk_elf_file.size = sizeof(mut_mk_elf_file); |
| 67 | mut_args.ext_elf_files[0].addr = helpers::to_u8_ptr(&mut_ext_elf_files); |
| 68 | mut_args.ext_elf_files[0].size = sizeof(mut_ext_elf_files); |
| 69 | helpers::ut_check(loader_init()); |
| 70 | helpers::ut_check(start_vmm(&mut_args)); |
| 71 | helpers::ut_check(start_vmm_per_cpu(1U)); |
| 72 | bsl::ut_then{} = [&]() noexcept { |
| 73 | helpers::ut_check(func(1U)); |
| 74 | }; |
| 75 | bsl::ut_cleanup{} = [&]() noexcept { |
| 76 | helpers::ut_check(loader_fini()); |
| 77 | helpers::reset(); |
| 78 | }; |
| 79 | }; |
| 80 | }; |
| 81 | }; |
| 82 | |
| 83 | bsl::ut_scenario{"invalid cpu"} = [&]() noexcept { |
| 84 | bsl::ut_then{} = [&]() noexcept { |
| 85 | helpers::ut_fails(func(42U)); |
| 86 | }; |
| 87 | }; |
| 88 | |
| 89 | bsl::ut_scenario{"cpu already running"} = [&]() noexcept { |
| 90 | bsl::ut_then{} = [&]() noexcept { |
| 91 | helpers::ut_check(func({})); |
| 92 | }; |
| 93 | }; |
| 94 | |
| 95 | bsl::ut_scenario{"stop twice"} = [&]() noexcept { |
| 96 | bsl::ut_given{} = [&]() noexcept { |
| 97 | start_vmm_args_t mut_args{}; |
| 98 | helpers::file_t mut_mk_elf_file{}; |
| 99 | helpers::file_t mut_ext_elf_files{}; |
| 100 | bsl::ut_when{} = [&]() noexcept { |
| 101 | helpers::init_file(mut_mk_elf_file); |
| 102 | helpers::init_file(mut_ext_elf_files); |
| 103 | mut_args.ver = bsl::safe_u64::magic_1().get(); |
| 104 | mut_args.num_pages_in_page_pool = bsl::safe_u32::magic_1().get(); |
| 105 | mut_args.mk_elf_file.addr = helpers::to_u8_ptr(&mut_mk_elf_file); |
| 106 | mut_args.mk_elf_file.size = sizeof(mut_mk_elf_file); |
no test coverage detected