Skip to content

Commit

Permalink
[test] Redundant data count section
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Sep 12, 2024
1 parent 4e722fb commit 7ff01f5
Showing 1 changed file with 48 additions and 42 deletions.
90 changes: 48 additions & 42 deletions test/core/binary.wast
Original file line number Diff line number Diff line change
Expand Up @@ -449,49 +449,47 @@
"\0a\01\00" ;; Code section with 0 functions
)

;; Fewer passive segments than datacount
;; Fewer passive segments than data count
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\0c\01\03" ;; Datacount section with value "3"
"\0b\05\02" ;; Data section with two entries
"\01\00" ;; Passive data section
"\01\00") ;; Passive data section
"data count and data section have inconsistent lengths")
"\0c\01\03" ;; Data count section with value 3
"\0b\05\02" ;; Data section with two entries
"\01\00" ;; Passive data section
"\01\00" ;; Passive data section
)
"data count and data section have inconsistent lengths"
)

;; More passive segments than datacount
;; More passive segments than data count
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\0c\01\01" ;; Datacount section with value "1"
"\0b\05\02" ;; Data section with two entries
"\01\00" ;; Passive data section
"\01\00") ;; Passive data section
"data count and data section have inconsistent lengths")
"\0c\01\01" ;; Data count section with value 1
"\0b\05\02" ;; Data section with two entries
"\01\00" ;; Passive data section
"\01\00" ;; Passive data section
)
"data count and data section have inconsistent lengths"
)

;; Data count section without data segment section
;; Non-zero data count section without data section
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\05\03\01\00\01" ;; Memory section: 1 memory
"\08\01\00" ;; Start section: function 0
"\0c\01\01" ;; Data Count section: 1 segment
"\0a\0e\01" ;; Code section: 1 function

;; function 0
"\0c\00"
"\41\00" ;; i32.const 0
"\41\00" ;; i32.const 0
"\41\00" ;; i32.const 0
"\fc\08\00\00" ;; memory.init dataidx=0 memidx=0
"\0b" ;; end
"\05\03\01\00\01" ;; Memory section with one entry
"\0c\01\01" ;; Data count section with value 1
)
"data count and data section have inconsistent lengths"
)

;; memory.init requires a datacount section
;; Zero data count section without data section
(module binary
"\00asm" "\01\00\00\00"
"\0c\01\00" ;; Data count section with value 0
)

;; memory.init requires a data count section
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
Expand All @@ -511,9 +509,10 @@

"\0b\03\01\01\00" ;; Data section
) ;; end
"data count section required")
"data count section required"
)

;; data.drop requires a datacount section
;; data.drop requires a data count section
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
Expand All @@ -530,7 +529,8 @@

"\0b\03\01\01\00" ;; Data section
) ;; end
"data count section required")
"data count section required"
)

;; passive element segment containing illegal opcode
(assert_malformed
Expand All @@ -555,8 +555,10 @@

;; function 0
"\02\00"
"\0b") ;; end
"illegal opcode")
"\0b" ;; end
)
"illegal opcode"
)

;; passive element segment containing type other than funcref
(assert_malformed
Expand All @@ -581,8 +583,10 @@

;; function 0
"\02\00"
"\0b") ;; end
"malformed reference type")
"\0b" ;; end
)
"malformed reference type"
)

;; passive element segment containing opcode ref.func
(module binary
Expand All @@ -606,7 +610,8 @@

;; function 0
"\02\00"
"\0b") ;; end
"\0b" ;; end
)

;; passive element segment containing opcode ref.null
(module binary
Expand All @@ -630,7 +635,8 @@

;; function 0
"\02\00"
"\0b") ;; end
"\0b" ;; end
)


;; Type count can be zero
Expand Down Expand Up @@ -1195,8 +1201,8 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\0c\01\01" ;; Datacount section with value "1"
"\0c\01\01" ;; Datacount section with value "1"
"\0c\01\01" ;; Data count section with value "1"
"\0c\01\01" ;; Data count section with value "1"
)
"unexpected content after last section"
)
Expand Down Expand Up @@ -1367,18 +1373,18 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\0c\01\01" ;; Datacount section with value "1"
"\0c\01\01" ;; Data count section with value "1"
"\09\01\00" ;; Element section with zero entries
)
"unexpected content after last section"
)

;; Datacount section out of order
;; Data count section out of order
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\0a\01\00" ;; Code section with zero entries
"\0c\01\01" ;; Datacount section with value "1"
"\0c\01\01" ;; Data count section with value "1"
)
"unexpected content after last section"
)
Expand Down

0 comments on commit 7ff01f5

Please sign in to comment.