Skip to content

Commit 8ea273d

Browse files
authored
[test] Add negative tests for multiple sections (#1773)
1 parent 351d8b1 commit 8ea273d

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

test/core/binary.wast

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,3 +1144,117 @@
11441144
)
11451145
"unexpected content after last section"
11461146
)
1147+
1148+
;; Multiple function sections
1149+
(assert_malformed
1150+
(module binary
1151+
"\00asm" "\01\00\00\00"
1152+
"\01\04\01\60\00\00" ;; Type section
1153+
"\03\02\01\00" ;; Function section with 1 function
1154+
"\03\02\01\00" ;; Function section with 1 function
1155+
"\0a\07\02\02\00\0b\02\00\0b" ;; Code section with 2 empty functions
1156+
)
1157+
"unexpected content after last section"
1158+
)
1159+
1160+
;; Multiple code sections
1161+
(assert_malformed
1162+
(module binary
1163+
"\00asm" "\01\00\00\00"
1164+
"\01\04\01\60\00\00" ;; Type section
1165+
"\03\03\02\00\00" ;; Function section with 2 functions
1166+
"\0a\04\01\02\00\0b" ;; Code section with 1 empty function
1167+
"\0a\04\01\02\00\0b" ;; Code section with 1 empty function
1168+
)
1169+
"unexpected content after last section"
1170+
)
1171+
1172+
;; Multiple data count sections
1173+
(assert_malformed
1174+
(module binary
1175+
"\00asm" "\01\00\00\00"
1176+
"\0c\01\01" ;; Datacount section with value "1"
1177+
"\0c\01\01" ;; Datacount section with value "1"
1178+
)
1179+
"unexpected content after last section"
1180+
)
1181+
1182+
;; Multiple data sections
1183+
(assert_malformed
1184+
(module binary
1185+
"\00asm" "\01\00\00\00"
1186+
"\0b\01\00" ;; Data section with zero entries
1187+
"\0b\01\00" ;; Data section with zero entries
1188+
)
1189+
"unexpected content after last section"
1190+
)
1191+
1192+
;; Multiple global sections
1193+
(assert_malformed
1194+
(module binary
1195+
"\00asm" "\01\00\00\00"
1196+
"\06\01\00" ;; Global section with zero entries
1197+
"\06\01\00" ;; Global section with zero entries
1198+
)
1199+
"unexpected content after last section"
1200+
)
1201+
1202+
;; Multiple export sections
1203+
(assert_malformed
1204+
(module binary
1205+
"\00asm" "\01\00\00\00"
1206+
"\07\01\00" ;; Export section with zero entries
1207+
"\07\01\00" ;; Export section with zero entries
1208+
)
1209+
"unexpected content after last section"
1210+
)
1211+
1212+
;; Multiple table sections
1213+
(assert_malformed
1214+
(module binary
1215+
"\00asm" "\01\00\00\00"
1216+
"\04\01\00" ;; Table section with zero entries
1217+
"\04\01\00" ;; Table section with zero entries
1218+
)
1219+
"unexpected content after last section"
1220+
)
1221+
1222+
;; Multiple element sections
1223+
(assert_malformed
1224+
(module binary
1225+
"\00asm" "\01\00\00\00"
1226+
"\09\01\00" ;; Element section with zero entries
1227+
"\09\01\00" ;; Element section with zero entries
1228+
)
1229+
"unexpected content after last section"
1230+
)
1231+
1232+
;; Multiple import sections
1233+
(assert_malformed
1234+
(module binary
1235+
"\00asm" "\01\00\00\00"
1236+
"\02\01\00" ;; Import section with zero entries
1237+
"\02\01\00" ;; Import section with zero entries
1238+
)
1239+
"unexpected content after last section"
1240+
)
1241+
1242+
;; Multiple type sections
1243+
(assert_malformed
1244+
(module binary
1245+
"\00asm" "\01\00\00\00"
1246+
"\01\01\00" ;; Type section with zero entries
1247+
"\01\01\00" ;; Type section with zero entries
1248+
)
1249+
"unexpected content after last section"
1250+
)
1251+
1252+
;; Multiple memory sections
1253+
(assert_malformed
1254+
(module binary
1255+
"\00asm" "\01\00\00\00"
1256+
"\05\01\00" ;; Memory section with zero entries
1257+
"\05\01\00" ;; Memory section with zero entries
1258+
)
1259+
"unexpected content after last section"
1260+
)

0 commit comments

Comments
 (0)