Skip to content

Commit 47d862c

Browse files
authored
cccccc[klghketetivvtnnhvntikigrnueuhdkkukljgjuest/meta/generate_*.js: sync upstream JS with tests (#1546)
1 parent 58cd4c3 commit 47d862c

File tree

5 files changed

+41
-43
lines changed

5 files changed

+41
-43
lines changed

test/meta/generate_memory_copy.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function mem_copy(min, max, shared, srcOffs, targetOffs, len) {
103103
(i32.load8_u (local.get 0))))
104104
105105
(assert_trap (invoke "run" (i32.const ${targetOffs}) (i32.const ${srcOffs}) (i32.const ${len}))
106-
"out of bounds")
106+
"out of bounds memory access")
107107
`);
108108

109109
let immediateOOB = copyDown && (srcOffs + len > memLength || targetOffs + len > memLength);
@@ -227,7 +227,7 @@ print(
227227
(memory 1 1)
228228
(func (export "test")
229229
(memory.copy (i32.const 0xFF00) (i32.const 0x8000) (i32.const 257))))
230-
(assert_trap (invoke "test") "out of bounds")
230+
(assert_trap (invoke "test") "out of bounds memory access")
231231
`);
232232

233233
// Destination wraparound the end of 32-bit offset space
@@ -236,7 +236,7 @@ print(
236236
(memory 1 1)
237237
(func (export "test")
238238
(memory.copy (i32.const 0xFFFFFF00) (i32.const 0x4000) (i32.const 257))))
239-
(assert_trap (invoke "test") "out of bounds")
239+
(assert_trap (invoke "test") "out of bounds memory access")
240240
`);
241241

242242
// Source range invalid
@@ -245,7 +245,7 @@ print(
245245
(memory 1 1)
246246
(func (export "test")
247247
(memory.copy (i32.const 0x8000) (i32.const 0xFF00) (i32.const 257))))
248-
(assert_trap (invoke "test") "out of bounds")
248+
(assert_trap (invoke "test") "out of bounds memory access")
249249
`);
250250

251251
// Source wraparound the end of 32-bit offset space
@@ -254,7 +254,7 @@ print(
254254
(memory 1 1)
255255
(func (export "test")
256256
(memory.copy (i32.const 0x4000) (i32.const 0xFFFFFF00) (i32.const 257))))
257-
(assert_trap (invoke "test") "out of bounds")
257+
(assert_trap (invoke "test") "out of bounds memory access")
258258
`);
259259

260260
// Zero len with both offsets in-bounds is a no-op
@@ -286,7 +286,7 @@ print(
286286
(memory 1 1)
287287
(func (export "test")
288288
(memory.copy (i32.const 0x20000) (i32.const 0x7000) (i32.const 0))))
289-
(assert_trap (invoke "test") "out of bounds")
289+
(assert_trap (invoke "test") "out of bounds memory access")
290290
`);
291291

292292
// Zero len with src offset out-of-bounds at the end of memory is allowed
@@ -304,7 +304,7 @@ print(
304304
(memory 1 1)
305305
(func (export "test")
306306
(memory.copy (i32.const 0x9000) (i32.const 0x20000) (i32.const 0))))
307-
(assert_trap (invoke "test") "out of bounds")
307+
(assert_trap (invoke "test") "out of bounds memory access")
308308
`);
309309

310310
// Zero len with both dest and src offsets out-of-bounds at the end of memory is allowed
@@ -322,7 +322,7 @@ print(
322322
(memory 1 1)
323323
(func (export "test")
324324
(memory.copy (i32.const 0x20000) (i32.const 0x20000) (i32.const 0))))
325-
(assert_trap (invoke "test") "out of bounds")
325+
(assert_trap (invoke "test") "out of bounds memory access")
326326
`);
327327

328328
// 100 random fills followed by 100 random copies, in a single-page buffer,

test/meta/generate_memory_fill.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ print(
6262
${PREAMBLE}
6363
(func (export "test")
6464
(memory.fill (i32.const 0x20000) (i32.const 0x55) (i32.const 0))))
65-
(assert_trap (invoke "test") "out of bounds")
65+
(assert_trap (invoke "test") "out of bounds memory access")
6666
`);
6767

6868
// Very large range
@@ -141,7 +141,7 @@ function mem_fill(min, max, shared, backup, write=backup*2) {
141141
let val = 37;
142142
print(
143143
`(assert_trap (invoke "run" (i32.const ${offs}) (i32.const ${val}) (i32.const ${write}))
144-
"out of bounds")
144+
"out of bounds memory access")
145145
`);
146146
checkRange(0, min, 0);
147147
}

test/meta/generate_memory_init.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ print(
6565
(module
6666
(func (export "test")
6767
(data.drop 0)))
68-
"unknown memory 0")
68+
"unknown data segment")
6969
`);
7070

7171
// drop with data seg ix out of range
@@ -95,7 +95,7 @@ print(
9595
(func (export "test")
9696
(data.drop 0)
9797
(memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1))))
98-
(assert_trap (invoke "test") "out of bounds")
98+
(assert_trap (invoke "test") "out of bounds memory access")
9999
`);
100100

101101
// init with data seg ix indicating an active segment
@@ -105,7 +105,7 @@ print(
105105
(data (i32.const 0) "\\37")
106106
(func (export "test")
107107
(memory.init 0 (i32.const 1234) (i32.const 1) (i32.const 1))))
108-
(assert_trap (invoke "test") "out of bounds")
108+
(assert_trap (invoke "test") "out of bounds memory access")
109109
`);
110110

111111
// init with no memory
@@ -143,7 +143,7 @@ print(
143143
${PREAMBLE}
144144
(func (export "test")
145145
(memory.init 0 (i32.const 1234) (i32.const 0) (i32.const 5))))
146-
(assert_trap (invoke "test") "out of bounds")
146+
(assert_trap (invoke "test") "out of bounds memory access")
147147
`);
148148

149149
// init: seg ix is valid passive, but implies copying beyond end of seg
@@ -152,7 +152,7 @@ print(
152152
${PREAMBLE}
153153
(func (export "test")
154154
(memory.init 0 (i32.const 1234) (i32.const 2) (i32.const 3))))
155-
(assert_trap (invoke "test") "out of bounds")
155+
(assert_trap (invoke "test") "out of bounds memory access")
156156
`);
157157

158158
// init: seg ix is valid passive, but implies copying beyond end of dst
@@ -161,7 +161,7 @@ print(
161161
${PREAMBLE}
162162
(func (export "test")
163163
(memory.init 0 (i32.const 0xFFFE) (i32.const 1) (i32.const 3))))
164-
(assert_trap (invoke "test") "out of bounds")
164+
(assert_trap (invoke "test") "out of bounds memory access")
165165
`);
166166

167167
// init: seg ix is valid passive, src offset past the end, zero len is invalid
@@ -170,7 +170,7 @@ print(
170170
${PREAMBLE}
171171
(func (export "test")
172172
(memory.init 0 (i32.const 1234) (i32.const 4) (i32.const 0))))
173-
(assert_trap (invoke "test") "out of bounds")
173+
(assert_trap (invoke "test") "out of bounds memory access")
174174
`);
175175

176176
// init: seg ix is valid passive, zero len, src offset at the end
@@ -188,7 +188,7 @@ print(
188188
${PREAMBLE}
189189
(func (export "test")
190190
(memory.init 0 (i32.const 0x10001) (i32.const 0) (i32.const 0))))
191-
(assert_trap (invoke "test") "out of bounds")
191+
(assert_trap (invoke "test") "out of bounds memory access")
192192
`);
193193

194194
// init: seg ix is valid passive, zero len, but dst offset at the end
@@ -216,7 +216,7 @@ print(
216216
${PREAMBLE}
217217
(func (export "test")
218218
(memory.init 0 (i32.const 0x10001) (i32.const 4) (i32.const 0))))
219-
(assert_trap (invoke "test") "out of bounds")
219+
(assert_trap (invoke "test") "out of bounds memory access")
220220
`);
221221

222222
// invalid argument types. TODO: can add anyfunc etc here.
@@ -265,7 +265,7 @@ function mem_init(min, max, shared, backup, write) {
265265
let offs = min*PAGESIZE - backup;
266266
print(
267267
`(assert_trap (invoke "run" (i32.const ${offs}) (i32.const ${write}))
268-
"out of bounds")
268+
"out of bounds memory access")
269269
`);
270270
checkRange(0, min, 0);
271271
}
@@ -309,5 +309,4 @@ print(
309309
(data "") (data "") (data "") (data "") (data "") (data "") (data "") (data "")
310310
(data "") (data "") (data "") (data "") (data "") (data "") (data "") (data "")
311311
(data "")
312-
(func (memory.init 64 (i32.const 0) (i32.const 0) (i32.const 0))))
313-
`)
312+
(func (memory.init 64 (i32.const 0) (i32.const 0) (i32.const 0))))`)

test/meta/generate_table_copy.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,22 @@ for ( let dest of ["$t0","$t1"] ) {
203203
// copy: dst range invalid
204204
tab_test2(`(table.copy ${dest} $t0 (i32.const 28) (i32.const 1) (i32.const 3))`,
205205
"",
206-
"out of bounds");
206+
"out of bounds table access");
207207

208208
// copy: dst wraparound end of 32 bit offset space
209209
tab_test2(`(table.copy ${dest} $t0 (i32.const 0xFFFFFFFE) (i32.const 1) (i32.const 2))`,
210210
"",
211-
"out of bounds");
211+
"out of bounds table access");
212212

213213
// copy: src range invalid
214214
tab_test2(`(table.copy ${dest} $t0 (i32.const 15) (i32.const 25) (i32.const 6))`,
215215
"",
216-
"out of bounds");
216+
"out of bounds table access");
217217

218218
// copy: src wraparound end of 32 bit offset space
219219
tab_test2(`(table.copy ${dest} $t0 (i32.const 15) (i32.const 0xFFFFFFFE) (i32.const 2))`,
220220
"",
221-
"out of bounds");
221+
"out of bounds table access");
222222

223223
// copy: zero length with both offsets in-bounds is OK
224224
tab_test_nofail(
@@ -233,7 +233,7 @@ for ( let dest of ["$t0","$t1"] ) {
233233
// copy: zero length with dst offset out of bounds past the end of the table is not allowed
234234
tab_test2(`(table.copy ${dest} $t0 (i32.const 31) (i32.const 15) (i32.const 0))`,
235235
"",
236-
"out of bounds");
236+
"out of bounds table access");
237237

238238
// copy: zero length with src offset out of bounds at the end of the table is allowed
239239
tab_test2(`(table.copy ${dest} $t0 (i32.const 15) (i32.const 30) (i32.const 0))`,
@@ -243,7 +243,7 @@ for ( let dest of ["$t0","$t1"] ) {
243243
// copy: zero length with src offset out of bounds past the end of the table is not allowed
244244
tab_test2(`(table.copy ${dest} $t0 (i32.const 15) (i32.const 31) (i32.const 0))`,
245245
"",
246-
"out of bounds");
246+
"out of bounds table access");
247247

248248
// copy: zero length with both dst and src offset out of bounds at the end of the table is allowed
249249
tab_test2(`(table.copy ${dest} $t0 (i32.const 30) (i32.const 30) (i32.const 0))`,
@@ -253,7 +253,7 @@ for ( let dest of ["$t0","$t1"] ) {
253253
// copy: zero length with both dst and src offset out of bounds past the end of the table is not allowed
254254
tab_test2(`(table.copy ${dest} $t0 (i32.const 31) (i32.const 31) (i32.const 0))`,
255255
"",
256-
"out of bounds");
256+
"out of bounds table access");
257257
}
258258

259259
// table.copy: out of bounds of the table for the source or target, but should
@@ -320,7 +320,7 @@ function tbl_copy(min, max, srcOffs, targetOffs, len) {
320320
let immediateOOB = copyDown && (srcOffs + len > tblLength || targetOffs + len > tblLength);
321321

322322
print(`(assert_trap (invoke "run" (i32.const ${targetOffs}) (i32.const ${srcOffs}) (i32.const ${len}))
323-
"out of bounds")`);
323+
"out of bounds table access")`);
324324

325325
var s = 0;
326326
var i = 0;

test/meta/generate_table_init.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ print(
113113
(module
114114
(func (export "test")
115115
(elem.drop 0)))
116-
"unknown table 0")
116+
"unknown elem segment 0")
117117
`);
118118

119119
// table.init requires a table, minimally
@@ -133,7 +133,7 @@ print(
133133
(func (result i32) (i32.const 0))
134134
(func (export "test")
135135
(elem.drop 4)))
136-
"unknown table 0")
136+
"unknown elem segment 4")
137137
`);
138138

139139
// init with elem seg ix out of range
@@ -197,7 +197,7 @@ tab_test1("(elem.drop 2)", 0,
197197

198198
// init with elem seg ix indicating an active segment
199199
tab_test1("(table.init 2 (i32.const 12) (i32.const 1) (i32.const 1))", 0,
200-
"out of bounds");
200+
"out of bounds table access");
201201

202202
// init, using an elem seg ix more than once is OK
203203
tab_test2(
@@ -213,15 +213,15 @@ tab_test2("(elem.drop 1)",
213213
// drop, then init
214214
tab_test2("(elem.drop 1)",
215215
"(table.init 1 (i32.const 12) (i32.const 1) (i32.const 1))",
216-
"out of bounds");
216+
"out of bounds table access");
217217

218218
// init: seg ix is valid passive, but length to copy > len of seg
219219
tab_test1("(table.init 1 (i32.const 12) (i32.const 0) (i32.const 5))", 0,
220-
"out of bounds");
220+
"out of bounds table access");
221221

222222
// init: seg ix is valid passive, but implies copying beyond end of seg
223223
tab_test1("(table.init 1 (i32.const 12) (i32.const 2) (i32.const 3))", 0,
224-
"out of bounds");
224+
"out of bounds table access");
225225

226226
// Tables are of different length with t1 shorter than t0, to test that we're not
227227
// using t0's limit for t1's bound
@@ -230,7 +230,7 @@ for ( let [table, oobval] of [[0,30],[1,28]] ) {
230230
// init: seg ix is valid passive, but implies copying beyond end of dst
231231
tab_test1(`(table.init $t${table} 1 (i32.const ${oobval-2}) (i32.const 1) (i32.const 3))`,
232232
table,
233-
"out of bounds");
233+
"out of bounds table access");
234234

235235
// init: seg ix is valid passive, zero len, and src offset out of bounds at the
236236
// end of the table - this is allowed
@@ -242,7 +242,7 @@ for ( let [table, oobval] of [[0,30],[1,28]] ) {
242242
// end of the table - this is not allowed
243243
tab_test1(`(table.init $t${table} 1 (i32.const 12) (i32.const 5) (i32.const 0))`,
244244
table,
245-
"out of bounds");
245+
"out of bounds table access");
246246

247247
// init: seg ix is valid passive, zero len, and dst offset out of bounds at the
248248
// end of the table - this is allowed
@@ -254,7 +254,7 @@ for ( let [table, oobval] of [[0,30],[1,28]] ) {
254254
// end of the table - this is not allowed
255255
tab_test1(`(table.init $t${table} 1 (i32.const ${oobval+1}) (i32.const 2) (i32.const 0))`,
256256
table,
257-
"out of bounds");
257+
"out of bounds table access");
258258

259259
// init: seg ix is valid passive, zero len, and dst and src offsets out of bounds
260260
// at the end of the table - this is allowed
@@ -266,7 +266,7 @@ for ( let [table, oobval] of [[0,30],[1,28]] ) {
266266
// end of the table - this is not allowed
267267
tab_test1(`(table.init $t${table} 1 (i32.const ${oobval+1}) (i32.const 5) (i32.const 0))`,
268268
table,
269-
"out of bounds");
269+
"out of bounds table access");
270270
}
271271

272272
// invalid argument types
@@ -338,7 +338,7 @@ function tbl_init(min, max, backup, write, segoffs=0) {
338338
// A fill reading past the end of the segment should throw *and* have filled
339339
// table with as much data as was available.
340340
let offs = min - backup;
341-
print(`(assert_trap (invoke "run" (i32.const ${offs}) (i32.const ${write})) "out of bounds")`);
341+
print(`(assert_trap (invoke "run" (i32.const ${offs}) (i32.const ${write})) "out of bounds table access")`);
342342
for (let i=0; i < min; i++) {
343343
print(`(assert_trap (invoke "test" (i32.const ${i})) "uninitialized element")`);
344344
}
@@ -383,5 +383,4 @@ print(
383383
(elem funcref) (elem funcref) (elem funcref) (elem funcref)
384384
(elem funcref) (elem funcref) (elem funcref) (elem funcref)
385385
(elem funcref)
386-
(func (table.init 64 (i32.const 0) (i32.const 0) (i32.const 0))))
387-
`)
386+
(func (table.init 64 (i32.const 0) (i32.const 0) (i32.const 0))))`)

0 commit comments

Comments
 (0)