From 20e284e86dedb380c286f1d360c5621d801181b7 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Fri, 27 Oct 2023 15:30:48 +0200 Subject: [PATCH] [test] introduce script scopes around expensive memory tests --- interpreter/script/js.ml | 20 ++++++++-- interpreter/script/run.ml | 3 +- interpreter/text/arrange.ml | 11 ++++-- test/core/memory_copy.wast | 66 +++++++++++++++++++++++++++++++ test/core/memory_fill.wast | 22 +++++++++++ test/core/memory_init.wast | 32 +++++++++++++++ test/core/table_copy.wast | 66 +++++++++++++++++++++++++++++++ test/core/table_init.wast | 54 +++++++++++++++++++++++++ test/meta/Makefile | 4 +- test/meta/generate_memory_copy.js | 54 +++++++++++++++++++------ test/meta/generate_memory_fill.js | 32 +++++++++++---- test/meta/generate_memory_init.js | 50 +++++++++++++++++------ test/meta/generate_table_copy.js | 4 ++ test/meta/generate_table_init.js | 4 ++ 14 files changed, 382 insertions(+), 40 deletions(-) diff --git a/interpreter/script/js.ml b/interpreter/script/js.ml index 2eb849a6c1..e2e7608933 100644 --- a/interpreter/script/js.ml +++ b/interpreter/script/js.ml @@ -585,7 +585,7 @@ let of_assertion mods ass = | AssertExhaustion (act, _) -> of_assertion' mods act "assert_exhaustion" [] None -let of_command mods cmd = +let rec of_command mods cmd = "\n// " ^ Filename.basename cmd.at.left.file ^ ":" ^ string_of_int cmd.at.left.line ^ "\n" ^ match cmd.it with @@ -605,8 +605,20 @@ let of_command mods cmd = of_assertion' mods act "run" [] None ^ "\n" | Assertion ass -> of_assertion mods ass ^ "\n" - | Meta _ -> assert false + | Meta meta -> + of_meta meta -let of_script scr = - (if !Flags.harness then harness else "") ^ +and of_meta cmd = + match cmd.it with + | Script (_, scr) -> + "\n// " ^ Filename.basename cmd.at.left.file ^ + ":" ^ string_of_int cmd.at.left.line ^ "\n" ^ + "{" ^ of_script' scr ^ "}\n" + | _ -> assert false + +and of_script' scr = String.concat "" (List.map (of_command (modules ())) scr) + +and of_script scr = + (if !Flags.harness then harness else "") ^ + of_script' scr diff --git a/interpreter/script/run.ml b/interpreter/script/run.ml index e0019d84a0..a9ba1db1ce 100644 --- a/interpreter/script/run.ml +++ b/interpreter/script/run.ml @@ -555,6 +555,7 @@ let rec run_command cmd = and run_meta cmd = match cmd.it with | Script (x_opt, script) -> + quote := (Meta cmd @@ cmd.at) :: !quote; run_quote_script script; bind scripts x_opt (lookup_script None cmd.at) @@ -589,7 +590,7 @@ and run_quote_script script = quote := []; (try run_script script with exn -> quote := save_quote; raise exn); bind scripts None (List.rev !quote); - quote := !quote @ save_quote + quote := save_quote let run_file file = input_file file run_script let run_string string = input_string string run_script diff --git a/interpreter/text/arrange.ml b/interpreter/text/arrange.ml index dc56743eb6..b736334ee4 100644 --- a/interpreter/text/arrange.ml +++ b/interpreter/text/arrange.ml @@ -765,12 +765,17 @@ let assertion mode ass = | AssertExhaustion (act, re) -> [Node ("assert_exhaustion", [action mode act; Atom (string re)])] -let command mode cmd = +let rec command mode cmd = match cmd.it with | Module (x_opt, def) -> [definition mode x_opt def] | Register (n, x_opt) -> [Node ("register " ^ name n ^ var_opt x_opt, [])] | Action act -> [action mode act] | Assertion ass -> assertion mode ass - | Meta _ -> assert false + | Meta met -> meta mode met -let script mode scr = Lib.List.concat_map (command mode) scr +and meta mode cmd = + match cmd.it with + | Script (x_opt, scr) -> [Node ("script" ^ var_opt x_opt, script mode scr)] + | _ -> assert false + +and script mode scr = Lib.List.concat_map (command mode) scr diff --git a/test/core/memory_copy.wast b/test/core/memory_copy.wast index 472995d79d..58bfea70d9 100644 --- a/test/core/memory_copy.wast +++ b/test/core/memory_copy.wast @@ -3,6 +3,7 @@ ;; DO NOT EDIT THIS FILE. CHANGE THE SOURCE AND REGENERATE. ;; +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -44,7 +45,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -86,7 +89,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -128,7 +133,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -170,7 +177,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -212,7 +221,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -254,7 +265,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 1)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -296,7 +309,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -338,7 +353,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -699,7 +716,9 @@ (assert_return (invoke "load8_u" (i32.const 65092)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 65291)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 65490)) (i32.const 0)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13\14") @@ -1061,7 +1080,9 @@ (assert_return (invoke "load8_u" (i32.const 65093)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 65292)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 65491)) (i32.const 0)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65516) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -1422,7 +1443,9 @@ (assert_return (invoke "load8_u" (i32.const 65533)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65534)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65535)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65515) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13\14") @@ -1784,7 +1807,9 @@ (assert_return (invoke "load8_u" (i32.const 65533)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65534)) (i32.const 19)) (assert_return (invoke "load8_u" (i32.const 65535)) (i32.const 20)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65486) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -2145,7 +2170,9 @@ (assert_return (invoke "load8_u" (i32.const 65503)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65504)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65505)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65516) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -2506,7 +2533,9 @@ (assert_return (invoke "load8_u" (i32.const 65533)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65534)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65535)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65506) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -2867,7 +2896,9 @@ (assert_return (invoke "load8_u" (i32.const 65523)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65524)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65525)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65516) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -3228,7 +3259,9 @@ (assert_return (invoke "load8_u" (i32.const 65533)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65534)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65535)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 65516) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -3589,7 +3622,9 @@ (assert_return (invoke "load8_u" (i32.const 65533)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65534)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65535)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 ) (data (i32.const 65516) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -3950,7 +3985,9 @@ (assert_return (invoke "load8_u" (i32.const 65533)) (i32.const 17)) (assert_return (invoke "load8_u" (i32.const 65534)) (i32.const 18)) (assert_return (invoke "load8_u" (i32.const 65535)) (i32.const 19)) +) +(script (module (memory (export "mem") 1 1 ) (data (i32.const 61440) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13") @@ -4311,6 +4348,7 @@ (assert_return (invoke "load8_u" (i32.const 65092)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 65291)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 65490)) (i32.const 0)) +) (assert_invalid (module @@ -4760,6 +4798,7 @@ "type mismatch") +(script (module (memory 1 1) (func (export "test") @@ -4785,7 +4824,9 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 20) (i32.const 65536) (i32.const 0)) (i32.const -1)) +) +(script (module (memory 1 1) (func (export "test") @@ -4811,31 +4852,41 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 21) (i32.const 65536) (i32.const 0)) (i32.const -1)) +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0xFF00) (i32.const 0x8000) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0xFFFFFF00) (i32.const 0x4000) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x8000) (i32.const 0xFF00) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x4000) (i32.const 0xFFFFFF00) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") @@ -4860,42 +4911,56 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 32768) (i32.const 65536) (i32.const 170)) (i32.const -1)) +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x10000) (i32.const 0x7000) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x20000) (i32.const 0x7000) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x9000) (i32.const 0x10000) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x9000) (i32.const 0x20000) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x10000) (i32.const 0x10000) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x20000) (i32.const 0x20000) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) (func (export "test") @@ -5576,3 +5641,4 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 64834) (i32.const 65536) (i32.const 0)) (i32.const -1)) +) diff --git a/test/core/memory_fill.wast b/test/core/memory_fill.wast index 98374a1586..7ba0d6f847 100644 --- a/test/core/memory_fill.wast +++ b/test/core/memory_fill.wast @@ -3,6 +3,7 @@ ;; DO NOT EDIT THIS FILE. CHANGE THE SOURCE AND REGENERATE. ;; +(script (module (memory 1 1) @@ -25,6 +26,8 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 65280) (i32.const 65536) (i32.const 85)) (i32.const -1)) +) +(script (module (memory 1 1) @@ -42,7 +45,9 @@ (func (export "test") (memory.fill (i32.const 0xFF00) (i32.const 0x55) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) @@ -60,7 +65,9 @@ (func (export "test") (memory.fill (i32.const 0xFFFFFF00) (i32.const 0x55) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) @@ -81,6 +88,8 @@ (assert_return (invoke "checkRange" (i32.const 0) (i32.const 65536) (i32.const 0)) (i32.const -1)) +) +(script (module (memory 1 1) @@ -98,7 +107,9 @@ (func (export "test") (memory.fill (i32.const 0x10000) (i32.const 0x55) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1 1) @@ -116,7 +127,9 @@ (func (export "test") (memory.fill (i32.const 0x20000) (i32.const 0x55) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1 1) @@ -141,7 +154,9 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 65535) (i32.const 65536) (i32.const 0)) (i32.const -1)) +) +(script (module (memory 1 1) @@ -171,6 +186,7 @@ (i32.const -1)) (assert_return (invoke "checkRange" (i32.const 28) (i32.const 65536) (i32.const 0)) (i32.const -1)) +) (assert_invalid (module (func (export "testfn") @@ -618,6 +634,7 @@ (memory.fill (f64.const 10) (f64.const 20) (f64.const 30)))) "type mismatch") +(script (module (memory 1 1 ) @@ -640,6 +657,8 @@ (assert_return (invoke "checkRange" (i32.const 0) (i32.const 1) (i32.const 0)) (i32.const -1)) +) +(script (module (memory 1 1 ) @@ -662,6 +681,8 @@ (assert_return (invoke "checkRange" (i32.const 0) (i32.const 1) (i32.const 0)) (i32.const -1)) +) +(script (module (memory 1 1 ) @@ -684,3 +705,4 @@ (assert_return (invoke "checkRange" (i32.const 0) (i32.const 1) (i32.const 0)) (i32.const -1)) +) diff --git a/test/core/memory_init.wast b/test/core/memory_init.wast index 672b1c5013..a6526badc5 100644 --- a/test/core/memory_init.wast +++ b/test/core/memory_init.wast @@ -3,6 +3,7 @@ ;; DO NOT EDIT THIS FILE. CHANGE THE SOURCE AND REGENERATE. ;; +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -46,7 +47,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -90,7 +93,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -134,7 +139,9 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\03\01\04\01") @@ -186,6 +193,7 @@ (assert_return (invoke "load8_u" (i32.const 27)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 28)) (i32.const 0)) (assert_return (invoke "load8_u" (i32.const 29)) (i32.const 0)) +) (assert_invalid (module (func (export "test") @@ -208,6 +216,7 @@ (data.drop 0))) (invoke "test") +(script (module (memory 1) (data "\37") @@ -215,13 +224,16 @@ (data.drop 0) (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1) (data (i32.const 0) "\37") (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1)))) (assert_trap (invoke "test") "out of bounds memory access") +) (assert_invalid (module @@ -237,6 +249,7 @@ (memory.init 1 (i32.const 1234) (i32.const 1) (i32.const 1)))) "unknown data segment 1") +(script (module (memory 1) (data "\37") @@ -244,69 +257,88 @@ (memory.init 0 (i32.const 1) (i32.const 0) (i32.const 1)) (memory.init 0 (i32.const 1) (i32.const 0) (i32.const 1)))) (invoke "test") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 0) (i32.const 5)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 2) (i32.const 3)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 0xFFFE) (i32.const 1) (i32.const 3)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 4) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 0x10001) (i32.const 0) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 0x10000) (i32.const 0) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 0x10000) (i32.const 1) (i32.const 0)))) (invoke "test") +) +(script (module (memory 1) (data "\37") (func (export "test") (memory.init 0 (i32.const 0x10001) (i32.const 4) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) (assert_invalid (module diff --git a/test/core/table_copy.wast b/test/core/table_copy.wast index 380e84ee59..8c379a1d71 100644 --- a/test/core/table_copy.wast +++ b/test/core/table_copy.wast @@ -1668,6 +1668,7 @@ (assert_trap (invoke "check_t1" (i32.const 28)) "uninitialized element") (assert_trap (invoke "check_t1" (i32.const 29)) "uninitialized element") +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1692,7 +1693,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1717,7 +1720,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1742,7 +1747,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1767,7 +1774,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1792,7 +1801,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1817,7 +1828,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1842,7 +1855,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1867,7 +1882,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1892,7 +1909,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1917,7 +1936,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1942,7 +1963,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1967,7 +1990,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -1992,7 +2017,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2017,7 +2044,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2042,7 +2071,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2067,7 +2098,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2092,7 +2125,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2117,7 +2152,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2142,7 +2179,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2167,7 +2206,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2192,7 +2233,9 @@ )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -2217,7 +2260,9 @@ )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2278,7 +2323,9 @@ (assert_trap (invoke "test" (i32.const 29)) "uninitialized element") (assert_trap (invoke "test" (i32.const 30)) "uninitialized element") (assert_trap (invoke "test" (i32.const 31)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2339,7 +2386,9 @@ (assert_trap (invoke "test" (i32.const 29)) "uninitialized element") (assert_trap (invoke "test" (i32.const 30)) "uninitialized element") (assert_trap (invoke "test" (i32.const 31)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2400,7 +2449,9 @@ (assert_return (invoke "test" (i32.const 29)) (i32.const 5)) (assert_return (invoke "test" (i32.const 30)) (i32.const 6)) (assert_return (invoke "test" (i32.const 31)) (i32.const 7)) +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2461,7 +2512,9 @@ (assert_return (invoke "test" (i32.const 29)) (i32.const 6)) (assert_return (invoke "test" (i32.const 30)) (i32.const 7)) (assert_return (invoke "test" (i32.const 31)) (i32.const 8)) +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2522,7 +2575,9 @@ (assert_trap (invoke "test" (i32.const 29)) "uninitialized element") (assert_trap (invoke "test" (i32.const 30)) "uninitialized element") (assert_trap (invoke "test" (i32.const 31)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2583,7 +2638,9 @@ (assert_return (invoke "test" (i32.const 29)) (i32.const 5)) (assert_return (invoke "test" (i32.const 30)) (i32.const 6)) (assert_return (invoke "test" (i32.const 31)) (i32.const 7)) +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2644,7 +2701,9 @@ (assert_trap (invoke "test" (i32.const 29)) "uninitialized element") (assert_trap (invoke "test" (i32.const 30)) "uninitialized element") (assert_trap (invoke "test" (i32.const 31)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2705,7 +2764,9 @@ (assert_return (invoke "test" (i32.const 29)) (i32.const 5)) (assert_return (invoke "test" (i32.const 30)) (i32.const 6)) (assert_return (invoke "test" (i32.const 31)) (i32.const 7)) +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -2766,7 +2827,9 @@ (assert_return (invoke "test" (i32.const 29)) (i32.const 8)) (assert_return (invoke "test" (i32.const 30)) (i32.const 9)) (assert_return (invoke "test" (i32.const 31)) (i32.const 10)) +) +(script (module (type (func (result i32))) (table 128 128 funcref) @@ -2923,7 +2986,9 @@ (assert_return (invoke "test" (i32.const 125)) (i32.const 13)) (assert_return (invoke "test" (i32.const 126)) (i32.const 14)) (assert_return (invoke "test" (i32.const 127)) (i32.const 15)) +) +(script (module (type (func (result i32))) (table 128 128 funcref) @@ -3080,3 +3145,4 @@ (assert_trap (invoke "test" (i32.const 125)) "uninitialized element") (assert_trap (invoke "test" (i32.const 126)) "uninitialized element") (assert_trap (invoke "test" (i32.const 127)) "uninitialized element") +) diff --git a/test/core/table_init.wast b/test/core/table_init.wast index 0b2d26f772..5fa7eb29a2 100644 --- a/test/core/table_init.wast +++ b/test/core/table_init.wast @@ -404,6 +404,7 @@ "unknown table 0") +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -427,7 +428,9 @@ (elem.drop 2) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -451,7 +454,9 @@ (table.init 2 (i32.const 12) (i32.const 1) (i32.const 1)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -475,7 +480,9 @@ (table.init 1 (i32.const 12) (i32.const 1) (i32.const 1)) (table.init 1 (i32.const 21) (i32.const 1) (i32.const 1)))) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -499,7 +506,9 @@ (elem.drop 1) (elem.drop 1))) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -523,7 +532,9 @@ (elem.drop 1) (table.init 1 (i32.const 12) (i32.const 1) (i32.const 1)))) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -547,7 +558,9 @@ (table.init 1 (i32.const 12) (i32.const 0) (i32.const 5)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -571,7 +584,9 @@ (table.init 1 (i32.const 12) (i32.const 2) (i32.const 3)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -595,7 +610,9 @@ (table.init $t0 1 (i32.const 28) (i32.const 1) (i32.const 3)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -619,7 +636,9 @@ (table.init $t0 1 (i32.const 12) (i32.const 4) (i32.const 0)) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -643,7 +662,9 @@ (table.init $t0 1 (i32.const 12) (i32.const 5) (i32.const 0)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -667,7 +688,9 @@ (table.init $t0 1 (i32.const 30) (i32.const 2) (i32.const 0)) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -691,7 +714,9 @@ (table.init $t0 1 (i32.const 31) (i32.const 2) (i32.const 0)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -715,7 +740,9 @@ (table.init $t0 1 (i32.const 30) (i32.const 4) (i32.const 0)) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -739,7 +766,9 @@ (table.init $t0 1 (i32.const 31) (i32.const 5) (i32.const 0)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -763,7 +792,9 @@ (table.init $t1 1 (i32.const 26) (i32.const 1) (i32.const 3)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -787,7 +818,9 @@ (table.init $t1 1 (i32.const 12) (i32.const 4) (i32.const 0)) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -811,7 +844,9 @@ (table.init $t1 1 (i32.const 12) (i32.const 5) (i32.const 0)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -835,7 +870,9 @@ (table.init $t1 1 (i32.const 28) (i32.const 2) (i32.const 0)) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -859,7 +896,9 @@ (table.init $t1 1 (i32.const 29) (i32.const 2) (i32.const 0)) )) (assert_trap (invoke "test") "out of bounds table access") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -883,7 +922,9 @@ (table.init $t1 1 (i32.const 28) (i32.const 4) (i32.const 0)) )) (invoke "test") +) +(script (module (table $t0 30 30 funcref) (table $t1 28 28 funcref) @@ -907,6 +948,7 @@ (table.init $t1 1 (i32.const 29) (i32.const 5) (i32.const 0)) )) (assert_trap (invoke "test") "out of bounds table access") +) (assert_invalid (module @@ -1475,6 +1517,7 @@ (table.init 0 (f64.const 1) (f64.const 1) (f64.const 1)))) "type mismatch") +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -1536,7 +1579,9 @@ (assert_trap (invoke "test" (i32.const 29)) "uninitialized element") (assert_trap (invoke "test" (i32.const 30)) "uninitialized element") (assert_trap (invoke "test" (i32.const 31)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 32 64 funcref) @@ -1598,7 +1643,9 @@ (assert_trap (invoke "test" (i32.const 29)) "uninitialized element") (assert_trap (invoke "test" (i32.const 30)) "uninitialized element") (assert_trap (invoke "test" (i32.const 31)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 160 320 funcref) @@ -1788,7 +1835,9 @@ (assert_trap (invoke "test" (i32.const 157)) "uninitialized element") (assert_trap (invoke "test" (i32.const 158)) "uninitialized element") (assert_trap (invoke "test" (i32.const 159)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 160 320 funcref) @@ -1978,7 +2027,9 @@ (assert_trap (invoke "test" (i32.const 157)) "uninitialized element") (assert_trap (invoke "test" (i32.const 158)) "uninitialized element") (assert_trap (invoke "test" (i32.const 159)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 64 64 funcref) @@ -2072,7 +2123,9 @@ (assert_trap (invoke "test" (i32.const 61)) "uninitialized element") (assert_trap (invoke "test" (i32.const 62)) "uninitialized element") (assert_trap (invoke "test" (i32.const 63)) "uninitialized element") +) +(script (module (type (func (result i32))) (table 16 16 funcref) @@ -2118,6 +2171,7 @@ (assert_trap (invoke "test" (i32.const 13)) "uninitialized element") (assert_trap (invoke "test" (i32.const 14)) "uninitialized element") (assert_trap (invoke "test" (i32.const 15)) "uninitialized element") +) (module (table 1 funcref) diff --git a/test/meta/Makefile b/test/meta/Makefile index 20e9adb2f5..05a42beb79 100644 --- a/test/meta/Makefile +++ b/test/meta/Makefile @@ -1,10 +1,10 @@ SHARED_MEM=false # SpiderMonkey shell -JSSHELL=~/mozilla-central/js/src/build-debug/dist/bin/js -e 'const WITH_SHARED_MEMORY=$(SHARED_MEM);' -f common.js +#JSSHELL=~/mozilla-central/js/src/build-debug/dist/bin/js -e 'const WITH_SHARED_MEMORY=$(SHARED_MEM);' -f common.js # Node.js -#JSSHELL=./noderun.sh $(SHARED_MEM) +JSSHELL=./noderun.sh $(SHARED_MEM) TARGETDIR=../core diff --git a/test/meta/generate_memory_copy.js b/test/meta/generate_memory_copy.js index 36751b86af..33b07eb140 100644 --- a/test/meta/generate_memory_copy.js +++ b/test/meta/generate_memory_copy.js @@ -8,6 +8,7 @@ print_origin("generate_memory_copy.js"); function mem_test(instruction, expected_result_vector) { print( ` +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\\03\\01\\04\\01") @@ -22,6 +23,7 @@ function mem_test(instruction, expected_result_vector) { for (let i = 0; i < expected_result_vector.length; i++) { print(`(assert_return (invoke "load8_u" (i32.const ${i})) (i32.const ${expected_result_vector[i]}))`); } + print(')'); } const e = 0; @@ -94,6 +96,7 @@ function mem_copy(min, max, shared, srcOffs, targetOffs, len) { print( ` +(script (module (memory (export "mem") ${min} ${max} ${shared}) (data (i32.const ${srcOffs}) "${initializers(srcLim - srcOffs, 0)}") @@ -122,6 +125,7 @@ function mem_copy(min, max, shared, srcOffs, targetOffs, len) { k = 0; } } + print(')'); } // OOB target address, nonoverlapping @@ -192,6 +196,7 @@ print( // result = 0x00--(09) 0x55--(11) 0x00--(pagesize-20) print( ` +(script (module (memory 1 1) (func (export "test") @@ -203,11 +208,13 @@ print( checkRange(0, 0+9, 0x00); checkRange(9, 9+11, 0x55); checkRange(9+11, 0x10000, 0x00); +print(')'); // Both ranges valid. Copy 5 bytes forwards by 1 (overlapping). // result = 0x00--(10) 0x55--(11) 0x00--(pagesize-19) print( ` +(script (module (memory 1 1) (func (export "test") @@ -219,47 +226,57 @@ print( checkRange(0, 0+10, 0x00); checkRange(10, 10+11, 0x55); checkRange(10+11, 0x10000, 0x00); +print(')'); // Destination range invalid print( ` +(script (module (memory 1 1) (func (export "test") (memory.copy (i32.const 0xFF00) (i32.const 0x8000) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Destination wraparound the end of 32-bit offset space print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0xFFFFFF00) (i32.const 0x4000) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Source range invalid print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x8000) (i32.const 0xFF00) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Source wraparound the end of 32-bit offset space print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x4000) (i32.const 0xFFFFFF00) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Zero len with both offsets in-bounds is a no-op print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.fill (i32.const 0x0000) (i32.const 0x55) (i32.const 0x8000)) @@ -270,65 +287,79 @@ print( `); checkRange(0x00000, 0x08000, 0x55); checkRange(0x08000, 0x10000, 0xAA); +print(')'); // Zero len with dest offset out-of-bounds at the end of memory is allowed print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x10000) (i32.const 0x7000) (i32.const 0)))) (invoke "test") +) `); // Zero len with dest offset out-of-bounds past the end of memory is not allowed print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x20000) (i32.const 0x7000) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Zero len with src offset out-of-bounds at the end of memory is allowed print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x9000) (i32.const 0x10000) (i32.const 0)))) (invoke "test") +) `); // Zero len with src offset out-of-bounds past the end of memory is not allowed print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x9000) (i32.const 0x20000) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Zero len with both dest and src offsets out-of-bounds at the end of memory is allowed print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x10000) (i32.const 0x10000) (i32.const 0)))) (invoke "test") +) `); // Zero len with both dest and src offsets out-of-bounds past the end of memory is not allowed print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.copy (i32.const 0x20000) (i32.const 0x20000) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // 100 random fills followed by 100 random copies, in a single-page buffer, // followed by verification of the (now heavily mashed-around) buffer. print( -`(module +`(script +(module (memory 1 1) (func (export "test") (memory.fill (i32.const 17767) (i32.const 1) (i32.const 1344)) @@ -766,3 +797,4 @@ checkRange(64331, 64518, 92); checkRange(64518, 64827, 11); checkRange(64827, 64834, 26); checkRange(64834, 65536, 0); +print(')'); diff --git a/test/meta/generate_memory_fill.js b/test/meta/generate_memory_fill.js index 3a8f485f15..2d7745d1ab 100644 --- a/test/meta/generate_memory_fill.js +++ b/test/meta/generate_memory_fill.js @@ -10,6 +10,7 @@ let PREAMBLE = // Range valid print( ` +(script (module ${PREAMBLE} (func (export "test") @@ -18,56 +19,68 @@ print( `); checkRange(0x00000, 0x0FF00, 0x00) checkRange(0x0FF00, 0x10000, 0x55) +print(')'); // Range invalid print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.fill (i32.const 0xFF00) (i32.const 0x55) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Wraparound the end of 32-bit offset space print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.fill (i32.const 0xFFFFFF00) (i32.const 0x55) (i32.const 257)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Zero len with offset in-bounds is a no-op print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.fill (i32.const 0x12) (i32.const 0x55) (i32.const 0)))) (invoke "test") `); checkRange(0x00000, 0x10000, 0x00); +print(')'); // Zero len with offset out-of-bounds at the end of memory is allowed print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.fill (i32.const 0x10000) (i32.const 0x55) (i32.const 0)))) (invoke "test") +) `); // Zero len with offset out-of-bounds past the end of memory is not allowed print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.fill (i32.const 0x20000) (i32.const 0x55) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // Very large range print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.fill (i32.const 0x1) (i32.const 0xAA) (i32.const 0xFFFE)))) @@ -76,10 +89,12 @@ print( checkRange(0x00000, 0x00001, 0x00); checkRange(0x00001, 0x0FFFF, 0xAA); checkRange(0x0FFFF, 0x10000, 0x00); +print(')'); // Sequencing print( ` +(script (module ${PREAMBLE} (func (export "test") @@ -92,6 +107,7 @@ checkRange(0x12+0, 0x12+3, 0x55); checkRange(0x12+3, 0x12+7, 0xAA); checkRange(0x12+7, 0x12+10, 0x55); checkRange(0x12+10, 0x10000, 0x00); +print(')'); // Sundry compilation failures. @@ -130,7 +146,8 @@ print( function mem_fill(min, max, shared, backup, write=backup*2) { print( -`(module +`(script +(module (memory ${min} ${max} ${shared}) ${checkRangeCode()} (func (export "run") (param $offs i32) (param $val i32) (param $len i32) @@ -144,6 +161,7 @@ function mem_fill(min, max, shared, backup, write=backup*2) { "out of bounds memory access") `); checkRange(0, min, 0); + print(')'); } mem_fill(1, 1, "", 256); diff --git a/test/meta/generate_memory_init.js b/test/meta/generate_memory_init.js index f8075cc339..31fd70b55b 100644 --- a/test/meta/generate_memory_init.js +++ b/test/meta/generate_memory_init.js @@ -8,6 +8,7 @@ print_origin("generate_memory_init.js"); function mem_test(instruction, expected_result_vector) { print( ` +(script (module (memory (export "memory0") 1 1) (data (i32.const 2) "\\03\\01\\04\\01") @@ -24,6 +25,7 @@ function mem_test(instruction, expected_result_vector) { for (let i = 0; i < expected_result_vector.length; i++) { print(`(assert_return (invoke "load8_u" (i32.const ${i})) (i32.const ${expected_result_vector[i]}))`); } + print(')'); } const e = 0; @@ -90,22 +92,26 @@ print( // drop, then init print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (data.drop 0) (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init with data seg ix indicating an active segment print( -`(module +`(script +(module (memory 1) (data (i32.const 0) "\\37") (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init with no memory @@ -129,94 +135,114 @@ print( // init, using a data seg ix more than once is OK print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 1) (i32.const 0) (i32.const 1)) (memory.init 0 (i32.const 1) (i32.const 0) (i32.const 1)))) (invoke "test") +) `); // init: seg ix is valid passive, but length to copy > len of seg print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 0) (i32.const 5)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init: seg ix is valid passive, but implies copying beyond end of seg print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 2) (i32.const 3)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init: seg ix is valid passive, but implies copying beyond end of dst print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 0xFFFE) (i32.const 1) (i32.const 3)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init: seg ix is valid passive, src offset past the end, zero len is invalid print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 4) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init: seg ix is valid passive, zero len, src offset at the end print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 0)))) (invoke "test") +) `); // init: seg ix is valid passive, dst offset past the end, zero len is invalid print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 0x10001) (i32.const 0) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // init: seg ix is valid passive, zero len, but dst offset at the end print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 0x10000) (i32.const 0) (i32.const 0)))) (invoke "test") +) `); // init: seg ix is valid passive, zero len, dst and src offsets at the end print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 0x10000) (i32.const 1) (i32.const 0)))) (invoke "test") +) `); // init: seg ix is valid passive, src and dst offset past the end, zero len is // invalid print( -`(module +`(script +(module ${PREAMBLE} (func (export "test") (memory.init 0 (i32.const 0x10001) (i32.const 4) (i32.const 0)))) (assert_trap (invoke "test") "out of bounds memory access") +) `); // invalid argument types. TODO: can add anyfunc etc here. diff --git a/test/meta/generate_table_copy.js b/test/meta/generate_table_copy.js index f7fd47dcba..6ef231fb8f 100644 --- a/test/meta/generate_table_copy.js +++ b/test/meta/generate_table_copy.js @@ -157,6 +157,7 @@ for ( let table of [0,1] ) { function do_test(insn1, insn2, errText) { print(` +(script (module (table $t0 30 30 funcref) (table $t1 30 30 funcref) @@ -186,6 +187,7 @@ function do_test(insn1, insn2, errText) } else { print(`(invoke "test")`); } + print(')'); } function tab_test2(insn1, insn2, errKind, errText) { @@ -285,6 +287,7 @@ function tbl_copy(min, max, srcOffs, targetOffs, len) { print( ` +(script (module (type (func (result i32))) (table ${min} ${max} funcref) @@ -331,6 +334,7 @@ function tbl_copy(min, max, srcOffs, targetOffs, len) { } print(`(assert_trap (invoke "test" (i32.const ${i})) "uninitialized element")`); } + print(')'); } // OOB target address, nonoverlapping diff --git a/test/meta/generate_table_init.js b/test/meta/generate_table_init.js index 16b9a84067..2680e3c913 100644 --- a/test/meta/generate_table_init.js +++ b/test/meta/generate_table_init.js @@ -153,6 +153,7 @@ let tab1_len = 28; function do_test(insn1, insn2, table, errText) { print(` +(script (module (table $t0 ${tab0_len} ${tab0_len} funcref) (table $t1 ${tab1_len} ${tab1_len} funcref) @@ -181,6 +182,7 @@ function do_test(insn1, insn2, table, errText) } else { print(`(invoke "test")`); } + print(')'); } function tab_test1(insn1, table, errText) { @@ -303,6 +305,7 @@ const tbl_init_len = 16; function tbl_init(min, max, backup, write, segoffs=0) { print( ` +(script (module (type (func (result i32))) (table ${min} ${max} funcref) @@ -342,6 +345,7 @@ function tbl_init(min, max, backup, write, segoffs=0) { for (let i=0; i < min; i++) { print(`(assert_trap (invoke "test" (i32.const ${i})) "uninitialized element")`); } + print(')'); } // We exceed the bounds of the table but not of the element segment