Skip to content

Commit bbe955d

Browse files
authored
[test] Add negative test for invalid section ordering (#1775)
1 parent 8eb2dae commit bbe955d

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

test/core/binary.wast

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,3 +1258,116 @@
12581258
)
12591259
"unexpected content after last section"
12601260
)
1261+
1262+
;; Type section out of order
1263+
(assert_malformed
1264+
(module binary
1265+
"\00asm" "\01\00\00\00"
1266+
"\02\01\00" ;; Import section with zero entries
1267+
"\01\01\00" ;; Type section with zero entries
1268+
)
1269+
"unexpected content after last section"
1270+
)
1271+
1272+
;; Import section out of order
1273+
(assert_malformed
1274+
(module binary
1275+
"\00asm" "\01\00\00\00"
1276+
"\03\01\00" ;; Function section with zero entries
1277+
"\02\01\00" ;; Import section with zero entries
1278+
)
1279+
"unexpected content after last section"
1280+
)
1281+
1282+
;; Function section out of order
1283+
(assert_malformed
1284+
(module binary
1285+
"\00asm" "\01\00\00\00"
1286+
"\04\01\00" ;; Table section with zero entries
1287+
"\03\01\00" ;; Function section with zero entries
1288+
)
1289+
"unexpected content after last section"
1290+
)
1291+
1292+
;; Table section out of order
1293+
(assert_malformed
1294+
(module binary
1295+
"\00asm" "\01\00\00\00"
1296+
"\05\01\00" ;; Memory section with zero entries
1297+
"\04\01\00" ;; Table section with zero entries
1298+
)
1299+
"unexpected content after last section"
1300+
)
1301+
1302+
;; Memory section out of order
1303+
(assert_malformed
1304+
(module binary
1305+
"\00asm" "\01\00\00\00"
1306+
"\06\01\00" ;; Global section with zero entries
1307+
"\05\01\00" ;; Memory section with zero entries
1308+
)
1309+
"unexpected content after last section"
1310+
)
1311+
1312+
;; Global section out of order
1313+
(assert_malformed
1314+
(module binary
1315+
"\00asm" "\01\00\00\00"
1316+
"\07\01\00" ;; Export section with zero entries
1317+
"\06\01\00" ;; Global section with zero entries
1318+
)
1319+
"unexpected content after last section"
1320+
)
1321+
1322+
;; Export section out of order
1323+
(assert_malformed
1324+
(module binary
1325+
"\00asm" "\01\00\00\00"
1326+
"\03\02\01\00" ;; Function section
1327+
"\08\01\00" ;; Start section: function 0
1328+
"\07\01\00" ;; Export section with zero entries
1329+
)
1330+
"unexpected content after last section"
1331+
)
1332+
1333+
;; Start section out of order
1334+
(assert_malformed
1335+
(module binary
1336+
"\00asm" "\01\00\00\00"
1337+
"\03\02\01\00" ;; Function section
1338+
"\09\01\00" ;; Element section with zero entries
1339+
"\08\01\00" ;; Start section: function 0
1340+
)
1341+
"unexpected content after last section"
1342+
)
1343+
1344+
;; Element section out of order
1345+
(assert_malformed
1346+
(module binary
1347+
"\00asm" "\01\00\00\00"
1348+
"\0c\01\01" ;; Datacount section with value "1"
1349+
"\09\01\00" ;; Element section with zero entries
1350+
)
1351+
"unexpected content after last section"
1352+
)
1353+
1354+
;; Datacount section out of order
1355+
(assert_malformed
1356+
(module binary
1357+
"\00asm" "\01\00\00\00"
1358+
"\0a\01\00" ;; Code section with zero entries
1359+
"\0c\01\01" ;; Datacount section with value "1"
1360+
)
1361+
"unexpected content after last section"
1362+
)
1363+
1364+
;; Code section out of order
1365+
(assert_malformed
1366+
(module binary
1367+
"\00asm" "\01\00\00\00"
1368+
"\0b\01\00" ;; Data section with zero entries
1369+
"\0a\01\00" ;; Code section with zero entries
1370+
)
1371+
"unexpected content after last section"
1372+
)
1373+

0 commit comments

Comments
 (0)