From e936c1fa576c15cec325d6f8e6d6169936111131 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Wed, 3 Mar 2021 16:08:23 +0100 Subject: [PATCH] test: Add memory.grow cases with huge hard memory limit --- test/unittests/execute_test.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unittests/execute_test.cpp b/test/unittests/execute_test.cpp index 8d54f7cebf..a2fdef169a 100644 --- a/test/unittests/execute_test.cpp +++ b/test/unittests/execute_test.cpp @@ -673,6 +673,7 @@ TEST(execute, memory_grow_custom_hard_limit) {1, 1}, {15, 1}, {16, -1}, + {65535, -1}, {0xffffffff, -1}, }; @@ -693,6 +694,12 @@ TEST(execute, memory_grow_custom_hard_limit) EXPECT_THAT(execute(*instance, 0, {input}), Result(expected)); } + { + const auto instance_huge_hard_limit = instantiate(*module, {}, {}, {}, {}, 65536); + EXPECT_THAT(execute(*instance_huge_hard_limit, 0, {65536}), Result(-1)); + EXPECT_THAT(execute(*instance_huge_hard_limit, 0, {0xffffffff}), Result(-1)); + } + /* wat2wasm (memory 1 16) (func (param i32) (result i32) @@ -734,6 +741,14 @@ TEST(execute, memory_grow_custom_hard_limit) EXPECT_THAT(execute(*instance_max_limit, 0, {input}), Result(expected)); } + { + bytes memory(PageSize, 0); + const auto instance_huge_hard_limit = + instantiate(*module_imported, {}, {}, {{&memory, {1, std::nullopt}}}, {}, 65536); + EXPECT_THAT(execute(*instance_huge_hard_limit, 0, {65536}), Result(-1)); + EXPECT_THAT(execute(*instance_huge_hard_limit, 0, {0xffffffff}), Result(-1)); + } + /* wat2wasm (memory (import "mod" "mem") 1 16) (func (param i32) (result i32)