Add two tests for mem map wrap

This commit is contained in:
lazymio 2022-04-16 18:19:41 +02:00
parent e8129b6f66
commit cf18982e1c
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873

View File

@ -144,10 +144,43 @@ static void test_mem_protect_map_ptr(void)
OK(uc_close(uc));
}
static void test_map_at_the_end(void)
{
uc_engine *uc;
uint8_t mem[0x1000];
memset(mem, 0xff, 0x100);
OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));
OK(uc_mem_map(uc, 0xfffffffffffff000, 0x1000, UC_PROT_ALL));
OK(uc_mem_write(uc, 0xfffffffffffff000, mem, sizeof(mem)));
uc_assert_err(UC_ERR_WRITE_UNMAPPED,
uc_mem_write(uc, 0xffffffffffffff00, mem, sizeof(mem)));
uc_assert_err(UC_ERR_WRITE_UNMAPPED, uc_mem_write(uc, 0, mem, sizeof(mem)));
OK(uc_close(uc));
}
static void test_map_wrap(void)
{
uc_engine *uc;
OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));
uc_assert_err(UC_ERR_ARG,
uc_mem_map(uc, 0xfffffffffffff000, 0x2000, UC_PROT_ALL));
OK(uc_close(uc));
}
TEST_LIST = {{"test_map_correct", test_map_correct},
{"test_map_wrapping", test_map_wrapping},
{"test_mem_protect", test_mem_protect},
{"test_splitting_mem_unmap", test_splitting_mem_unmap},
{"test_splitting_mmio_unmap", test_splitting_mmio_unmap},
{"test_mem_protect_map_ptr", test_mem_protect_map_ptr},
{"test_map_at_the_end", test_map_at_the_end},
{"test_map_wrap", test_map_wrap},
{NULL, NULL}};