Fix off-by-one bug and add a unit test

This commit is contained in:
mio
2024-10-13 15:19:05 +08:00
parent 579317bb21
commit fbf34af81c
2 changed files with 5 additions and 1 deletions

View File

@@ -181,11 +181,14 @@ static void test_uc_ctl_change_page_size(void)
{
uc_engine *uc;
uc_engine *uc2;
uint32_t pg = 0;
OK(uc_open(UC_ARCH_ARM, UC_MODE_ARM, &uc));
OK(uc_open(UC_ARCH_ARM, UC_MODE_ARM, &uc2));
OK(uc_ctl_set_page_size(uc, 4096));
OK(uc_ctl_get_page_size(uc, &pg));
TEST_CHECK(pg == 4096);
OK(uc_mem_map(uc2, 1 << 10, 1 << 10, UC_PROT_ALL));
uc_assert_err(UC_ERR_ARG, uc_mem_map(uc, 1 << 10, 1 << 10, UC_PROT_ALL));