Adjust big memory test for host pagesize

On machines with a page size larger than 4K, the requested memory size
in `test_map_big_memory` gets rounded up and overflows to zero.

This PR adds some code to query the page size and adjust the requested
memory size accordingly.
This commit is contained in:
Timo Röhling 2022-09-24 13:58:23 +02:00 committed by mio
parent e76b2db434
commit e1e7b25268
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873

View File

@ -184,8 +184,15 @@ static void test_map_big_memory(void)
OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc)); OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));
#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)
uint64_t requested_size = 0xfffffffffffff000; // assume 4K page size
#else
long ps = sysconf(_SC_PAGESIZE);
uint64_t requested_size = (uint64_t)(-ps);
#endif
uc_assert_err(UC_ERR_NOMEM, uc_assert_err(UC_ERR_NOMEM,
uc_mem_map(uc, 0x0, 0xfffffffffffff000, UC_PROT_ALL)); uc_mem_map(uc, 0x0, requested_size, UC_PROT_ALL));
OK(uc_close(uc)); OK(uc_close(uc));
} }