diff --git a/tests/unit/test_mem.c b/tests/unit/test_mem.c index c18e8be6..7ad51e5d 100644 --- a/tests/unit/test_mem.c +++ b/tests/unit/test_mem.c @@ -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}};