diff options
Diffstat (limited to 'test/spec')
-rw-r--r-- | test/spec/bulk-memory.wast | 6 | ||||
-rw-r--r-- | test/spec/bulk-memory64.wast | 6 | ||||
-rw-r--r-- | test/spec/data.wast | 276 | ||||
-rw-r--r-- | test/spec/imports.wast | 4 | ||||
-rw-r--r-- | test/spec/old_import.wast | 4 |
5 files changed, 221 insertions, 75 deletions
diff --git a/test/spec/bulk-memory.wast b/test/spec/bulk-memory.wast index 62e9cdb3a..1a2d3e440 100644 --- a/test/spec/bulk-memory.wast +++ b/test/spec/bulk-memory.wast @@ -1,7 +1,7 @@ ;; Passive segment syntax (module (memory 1) - (data passive "foo")) + (data "foo")) ;; memory.fill (module @@ -112,7 +112,7 @@ ;; memory.init (module (memory 1) - (data passive "\aa\bb\cc\dd") + (data "\aa\bb\cc\dd") (func (export "init") (param i32 i32 i32) (memory.init 0 @@ -152,7 +152,7 @@ ;; data.drop (module (memory 1) - (data passive "") + (data "") (data (i32.const 0) "") (func (export "drop_passive") (data.drop 0)) diff --git a/test/spec/bulk-memory64.wast b/test/spec/bulk-memory64.wast index 6c0ec7bb6..2ad60a47d 100644 --- a/test/spec/bulk-memory64.wast +++ b/test/spec/bulk-memory64.wast @@ -1,7 +1,7 @@ ;; Passive segment syntax (module (memory i64 1) - (data passive "foo")) + (data "foo")) ;; memory.fill (module @@ -112,7 +112,7 @@ ;; memory.init (module (memory i64 1) - (data passive "\aa\bb\cc\dd") + (data "\aa\bb\cc\dd") (func (export "init") (param i64 i32 i32) (memory.init 0 @@ -152,7 +152,7 @@ ;; data.drop (module (memory i64 1) - (data passive "") + (data "") (data (i64.const 0) "") (func (export "drop_passive") (data.drop 0)) diff --git a/test/spec/data.wast b/test/spec/data.wast index 7d6945417..31e88927e 100644 --- a/test/spec/data.wast +++ b/test/spec/data.wast @@ -8,14 +8,26 @@ (data (i32.const 1) "a" "" "bcd") (data (offset (i32.const 0))) (data (offset (i32.const 0)) "" "a" "bc" "") - (data 0 (i32.const 0)) - (data 0x0 (i32.const 1) "a" "" "bcd") - (data 0x000 (offset (i32.const 0))) - (data 0 (offset (i32.const 0)) "" "a" "bc" "") - (data $m (i32.const 0)) - (data $m (i32.const 1) "a" "" "bcd") - (data $m (offset (i32.const 0))) - (data $m (offset (i32.const 0)) "" "a" "bc" "") + (data (memory 0) (i32.const 0)) + (data (memory 0x0) (i32.const 1) "a" "" "bcd") + (data (memory 0x000) (offset (i32.const 0))) + (data (memory 0) (offset (i32.const 0)) "" "a" "bc" "") + (data (memory $m) (i32.const 0)) + (data (memory $m) (i32.const 1) "a" "" "bcd") + (data (memory $m) (offset (i32.const 0))) + (data (memory $m) (offset (i32.const 0)) "" "a" "bc" "") + (data $d1 (i32.const 0)) + (data $d2 (i32.const 1) "a" "" "bcd") + (data $d3 (offset (i32.const 0))) + (data $d4 (offset (i32.const 0)) "" "a" "bc" "") + (data $d5 (memory 0) (i32.const 0)) + (data $d6 (memory 0x0) (i32.const 1) "a" "" "bcd") + (data $d7 (memory 0x000) (offset (i32.const 0))) + (data $d8 (memory 0) (offset (i32.const 0)) "" "a" "bc" "") + (data $d9 (memory $m) (i32.const 0)) + (data $d10 (memory $m) (i32.const 1) "a" "" "bcd") + (data $d11 (memory $m) (offset (i32.const 0))) + (data $d12 (memory $m) (offset (i32.const 0)) "" "a" "bc" "") ) ;; Basic use @@ -124,78 +136,76 @@ (data (i32.const 0) "" "") ) -(module - (import "spectest" "memory" (memory 0)) - (data (i32.const 0) "a") -) +;; (module +;; (import "spectest" "memory" (memory 0)) +;; (data (i32.const 0) "a") +;; ) -(module - (import "spectest" "memory" (memory 0 3)) - (data (i32.const 0) "a") -) +;; (module +;; (import "spectest" "memory" (memory 0 3)) +;; (data (i32.const 0) "a") +;; ) -(module - (global (import "spectest" "global_i32") i32) - (import "spectest" "memory" (memory 0)) - (data (global.get 0) "a") -) +;; (module +;; (global (import "spectest" "global_i32") i32) +;; (import "spectest" "memory" (memory 0)) +;; (data (global.get 0) "a") +;; ) -(module - (global (import "spectest" "global_i32") i32) - (import "spectest" "memory" (memory 0 3)) - (data (global.get 0) "a") -) +;; (module +;; (global (import "spectest" "global_i32") i32) +;; (import "spectest" "memory" (memory 0 3)) +;; (data (global.get 0) "a") +;; ) -(module - (import "spectest" "memory" (memory 0)) - (data (i32.const 1) "a") -) +;; (module +;; (import "spectest" "memory" (memory 0)) +;; (data (i32.const 1) "a") +;; ) -(module - (import "spectest" "memory" (memory 0 3)) - (data (i32.const 1) "a") -) +;; (module +;; (import "spectest" "memory" (memory 0 3)) +;; (data (i32.const 1) "a") +;; ) ;; Invalid bounds for data -(assert_unlinkable +(assert_trap (module (memory 0) (data (i32.const 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 0 0) (data (i32.const 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 0 1) (data (i32.const 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) - -(assert_unlinkable +(assert_trap (module (memory 0) (data (i32.const 1)) ) - "data segment does not fit" + "out of bounds memory access" ) - -(assert_unlinkable +(assert_trap (module (memory 0 1) (data (i32.const 1)) ) - "data segment does not fit" + "out of bounds memory access" ) ;; This seems to cause a time-out on Travis. @@ -204,77 +214,77 @@ (memory 0x10000) (data (i32.const 0xffffffff) "ab") ) - "" ;; either out of memory or segment does not fit + "" ;; either out of memory or out of bounds ;) -(assert_unlinkable +(assert_trap (module (global (import "spectest" "global_i32") i32) (memory 0) (data (global.get 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 1 2) (data (i32.const 0x1_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "memory" (memory 1)) (data (i32.const 0x1_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 2) (data (i32.const 0x2_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 2 3) (data (i32.const 0x2_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 1) (data (i32.const -1) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "memory" (memory 1)) (data (i32.const -1) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 2) (data (i32.const -100) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "memory" (memory 1)) (data (i32.const -100) "a") ) - "data segment does not fit" + "out of bounds memory access" ) ;; Data without memory @@ -286,6 +296,82 @@ "unknown memory" ) +;; Data segment with memory index 1 (only memory 0 available) +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\05\03\01" ;; memory section + "\00\00" ;; memory 0 + "\0b\07\01" ;; data section + "\02\01\41\00\0b" ;; active data segment 0 for memory 1 + "\00" ;; empty vec(byte) + ) + "unknown memory 1" +) + +;; Data segment with memory index 0 (no memory section) +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\0b\06\01" ;; data section + "\00\41\00\0b" ;; active data segment 0 for memory 0 + "\00" ;; empty vec(byte) + ) + "unknown memory 0" +) + +;; Data segment with memory index 1 (no memory section) +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\0b\07\01" ;; data section + "\02\01\41\00\0b" ;; active data segment 0 for memory 1 + "\00" ;; empty vec(byte) + ) + "unknown memory 1" +) + +;; Data segment with memory index 1 and vec(byte) as above, +;; only memory 0 available. +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\05\03\01" ;; memory section + "\00\00" ;; memory 0 + "\0b\45\01" ;; data section + "\02" ;; active segment + "\01" ;; memory index + "\41\00\0b" ;; offset constant expression + "\3e" ;; vec(byte) length + "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f" + "\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f" + "\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f" + "\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d" + ) + "unknown memory 1" +) + +;; Data segment with memory index 1 and specially crafted vec(byte) after. +;; This is to detect incorrect validation where memory index is interpreted +;; as a flag followed by "\41" interpreted as the size of vec(byte) +;; with the expected number of bytes following. +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\0b\45\01" ;; data section + "\02" ;; active segment + "\01" ;; memory index + "\41\00\0b" ;; offset constant expression + "\3e" ;; vec(byte) length + "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f" + "\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f" + "\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f" + "\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d" + ) + "unknown memory 1" +) + + ;; Invalid offsets (assert_invalid @@ -297,6 +383,40 @@ ) (assert_invalid + (module + (memory 1) + (data (offset (;empty instruction sequence;))) + ) + "type mismatch" +) + +(assert_invalid + (module + (memory 1) + (data (offset (i32.const 0) (i32.const 0))) + ) + "type mismatch" +) + +(assert_invalid + (module + (global (import "test" "global-i32") i32) + (memory 1) + (data (offset (global.get 0) (global.get 0))) + ) + "type mismatch" +) + +(assert_invalid + (module + (global (import "test" "global-i32") i32) + (memory 1) + (data (offset (global.get 0) (i32.const 0))) + ) + "type mismatch" +) + +(assert_invalid (module (memory 1) (data (i32.ctz (i32.const 0))) @@ -333,3 +453,29 @@ ;; (module (memory 1) (data (global.get $g)) (global $g (mut i32) (i32.const 0))) ;; "constant expression required" ;; ) + +(assert_invalid + (module + (memory 1) + (data (global.get 0)) + ) + "unknown global 0" +) + +(assert_invalid + (module + (global (import "test" "global-i32") i32) + (memory 1) + (data (global.get 1)) + ) + "unknown global 1" +) + +(assert_invalid + (module + (global (import "test" "global-mut-i32") (mut i32)) + (memory 1) + (data (global.get 0)) + ) + "constant expression required" +)
\ No newline at end of file diff --git a/test/spec/imports.wast b/test/spec/imports.wast index 2f0200dc3..04c1746c7 100644 --- a/test/spec/imports.wast +++ b/test/spec/imports.wast @@ -380,7 +380,7 @@ (module (import "spectest" "memory" (memory 1 2)) - (data 0 (i32.const 10) "\10") + (data (i32.const 10) "\10") (func (export "load") (param i32) (result i32) (i32.load (local.get 0))) ) @@ -392,7 +392,7 @@ (module (memory (import "spectest" "memory") 1 2) - (data 0 (i32.const 10) "\10") + (data (i32.const 10) "\10") (func (export "load") (param i32) (result i32) (i32.load (local.get 0))) ) diff --git a/test/spec/old_import.wast b/test/spec/old_import.wast index 6c5e9dcdb..bc6144185 100644 --- a/test/spec/old_import.wast +++ b/test/spec/old_import.wast @@ -158,7 +158,7 @@ (module (import "spectest" "memory" (memory 1 2)) - (data 0 (i32.const 10) "\10") + (data (i32.const 10) "\10") (func (export "load") (param i32) (result i32) (i32.load (local.get 0))) ) @@ -170,7 +170,7 @@ (module (memory (import "spectest" "memory") 1 2) - (data 0 (i32.const 10) "\10") + (data (i32.const 10) "\10") (func (export "load") (param i32) (result i32) (i32.load (local.get 0))) ) |