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

Function tests

loader/tests/src/test_map_ext_elf_files.cpp:47–91  ·  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{&map_ext_elf_files};
52
53 bsl::ut_scenario{"success"} = [&]() noexcept {
54 bsl::ut_given{} = [&]() noexcept {
55 bsl::array<elf_file_t, HYPERVISOR_MAX_EXTENSIONS> mut_ext_elf_files{};
56 root_page_table_t mut_rpt{};
57 bfelf_elf64_ehdr_t const file{};
58 bsl::ut_when{} = [&]() noexcept {
59 mut_ext_elf_files.front().addr = &file;
60 mut_ext_elf_files.front().size = sizeof(file);
61 bsl::ut_then{} = [&]() noexcept {
62 helpers::ut_check(func(mut_ext_elf_files.data(), &mut_rpt));
63 };
64 bsl::ut_cleanup{} = [&]() noexcept {
65 helpers::reset();
66 };
67 };
68 };
69 };
70
71 bsl::ut_scenario{"map_4k_page fails"} = [&]() noexcept {
72 bsl::ut_given{} = [&]() noexcept {
73 bsl::array<elf_file_t, HYPERVISOR_MAX_EXTENSIONS> mut_ext_elf_files{};
74 root_page_table_t mut_rpt{};
75 bfelf_elf64_ehdr_t const file{};
76 bsl::ut_when{} = [&]() noexcept {
77 mut_ext_elf_files.front().addr = &file;
78 mut_ext_elf_files.front().size = sizeof(file);
79 helpers::g_mut_map_4k_page = 1;
80 bsl::ut_then{} = [&]() noexcept {
81 helpers::ut_fails(func(mut_ext_elf_files.data(), &mut_rpt));
82 };
83 bsl::ut_cleanup{} = [&]() noexcept {
84 helpers::reset();
85 };
86 };
87 };
88 };
89
90 return helpers::fini();
91 }
92}
93
94/// <!-- description -->

Callers 1

mainFunction · 0.70

Calls 6

initFunction · 0.85
ut_checkFunction · 0.85
resetFunction · 0.85
ut_failsFunction · 0.85
finiFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected