32 static auto operator"" _cve(
const char *
str, std::size_t len)
33 { (void)str; (void)len;
return std::make_shared<bfn::corrupt_vmm_error>(); }
35 static auto operator"" _use(
const char *
str, std::size_t len)
36 { (void)str; (void)len;
return std::make_shared<bfn::unknown_status_error>(); }
38 static auto operator"" _ivse(
const char *
str, std::size_t len)
39 { (void)str; (void)len;
return std::make_shared<bfn::invalid_vmm_state_error>(
""); }
41 static auto operator"" _ife(
const char *
str, std::size_t len)
42 { (void)str; (void)len;
return std::make_shared<bfn::ioctl_failed_error>(
""); }
45 setup_file(MockRepository &mocks)
47 auto fil = mocks.Mock<
file>();
60 auto ctl = mocks.Mock<
ioctl>();
97 bfm_ut::test_ioctl_driver_process_invalid_file()
101 auto &&fil =
static_cast<file *
>(
nullptr);
102 auto &&ctl = mocks.Mock<
ioctl>();
112 bfm_ut::test_ioctl_driver_process_invalid_ioctl()
114 MockRepository mocks;
116 auto &&fil = mocks.Mock<
file>();
117 auto &&ctl =
static_cast<ioctl *
>(
nullptr);
127 bfm_ut::test_ioctl_driver_process_invalid_command_line_parser()
129 MockRepository mocks;
131 auto &&fil = mocks.Mock<
file>();
132 auto &&ctl = mocks.Mock<
ioctl>();
142 bfm_ut::test_ioctl_driver_process_help()
144 MockRepository mocks;
146 auto &&fil = setup_file(mocks);
158 bfm_ut::test_ioctl_driver_process_load_vmm_running()
160 MockRepository mocks;
162 auto &&fil = setup_file(mocks);
179 bfm_ut::test_ioctl_driver_process_load_vmm_loaded()
181 MockRepository mocks;
183 auto &&fil = setup_file(mocks);
200 bfm_ut::test_ioctl_driver_process_load_vmm_corrupt()
202 MockRepository mocks;
204 auto &&fil = setup_file(mocks);
216 bfm_ut::test_ioctl_driver_process_load_vmm_unknown_status()
218 MockRepository mocks;
220 auto &&fil = setup_file(mocks);
221 auto &&ctl = setup_ioctl(mocks, -1);
232 bfm_ut::test_ioctl_driver_process_load_bad_modules_filename()
234 MockRepository mocks;
236 auto &&fil = setup_file(mocks);
253 bfm_ut::test_ioctl_driver_process_load_bad_module_filename()
255 MockRepository mocks;
257 auto &&fil = setup_file(mocks);
264 {
return "{\"modules\":[\"1\",\"2\",\"3\"]}"_s; });
276 bfm_ut::test_ioctl_driver_process_load_add_module_failed()
278 MockRepository mocks;
280 auto &&fil = setup_file(mocks);
287 {
return "{\"modules\":[\"1\",\"2\",\"3\"]}"_s; });
304 bfm_ut::test_ioctl_driver_process_load_load_failed()
306 MockRepository mocks;
308 auto &&fil = setup_file(mocks);
315 {
return "{\"modules\":[\"1\",\"2\",\"3\"]}"_s; });
330 bfm_ut::test_ioctl_driver_process_load_success()
332 MockRepository mocks;
334 auto &&fil = setup_file(mocks);
341 {
return "{\"modules\":[\"1\",\"2\",\"3\"]}"_s; });
354 bfm_ut::test_ioctl_driver_process_unload_vmm_running()
356 MockRepository mocks;
358 auto &&fil = setup_file(mocks);
373 bfm_ut::test_ioctl_driver_process_unload_vmm_loaded()
375 MockRepository mocks;
377 auto &&fil = setup_file(mocks);
392 bfm_ut::test_ioctl_driver_process_unload_vmm_unloaded()
394 MockRepository mocks;
396 auto &&fil = setup_file(mocks);
411 bfm_ut::test_ioctl_driver_process_unload_vmm_corrupt()
413 MockRepository mocks;
415 auto &&fil = setup_file(mocks);
427 bfm_ut::test_ioctl_driver_process_unload_vmm_unknown_status()
429 MockRepository mocks;
431 auto &&fil = setup_file(mocks);
432 auto &&ctl = setup_ioctl(mocks, -1);
443 bfm_ut::test_ioctl_driver_process_unload_unload_failed()
445 MockRepository mocks;
447 auto &&fil = setup_file(mocks);
461 bfm_ut::test_ioctl_driver_process_unload_success()
463 MockRepository mocks;
465 auto &&fil = setup_file(mocks);
477 bfm_ut::test_ioctl_driver_process_start_vmm_running()
479 MockRepository mocks;
481 auto &&fil = setup_file(mocks);
496 bfm_ut::test_ioctl_driver_process_start_vmm_loaded()
498 MockRepository mocks;
500 auto &&fil = setup_file(mocks);
515 bfm_ut::test_ioctl_driver_process_start_vmm_unloaded()
517 MockRepository mocks;
519 auto &&fil = setup_file(mocks);
534 bfm_ut::test_ioctl_driver_process_start_vmm_corrupt()
536 MockRepository mocks;
538 auto &&fil = setup_file(mocks);
552 bfm_ut::test_ioctl_driver_process_start_vmm_unknown_status()
554 MockRepository mocks;
556 auto &&fil = setup_file(mocks);
557 auto &&ctl = setup_ioctl(mocks, -1);
570 bfm_ut::test_ioctl_driver_process_start_start_failed()
572 MockRepository mocks;
574 auto &&fil = setup_file(mocks);
588 bfm_ut::test_ioctl_driver_process_start_success()
590 MockRepository mocks;
592 auto &&fil = setup_file(mocks);
604 bfm_ut::test_ioctl_driver_process_stop_vmm_loaded()
606 MockRepository mocks;
608 auto &&fil = setup_file(mocks);
622 bfm_ut::test_ioctl_driver_process_stop_vmm_unloaded()
624 MockRepository mocks;
626 auto &&fil = setup_file(mocks);
640 bfm_ut::test_ioctl_driver_process_stop_vmm_corrupt()
642 MockRepository mocks;
644 auto &&fil = setup_file(mocks);
658 bfm_ut::test_ioctl_driver_process_stop_vmm_unknown_status()
660 MockRepository mocks;
662 auto &&fil = setup_file(mocks);
663 auto &&ctl = setup_ioctl(mocks, -1);
676 bfm_ut::test_ioctl_driver_process_stop_stop_failed()
678 MockRepository mocks;
680 auto &&fil = setup_file(mocks);
694 bfm_ut::test_ioctl_driver_process_stop_success()
696 MockRepository mocks;
698 auto &&fil = setup_file(mocks);
710 bfm_ut::test_ioctl_driver_process_dump_vmm_unloaded()
712 MockRepository mocks;
714 auto &&fil = setup_file(mocks);
728 bfm_ut::test_ioctl_driver_process_dump_vmm_corrupted()
730 MockRepository mocks;
732 auto &&fil = setup_file(mocks);
746 bfm_ut::test_ioctl_driver_process_dump_vmm_unknown_status()
748 MockRepository mocks;
750 auto &&fil = setup_file(mocks);
751 auto &&ctl = setup_ioctl(mocks, -1);
764 bfm_ut::test_ioctl_driver_process_dump_dump_failed()
766 MockRepository mocks;
768 auto &&fil = setup_file(mocks);
782 bfm_ut::test_ioctl_driver_process_dump_success_running()
784 MockRepository mocks;
786 auto &&fil = setup_file(mocks);
807 bfm_ut::test_ioctl_driver_process_dump_success_loaded()
809 MockRepository mocks;
811 auto &&fil = setup_file(mocks);
832 bfm_ut::test_ioctl_driver_process_vmm_status_running()
834 MockRepository mocks;
836 auto &&fil = setup_file(mocks);
848 bfm_ut::test_ioctl_driver_process_vmm_status_loaded()
850 MockRepository mocks;
852 auto &&fil = setup_file(mocks);
864 bfm_ut::test_ioctl_driver_process_vmm_status_unloaded()
866 MockRepository mocks;
868 auto &&fil = setup_file(mocks);
880 bfm_ut::test_ioctl_driver_process_vmm_status_corrupt()
882 MockRepository mocks;
884 auto &&fil = setup_file(mocks);
896 bfm_ut::test_ioctl_driver_process_vmm_status_unknown_status()
898 MockRepository mocks;
900 auto &&fil = setup_file(mocks);
901 auto &&ctl = setup_ioctl(mocks, -1);
912 bfm_ut::test_ioctl_driver_process_vmcall_vmm_unloaded()
914 MockRepository mocks;
916 auto &&fil = setup_file(mocks);
930 bfm_ut::test_ioctl_driver_process_vmcall_vmm_loaded()
932 MockRepository mocks;
934 auto &&fil = setup_file(mocks);
948 bfm_ut::test_ioctl_driver_process_vmcall_vmm_corrupt()
950 MockRepository mocks;
952 auto &&fil = setup_file(mocks);
966 bfm_ut::test_ioctl_driver_process_vmcall_vmm_unknown()
968 MockRepository mocks;
970 auto &&fil = setup_file(mocks);
971 auto &&ctl = setup_ioctl(mocks, -1);
984 bfm_ut::test_ioctl_driver_process_vmcall_unknown_vmcall()
986 MockRepository mocks;
988 auto &&fil = setup_file(mocks);
995 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1006 bfm_ut::test_ioctl_driver_process_vmcall_versions_ioctl_failed()
1008 MockRepository mocks;
1010 auto &&fil = setup_file(mocks);
1017 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1030 bfm_ut::test_ioctl_driver_process_vmcall_versions_ioctl_return_failed()
1032 MockRepository mocks;
1034 auto &&fil = setup_file(mocks);
1041 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1057 bfm_ut::test_ioctl_driver_process_vmcall_versions_protocol_version()
1059 MockRepository mocks;
1061 auto &&fil = setup_file(mocks);
1068 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1086 bfm_ut::test_ioctl_driver_process_vmcall_versions_bareflank_version()
1088 MockRepository mocks;
1090 auto &&fil = setup_file(mocks);
1097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1117 bfm_ut::test_ioctl_driver_process_vmcall_versions_user_version()
1119 MockRepository mocks;
1121 auto &&fil = setup_file(mocks);
1128 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1148 bfm_ut::test_ioctl_driver_process_vmcall_versions_unknown()
1150 MockRepository mocks;
1152 auto &&fil = setup_file(mocks);
1159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1165 regs->r02 = 0x8000000000000000;
1179 bfm_ut::test_ioctl_driver_process_vmcall_registers_ioctl_failed()
1181 MockRepository mocks;
1183 auto &&fil = setup_file(mocks);
1190 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1203 bfm_ut::test_ioctl_driver_process_vmcall_registers_ioctl_return_failed()
1205 MockRepository mocks;
1207 auto &&fil = setup_file(mocks);
1214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1230 bfm_ut::test_ioctl_driver_process_vmcall_registers_success()
1232 MockRepository mocks;
1234 auto &&fil = setup_file(mocks);
1241 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1252 bfm_ut::test_ioctl_driver_process_vmcall_unittest_ioctl_failed()
1254 MockRepository mocks;
1256 auto &&fil = setup_file(mocks);
1263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1276 bfm_ut::test_ioctl_driver_process_vmcall_unittest_ioctl_return_failed()
1278 MockRepository mocks;
1280 auto &&fil = setup_file(mocks);
1287 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1303 bfm_ut::test_ioctl_driver_process_vmcall_unittest_success()
1305 MockRepository mocks;
1307 auto &&fil = setup_file(mocks);
1314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1325 bfm_ut::test_ioctl_driver_process_vmcall_event_ioctl_failed()
1327 MockRepository mocks;
1329 auto &&fil = setup_file(mocks);
1336 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1349 bfm_ut::test_ioctl_driver_process_vmcall_event_ioctl_return_failed()
1351 MockRepository mocks;
1353 auto &&fil = setup_file(mocks);
1360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1376 bfm_ut::test_ioctl_driver_process_vmcall_event_success()
1378 MockRepository mocks;
1380 auto &&fil = setup_file(mocks);
1387 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1411 bfm_ut::test_ioctl_driver_process_vmcall_data_string_unformatted_unknown_data_type()
1413 MockRepository mocks;
1415 auto &&fil = setup_file(mocks);
1424 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1437 bfm_ut::test_ioctl_driver_process_vmcall_data_string_unformatted_ioctl_failed()
1439 MockRepository mocks;
1441 auto &&fil = setup_file(mocks);
1450 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1463 bfm_ut::test_ioctl_driver_process_vmcall_data_string_unformatted_ioctl_return_failed()
1465 MockRepository mocks;
1467 auto &&fil = setup_file(mocks);
1476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1492 bfm_ut::test_ioctl_driver_process_vmcall_data_string_unformatted_out_of_range()
1494 MockRepository mocks;
1496 auto &&fil = setup_file(mocks);
1505 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1522 bfm_ut::test_ioctl_driver_process_vmcall_data_string_unformatted_success_no_return()
1524 MockRepository mocks;
1526 auto &&fil = setup_file(mocks);
1535 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1551 bfm_ut::test_ioctl_driver_process_vmcall_data_string_unformatted_success_unformatted()
1553 MockRepository mocks;
1555 auto &&fil = setup_file(mocks);
1564 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1581 bfm_ut::test_ioctl_driver_process_vmcall_data_string_json_ioctl_failed()
1583 MockRepository mocks;
1585 auto &&fil = setup_file(mocks);
1594 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1607 bfm_ut::test_ioctl_driver_process_vmcall_data_string_json_ioctl_return_failed()
1609 MockRepository mocks;
1611 auto &&fil = setup_file(mocks);
1620 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1636 bfm_ut::test_ioctl_driver_process_vmcall_data_string_json_out_of_range()
1638 MockRepository mocks;
1640 auto &&fil = setup_file(mocks);
1649 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1666 bfm_ut::test_ioctl_driver_process_vmcall_data_string_json_success_no_return()
1668 MockRepository mocks;
1670 auto &&fil = setup_file(mocks);
1679 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1695 bfm_ut::test_ioctl_driver_process_vmcall_data_string_json_parse_failure()
1697 MockRepository mocks;
1699 auto &&fil = setup_file(mocks);
1708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1713 auto &&output =
"hello world"_s;
1714 __builtin_memcpy(reinterpret_cast<char *>(regs->r08), output.c_str(), output.size());
1717 regs->r09 = output.size();
1728 bfm_ut::test_ioctl_driver_process_vmcall_data_string_json_success_json()
1730 MockRepository mocks;
1732 auto &&fil = setup_file(mocks);
1741 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1746 auto &&output =
"{\"msg\":\"hello world\"}"_s;
1747 __builtin_memcpy(reinterpret_cast<char *>(regs->r08), output.c_str(), output.size());
1750 regs->r09 = output.size();
1761 bfm_ut::test_ioctl_driver_process_vmcall_data_binary_unformatted_ifile_failed()
1763 MockRepository mocks;
1765 auto &&fil = setup_file(mocks);
1776 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1787 bfm_ut::test_ioctl_driver_process_vmcall_data_binary_unformatted_ioctl_failed()
1789 MockRepository mocks;
1791 auto &&fil = setup_file(mocks);
1800 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1813 bfm_ut::test_ioctl_driver_process_vmcall_data_binary_unformatted_ioctl_return_failed()
1815 MockRepository mocks;
1817 auto &&fil = setup_file(mocks);
1826 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1842 bfm_ut::test_ioctl_driver_process_vmcall_data_binary_unformatted_out_of_range()
1844 MockRepository mocks;
1846 auto &&fil = setup_file(mocks);
1855 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1872 bfm_ut::test_ioctl_driver_process_vmcall_data_binary_unformatted_success_no_return()
1874 MockRepository mocks;
1876 auto &&fil = setup_file(mocks);
1885 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1901 bfm_ut::test_ioctl_driver_process_vmcall_data_binary_unformatted_success_unformatted()
1903 MockRepository mocks;
1905 auto &&fil = setup_file(mocks);
1914 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
#define expect_exception(f, e)
#define RUN_UNITTEST_WITH_MOCKS(a, b)
virtual void call_ioctl_vmm_status(gsl::not_null< status_pointer > status)
virtual const filename_type & ifile() const noexcept
#define expect_no_exception(f)
virtual void call_ioctl_start_vmm()
virtual cpuid_type cpuid() const noexcept
#define VMCALL_OUT_BUFFER_SIZE
virtual void write_binary(const filename_type &filename, const binary_data &data) const
debug_ring_resources_t * drr
virtual void call_ioctl_stop_vmm()
virtual void call_ioctl_unload_vmm()
virtual command_type cmd() const noexcept
ioctl::status_type g_status
virtual void call_ioctl_dump_vmm(gsl::not_null< drr_pointer > drr, vcpuid_type vcpuid)
virtual void call_ioctl_load_vmm()
virtual text_data read_text(const filename_type &filename) const
virtual void write_text(const filename_type &filename, const text_data &data) const
virtual binary_data read_binary(const filename_type &filename) const
virtual const filename_type & ofile() const noexcept
virtual const registers_type & registers() const noexcept
std::vector< char > binary_data
virtual void call_ioctl_vmcall(gsl::not_null< registers_pointer > regs, cpuid_type cpuid)
virtual vcpuid_type vcpuid() const noexcept
virtual const filename_type & modules() const noexcept
virtual void call_ioctl_add_module(const binary_data &module_data)