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

Function tests

loader/tests/src/test_start_vmm.cpp:50–735  ·  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

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

Callers 1

mainFunction · 0.70

Calls 9

initFunction · 0.85
init_fileFunction · 0.85
to_u8_ptrFunction · 0.85
ut_checkFunction · 0.85
loader_initFunction · 0.85
loader_finiFunction · 0.85
resetFunction · 0.85
ut_failsFunction · 0.85
finiFunction · 0.85

Tested by

no test coverage detected