From e1e7b252686205006c4d10f66d66857c4f045784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Sat, 24 Sep 2022 13:58:23 +0200 Subject: [PATCH] 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. --- tests/unit/test_mem.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_mem.c b/tests/unit/test_mem.c index a1db14e1..8910fdcf 100644 --- a/tests/unit/test_mem.c +++ b/tests/unit/test_mem.c @@ -184,8 +184,15 @@ static void test_map_big_memory(void) 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_mem_map(uc, 0x0, 0xfffffffffffff000, UC_PROT_ALL)); + uc_mem_map(uc, 0x0, requested_size, UC_PROT_ALL)); OK(uc_close(uc)); }