added test for unmap of doubly mapped region

This commit is contained in:
coco 2015-12-28 22:02:31 +01:00
parent 53a989a751
commit fa2da819b6
2 changed files with 14 additions and 1 deletions

View file

@ -29,4 +29,4 @@ test_mem_map_ptr: test_mem_map_ptr.c
test_mem_high: test_mem_high.c test_mem_high: test_mem_high.c
${ALL_TESTS}: ${ALL_TESTS}:
gcc ${CFLAGS} -o $@ $^ clang ${CFLAGS} -o $@ $^

View file

@ -129,6 +129,18 @@ static void test_bad_unmap(void **state)
} }
/* Try to unmap memory that has not been mapped twice*/
static void test_unmap_double_map(void **state)
{
uc_engine *uc = *state;
/* TODO: Which error should this return? */
uc_assert_success(uc_mem_map(uc, 0, 0x4000, 0)); /* 0x0000 - 0x1000 */
uc_assert_success(uc_mem_map(uc, 0x0000, 0x1000, 0)); /* 0x1000 - 0x2000 */
uc_assert_fail(uc_mem_unmap(uc, 0x2000, 0x2000));
}
int main(void) { int main(void) {
#define test(x) cmocka_unit_test_setup_teardown(x, setup, teardown) #define test(x) cmocka_unit_test_setup_teardown(x, setup, teardown)
const struct CMUnitTest tests[] = { const struct CMUnitTest tests[] = {
@ -137,6 +149,7 @@ int main(void) {
//test(test_bad_write), //test(test_bad_write),
test(test_bad_unmap), test(test_bad_unmap),
test(test_rw_across_boundaries), test(test_rw_across_boundaries),
test(test_unmap_double_map),
}; };
#undef test #undef test
return cmocka_run_group_tests(tests, NULL, NULL); return cmocka_run_group_tests(tests, NULL, NULL);