From ace8cc2d2fd9a5f133237b8a1c41802683a65ce8 Mon Sep 17 00:00:00 2001 From: Yi Huang Date: Mon, 28 Aug 2023 16:19:50 +0800 Subject: [PATCH] [Test] Grow memory pages to Wasm limit --- tests/README.md | 4 ++++ tests/memory/invalid-size.wasm | Bin 0 -> 61 bytes tests/memory/invalid-size.wat | 9 +++++++++ tests/memory/valid-size.wasm | Bin 0 -> 61 bytes tests/memory/valid-size.wat | 9 +++++++++ 5 files changed, 22 insertions(+) create mode 100644 tests/memory/invalid-size.wasm create mode 100644 tests/memory/invalid-size.wat create mode 100644 tests/memory/valid-size.wasm create mode 100644 tests/memory/valid-size.wat diff --git a/tests/README.md b/tests/README.md index 8da2c7d..4f07839 100644 --- a/tests/README.md +++ b/tests/README.md @@ -8,11 +8,15 @@ | [out-of-bound.wat] | start w/ 1 memory page; store an `i32` at addr `65533` | fails w/ `out of bounds memory access` | | [wellgrown.wat] | limit at 2 memory pages; start w/ 1 page and grow by 1 page | returns `1` | | [overgrown.wat] | limit at 2 memory pages; start w/ 1 page and grow by 2 pages | returns `4294967295` (`-1` in `u32`) | +| [valid-size.wat] | grow memory by 65536 pages | returns `0` | +| [invalid-size.wat] | grow memory by 65537 pages | returns `4294967295` (`-1` in `u32`) | [just-in-bound.wat]: memory/just-in-bound.wat [out-of-bound.wat]: memory/out-of-bound.wat [wellgrown.wat]: memory/wellgrown.wat [overgrown.wat]: memory/overgrown.wat +[valid-size.wat]: memory/valid-size.wat +[invalid-size.wat]: memory/invalid-size.wat ## Running diff --git a/tests/memory/invalid-size.wasm b/tests/memory/invalid-size.wasm new file mode 100644 index 0000000000000000000000000000000000000000..a28227f556af89675a0da9b24488b55319851866 GIT binary patch literal 61 zcmZQbEY4+QU|?Y6VoG4FXRJ?PV610mW@2DuWd;hfb1|~T7ndX!l>ik8GO;lzFgP%9 Ob1*nIHn0dVa037c5(qy4 literal 0 HcmV?d00001 diff --git a/tests/memory/invalid-size.wat b/tests/memory/invalid-size.wat new file mode 100644 index 0000000..ca6fe8d --- /dev/null +++ b/tests/memory/invalid-size.wat @@ -0,0 +1,9 @@ +(module + (func $grow (param $p i32) (result i32) + (memory.grow (local.get $p)) + ) + (memory 0) + (func $main (export "_start") (result i32) + (call $grow (i32.const 65537)) + ) +) diff --git a/tests/memory/valid-size.wasm b/tests/memory/valid-size.wasm new file mode 100644 index 0000000000000000000000000000000000000000..8afd1b4e53f272dfbc27a784c24149899f8e5a0a GIT binary patch literal 61 zcmZQbEY4+QU|?Y6VoG4FXRJ?PV610mW@2DuWd;hfb1|~T7ndX!l>ik8GO;lzFgP%9 Ob1*nIG_VLTa037c3