Skip to content

Commit

Permalink
test: Add memory.grow cases with huge hard memory limit
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 authored and axic committed Mar 10, 2021
1 parent 66bde8d commit e936c1f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unittests/execute_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ TEST(execute, memory_grow_custom_hard_limit)
{1, 1},
{15, 1},
{16, -1},
{65535, -1},
{0xffffffff, -1},
};

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e936c1f

Please sign in to comment.