Skip to content

Commit

Permalink
Update the latest spec core test set
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 authored and ksh8281 committed Jun 12, 2024
1 parent a4a0fc2 commit 96989a5
Show file tree
Hide file tree
Showing 18 changed files with 2,750 additions and 1,076 deletions.
238 changes: 159 additions & 79 deletions test/wasm-spec/core/binary-leb128.wast
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\08\01" ;; type section
"\01\0c\01" ;; type section
"\60" ;; func type
"\02" ;; num params
"\7f\7e" ;; param type
Expand Down Expand Up @@ -404,19 +404,19 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\11\01" ;; Code section
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\11\01" ;; Code section
;; function 0
"\0f\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\82\80\80\80\80\00" ;; offset 2 with one byte too many
"\1a" ;; drop
"\0b" ;; end
"\0f\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\82\80\80\80\80\80\80\80\80\80\00" ;; offset 2 with one byte too many
"\1a" ;; drop
"\0b" ;; end
)
"integer representation too long"
)
Expand Down Expand Up @@ -461,19 +461,19 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\12\01" ;; Code section
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\12\01" ;; Code section
;; function 0
"\10\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\02" ;; alignment 2
"\82\80\80\80\80\00" ;; offset 2 with one byte too many
"\0b" ;; end
"\10\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\02" ;; alignment 2
"\82\80\80\80\80\80\80\80\80\80\00" ;; offset 2 with one byte too many
"\0b" ;; end
)
"integer representation too long"
)
Expand Down Expand Up @@ -730,40 +730,42 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\10\01" ;; Code section
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\10\01" ;; Code section
;; function 0
"\0e\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\82\80\80\80\10" ;; offset 2 with unused bits set
"\1a" ;; drop
"\0b" ;; end
"\0e\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\82\80\80\80\80\80\80\80\80\10" ;; offset 2 with unused bits set
"\1a" ;; drop
"\0b" ;; end
)
"integer too large"
;; TODO: This changes to "integer too large" with memory64.
"integer representation too long"
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\10\01" ;; Code section
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\10\01" ;; Code section
;; function 0
"\0e\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\82\80\80\80\40" ;; offset 2 with some unused bits set
"\1a" ;; drop
"\0b" ;; end
"\0e\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\28" ;; i32.load
"\02" ;; alignment 2
"\82\80\80\80\80\80\80\80\80\40" ;; offset 2 with some unused bits set
"\1a" ;; drop
"\0b" ;; end
)
"integer too large"
;; TODO: This changes to "integer too large" with memory64.
"integer representation too long"
)
(assert_malformed
(module binary
Expand Down Expand Up @@ -843,41 +845,42 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\11\01" ;; Code section
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\11\01" ;; Code section
;; function 0
"\0f\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\02" ;; alignment 2
"\82\80\80\80\10" ;; offset 2 with unused bits set
"\0b" ;; end
"\0f\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\02" ;; alignment 2
"\82\80\80\80\80\80\80\80\80\10" ;; offset 2 with unused bits set
"\0b" ;; end
)
"integer too large"
;; TODO: This changes to "integer too large" with memory64.
"integer representation too long"
)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\11\01" ;; Code section

"\01\04\01\60\00\00" ;; Type section
"\03\02\01\00" ;; Function section
"\05\03\01\00\01" ;; Memory section
"\0a\11\01" ;; Code section
;; function 0
"\0f\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\02" ;; alignment 2
"\82\80\80\80\40" ;; offset 2 with some unused bits set
"\0b" ;; end
"\0f\01\01" ;; local type count
"\7f" ;; i32
"\41\00" ;; i32.const 0
"\41\03" ;; i32.const 3
"\36" ;; i32.store
"\02" ;; alignment 2
"\82\80\80\80\80\80\80\80\80\40" ;; offset 2 with some unused bits set
"\0b" ;; end
)
"integer too large"
;; TODO: This changes to "integer too large" with memory64.
"integer representation too long"
)

;; Signed LEB128s sign-extend
Expand Down Expand Up @@ -963,7 +966,6 @@
"integer too large"
)


(module binary
"\00asm" "\01\00\00\00"
"\01\04\01" ;; type section
Expand Down Expand Up @@ -1000,3 +1002,81 @@
)
"integer representation too long"
)

;; Data segment tags and memory index can have non-minimal length
(module binary
"\00asm" "\01\00\00\00"
"\05\03\01" ;; Memory section with 1 entry
"\00\00" ;; no max, minimum 0
"\0b\07\01" ;; Data section with 1 entry
"\80\00" ;; Active segment, encoded with 2 bytes
"\41\00\0b\00" ;; (i32.const 0) with contents ""
)
(module binary
"\00asm" "\01\00\00\00"
"\05\03\01" ;; Memory section with 1 entry
"\00\00" ;; no max, minimum 0
"\0b\08\01" ;; Data section with 1 entry
"\82\00" ;; Active segment, encoded with 2 bytes
"\00" ;; explicit memory index
"\41\00\0b\00" ;; (i32.const 0) with contents ""
)
(module binary
"\00asm" "\01\00\00\00"
"\05\03\01" ;; Memory section with 1 entry
"\00\00" ;; no max, minimum 0
"\0b\09\01" ;; Data section with 1 entry
"\82\00" ;; Active segment, encoded with 2 bytes
"\80\00" ;; explicit memory index, encoded with 2 bytes
"\41\00\0b\00" ;; (i32.const 0) with contents ""
)

;; Element segment tags and table index can have non-minimal length
(module binary
"\00asm" "\01\00\00\00"
"\04\04\01" ;; Table section with 1 entry
"\70\00\00" ;; no max, minimum 0, funcref
"\09\07\01" ;; Element section with 1 entry
"\80\00" ;; Active segment
"\41\00\0b\00" ;; (i32.const 0) with no elements
)
(module binary
"\00asm" "\01\00\00\00"
"\04\04\01" ;; Table section with 1 entry
"\70\00\00" ;; no max, minimum 0, funcref
"\09\09\01" ;; Element section with 1 entry
"\02" ;; Active segment
"\80\00" ;; explicit table index, encoded with 2 bytes
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
)
(module binary
"\00asm" "\01\00\00\00"
"\04\04\01" ;; Table section with 1 entry
"\70\00\00" ;; no max, minimum 0, funcref
"\09\09\01" ;; Element section with 1 entry
"\82\00" ;; Active segment, encoded with 2 bytes
"\00" ;; explicit table index
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
)
(module binary
"\00asm" "\01\00\00\00"
"\04\04\01" ;; Table section with 1 entry
"\70\00\00" ;; no max, minimum 0, funcref
"\09\0a\01" ;; Element section with 1 entry
"\82\00" ;; Active segment, encoded with 2 bytes
"\80\00" ;; explicit table index, encoded with 2 bytes
"\41\00\0b\00\00" ;; (i32.const 0) with no elements
)

;; Type section with signed LEB128 encoded type
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01" ;; Type section id
"\05" ;; Type section length
"\01" ;; Types vector length
"\e0\7f" ;; Malformed functype, -0x20 in signed LEB128 encoding
"\00\00"
)
"integer representation too long"
)
Loading

0 comments on commit 96989a5

Please sign in to comment.