v8/test/inspector/debugger/wasm-regress-10957.js
Benedikt Meurer 6f448efbef [inspector] Make wasm tests fail rather than time out.
Consistently use InspectorTest.runAsyncTestSuite() in wasm inspector
tests to make tests easier to debug (they'll fail instead of timing
out in case of errors).

Bug: chromium:1162229, chromium:1071432
Change-Id: I7aada196f9e34071aa1bb059bb45f85f75226060
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2609414
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71908}
2021-01-05 07:38:57 +00:00

70 lines
2.0 KiB
JavaScript

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --allow-natives-syntax
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
let {session, contextGroup, Protocol} = InspectorTest.start('Regress 10957');
var builder = new WasmModuleBuilder();
let pause = builder.addImport('imports', 'pause', kSig_v_v);
let sig = makeSig([kWasmI32, kWasmI32, kWasmI32, kWasmI32, kWasmI32, kWasmI32, kWasmI32], [kWasmI32]);
let f = builder.addFunction('f', sig)
.addBody([
kExprLocalGet, 0,
kExprLocalGet, 1,
kExprLocalGet, 2,
kExprLocalGet, 3,
kExprLocalGet, 4,
kExprLocalGet, 5,
kExprLocalGet, 6,
kExprI32Add,
kExprI32Add,
kExprI32Add,
kExprI32Add,
kExprI32Add,
kExprI32Add,
]);
builder.addFunction('main', kSig_i_v)
.addBody([
kExprCallFunction, pause,
kExprI32Const, 1,
kExprI32Const, 1,
kExprI32Const, 1,
kExprI32Const, 1,
kExprI32Const, 1,
kExprI32Const, 1,
kExprI32Const, 1,
kExprCallFunction, f.index])
.exportFunc();
var module_bytes = builder.toArray();
function instantiate(bytes, imports) {
var buffer = new ArrayBuffer(bytes.length);
var view = new Uint8Array(buffer);
for (var i = 0; i < bytes.length; ++i) {
view[i] = bytes[i] | 0;
}
const module = new WebAssembly.Module(buffer);
return new WebAssembly.Instance(module, imports);
}
InspectorTest.runAsyncTestSuite([
async function testRegress10957() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiate');
const code =
`let instance = (${instantiate})(${JSON.stringify(module_bytes)}, {'imports': {'pause': () => { %ScheduleBreak() } }});
instance.exports.main();
`;
Protocol.Runtime.evaluate({'expression': code}).then(message =>
InspectorTest.logMessage(message.result.result.value));
await Protocol.Debugger.oncePaused();
Protocol.Debugger.resume();
}
]);