Skip to content

Commit

Permalink
[Test] Grow memory pages to Wasm limit
Browse files Browse the repository at this point in the history
  • Loading branch information
0yi0 committed Sep 4, 2023
1 parent 5419042 commit ace8cc2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added tests/memory/invalid-size.wasm
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/memory/invalid-size.wat
Original file line number Diff line number Diff line change
@@ -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))
)
)
Binary file added tests/memory/valid-size.wasm
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/memory/valid-size.wat
Original file line number Diff line number Diff line change
@@ -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 65536))
)
)

0 comments on commit ace8cc2

Please sign in to comment.