Commit 6f448efb authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[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: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71908}
parent afd3f63e
Test that breakpoints do not survive a restart of the debugger.
Running test: test
Instantiating.
Waiting for wasm script (ignoring first non-wasm script).
Setting breakpoint.
......@@ -8,4 +10,3 @@ func returned.
Restarting debugger.
Calling func.
func returned.
Finished.
......@@ -9,10 +9,8 @@ const {session, contextGroup, Protocol} = InspectorTest.start(
session.setupScriptMap();
const builder = new WasmModuleBuilder();
const func =
builder.addFunction('func', kSig_v_v).addBody([kExprNop]).exportFunc();
const module_bytes = builder.toArray();
Protocol.Debugger.onPaused(async msg => {
......@@ -20,7 +18,8 @@ Protocol.Debugger.onPaused(async msg => {
Protocol.Debugger.resume();
});
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
// Spawn asynchronously:
......@@ -45,6 +44,5 @@ Protocol.Debugger.onPaused(async msg => {
await Protocol.Debugger.disable();
await Protocol.Debugger.enable();
}
InspectorTest.log('Finished.');
InspectorTest.completeTest();
})();
}
]);
Tests debug command for wasm
Running test: test
Waiting for wasm scripts to be parsed.
Ignoring script with url v8://test/instantiate
Got wasm script: wasm://wasm/7d022e0e
......@@ -6,4 +8,3 @@ paused No 1
Script wasm://wasm/7d022e0e byte offset 35: Wasm opcode 0x20 (kExprLocalGet)
Debugger.resume
exports.main returned!
Finished!
......@@ -43,7 +43,8 @@ function test() {
}
//# sourceURL=test.js`);
(async function Test() {
InspectorTest.runAsyncTestSuite([
async function test() {
breakCount = 0;
breakpointId = 0;
await Protocol.Debugger.enable();
......@@ -51,9 +52,8 @@ function test() {
await waitForWasmScript();
await Protocol.Runtime.evaluate({ expression: 'test()', includeCommandLineAPI: true});
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
function printFailure(message) {
if (!message.result) {
......
......@@ -9,8 +9,8 @@ utils.load('test/inspector/wasm-inspector-test.js');
let {session, contextGroup, Protocol} =
InspectorTest.start('Test wasm scope information with externref globals');
(async function() {
try {
InspectorTest.runAsyncTestSuite([
async function test() {
let builder = new WasmModuleBuilder();
builder.addImportedGlobal('m', 'global', kWasmExternRef, false);
let func = builder.addFunction('func', kSig_v_v)
......@@ -74,11 +74,5 @@ let {session, contextGroup, Protocol} =
InspectorTest.log(` ${prop.name}: {${values}}`);
}
}
InspectorTest.log('Finished.');
} catch (exc) {
InspectorTest.log(`Failed with exception: ${exc}.`);
} finally {
InspectorTest.completeTest();
}
})();
]);
Tests breakable locations in wasm
Running test: test
Running testFunction...
Script nr 0 parsed. URL: v8://test/instantiate
Script nr 1 parsed. URL: wasm://wasm/354ada0e
......@@ -73,4 +75,3 @@ Stopped at wasm://wasm/354ada0e:0:57
Missing breakpoints: 1
Stopped at wasm://wasm/354ada0e:0:58
Missing breakpoints: 0
Finished!
......@@ -35,7 +35,8 @@ var module_bytes = builder.toArray();
Protocol.Debugger.enable();
Protocol.Debugger.onScriptParsed(handleScriptParsed);
async function runTest() {
InspectorTest.runAsyncTestSuite([
async function test() {
InspectorTest.log('Running testFunction...');
await WasmInspectorTest.instantiate(module_bytes);
await getBreakableLocationsForAllWasmScripts();
......@@ -46,12 +47,8 @@ async function runTest() {
await waitForAllPauses();
// Code should now complete
await promise;
InspectorTest.log('Finished!');
}
runTest()
.catch(reason => InspectorTest.log(`Failed: ${reason}`))
.then(InspectorTest.completeTest);
}
]);
var allBreakableLocations = [];
......
Test wasm global names
Running test: test
Waiting for wasm script to be parsed.
Setting breakpoint in wasm.
Running main.
Paused in debugger.
globals: {"module_name.imported_global", "exported_global", "global2"}
Finished.
......@@ -17,23 +17,13 @@ let func = builder.addFunction('func', kSig_v_i)
.exportAs('main');
var o = builder.addGlobal(kWasmI32, func).exportAs('exported_global');
builder.addGlobal(kWasmI32); // global2
let moduleBytes = JSON.stringify(builder.toArray());
let moduleBytes = builder.toArray();
function test(moduleBytes) {
let module = new WebAssembly.Module((new Uint8Array(moduleBytes)).buffer);
let imported_global_value = 123;
instance = new WebAssembly.Instance(
module, {module_name: {imported_global: imported_global_value}});
}
(async function() {
try {
InspectorTest.runAsyncTestSuite([
async function test() {
Protocol.Debugger.enable();
Protocol.Runtime.evaluate({
expression: `
let instance;
${test.toString()}
test(${moduleBytes});`
expression: `var instance = (${WasmInspectorTest.instantiateFromBuffer})(${JSON.stringify(moduleBytes)}, {module_name: {imported_global: 123}});`
});
InspectorTest.log('Waiting for wasm script to be parsed.');
......@@ -72,11 +62,5 @@ function test(moduleBytes) {
InspectorTest.log(` ${prop.name}: {${values}}`);
}
}
InspectorTest.log('Finished.');
} catch (exc) {
InspectorTest.log(`Failed with exception: ${exc}.`);
} finally {
InspectorTest.completeTest();
}
})();
]);
Test inspecting register values in Liftoff.
Running test: test
Testing i32.
Waiting for wasm script.
Setting 20 breakpoints.
......@@ -99,4 +101,3 @@ Paused at offset 75; wasm-expression-stack: [0, 1, 44]; local: [0, 1, 2, 3, 4, 5
Paused at offset 76; wasm-expression-stack: [0, 45]; local: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Paused at offset 77; wasm-expression-stack: [45]; local: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
main returned.
Finished!
......@@ -88,11 +88,11 @@ async function testConfig(config) {
InspectorTest.log('main returned.');
}
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
for (let config in configs) {
await testConfig(config);
}
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
Test wasm memory names
Running test: test
Waiting for wasm script to be parsed.
Setting breakpoint in wasm.
Running main.
......
......@@ -102,17 +102,11 @@ contextGroup.addScript(`
let instance;
${createInstance.toString()}`);
(async function test() {
try {
InspectorTest.runAsyncTestSuite([
async function test() {
Protocol.Debugger.enable();
await check(createModuleBytesUnnamedMemory());
await check(createModuleBytesExportedMemory());
await check(createModuleBytesImportedMemory());
} catch (exc) {
InspectorTest.log(`Failed with exception: ${exc}.`);
} finally {
InspectorTest.completeTest();
}
})();
]);
Regress 10957
Running test: testRegress10957
Instantiate
Finished!
7
......@@ -53,7 +53,8 @@ function instantiate(bytes, imports) {
return new WebAssembly.Instance(module, imports);
}
(async function Regress10957() {
InspectorTest.runAsyncTestSuite([
async function testRegress10957() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiate');
const code =
......@@ -64,7 +65,5 @@ function instantiate(bytes, imports) {
InspectorTest.logMessage(message.result.result.value));
await Protocol.Debugger.oncePaused();
Protocol.Debugger.resume();
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
Tests remove breakpoint from wasm scripts.
Running test: Test
Calling instantiate function.
Waiting for wasm scripts to be parsed.
Ignoring script with url v8://test/instantiate
......@@ -14,4 +16,3 @@ Script wasm://wasm/7d022e0e byte offset 39: Wasm opcode 0x6b (kExprI32Sub)
Remove breakpoint
Debugger.resume
exports.main returned!
Finished!
......@@ -46,7 +46,8 @@ function test() {
}
//# sourceURL=test.js`);
(async function Test() {
InspectorTest.runAsyncTestSuite([
async function Test() {
await Protocol.Debugger.enable();
InspectorTest.log('Calling instantiate function.');
WasmInspectorTest.instantiate(module_bytes);
......@@ -61,9 +62,8 @@ function test() {
await Protocol.Runtime.evaluate({ expression: 'test()' });
await Protocol.Runtime.evaluate({ expression: 'test()' });
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
function printFailure(message) {
if (!message.result) {
......
Checks resetting context group with wasm.
Running test: test
{
id : <messageId>
result : {
......
......@@ -30,7 +30,8 @@ let contextGroup2 = new InspectorTest.ContextGroup();
let session2 = contextGroup2.connect();
session2.setupScriptMap();
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await session1.Protocol.Debugger.enable();
await session2.Protocol.Debugger.enable();
......@@ -45,6 +46,5 @@ session2.setupScriptMap();
await session1.Protocol.Debugger.onceScriptParsed(2);
InspectorTest.logMessage(await session1.Protocol.Runtime.evaluate({expression: 'instance.exports.main(4)'}));
InspectorTest.logMessage(await session2.Protocol.Runtime.evaluate({expression: 'instance.exports.main(5)'}));
InspectorTest.completeTest();
})();
}
]);
Test retrieving scope information when pausing in wasm functions
Running test: test
Calling instantiate function.
Waiting for wasm script to be parsed.
Got wasm script!
......
Test retrieving scope information from compiled Liftoff frames
Running test: test
Calling instantiate function.
Waiting for wasm script to be parsed.
Got wasm script!
......
......@@ -16,7 +16,8 @@ Protocol.Debugger.onPaused(printPauseLocationsAndContinue);
let breakpointLocation = -1;
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
// Instantiate wasm and wait for three wasm scripts for the three functions.
instantiateWasm();
let scriptIds = await waitForWasmScripts();
......@@ -32,8 +33,8 @@ let breakpointLocation = -1;
// Now run the wasm code.
await WasmInspectorTest.evalWithUrl('instance.exports.main(42)', 'runWasm');
InspectorTest.log('exports.main returned. Test finished.');
InspectorTest.completeTest();
})();
}
]);
async function printPauseLocationsAndContinue(msg) {
let loc = msg.params.callFrames[0].location;
......
......@@ -16,7 +16,8 @@ Protocol.Debugger.onPaused(printPauseLocationsAndContinue);
let breakpointLocation = undefined; // Will be set by {instantiateWasm}.
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
// Instantiate wasm and wait for three wasm scripts for the three functions.
instantiateWasm();
let scriptIds = await waitForWasmScripts();
......@@ -37,8 +38,8 @@ let breakpointLocation = undefined; // Will be set by {instantiateWasm}.
// Now run the wasm code.
await WasmInspectorTest.evalWithUrl('instance.exports.main(4)', 'runWasm');
InspectorTest.log('exports.main returned. Test finished.');
InspectorTest.completeTest();
})();
}
]);
async function printPauseLocationsAndContinue(msg) {
let loc = msg.params.callFrames[0].location;
......
Tests reported code offsets on wasm scripts
Running test: test
Wasm script parsed: ID 0, startColumn: 0, endColumn: 29, codeOffset: 0
Wasm script parsed: ID 1, startColumn: 0, endColumn: 29, codeOffset: 0
Wasm script parsed: ID 2, startColumn: 0, endColumn: 32, codeOffset: 31
......
Tests reported code offsets on wasm scripts
Running test: test
Wasm script parsed: ID 0, startColumn: 0, endColumn: 29, codeOffset: 0
Wasm script parsed: ID 1, startColumn: 0, endColumn: 29, codeOffset: 0
Wasm script parsed: ID 2, startColumn: 0, endColumn: 32, codeOffset: 31
......
......@@ -109,7 +109,8 @@ function compileAsync(bytes) {
contextGroup.addScript(
`${compileSync}${compileAsync}`, 0, 0, 'v8://test/compileFunctions');
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
Protocol.Debugger.enable();
let script_ids = new Map();
let generators = [
......@@ -140,6 +141,5 @@ contextGroup.addScript(
++wasm_scripts;
}
}
InspectorTest.completeTest();
})();
}
]);
......@@ -107,7 +107,8 @@ function compileAsync(bytes) {
contextGroup.addScript(
`${compileSync}${compileAsync}`, 0, 0, 'v8://test/compileFunctions');
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
Protocol.Debugger.enable();
let script_ids = new Map();
let generators = [
......@@ -138,6 +139,5 @@ contextGroup.addScript(
++wasm_scripts;
}
}
InspectorTest.completeTest();
})();
}
]);
Tests if breakpoint set is first breakable location
Running test: test
Running test function...
Set breakpoint outside of any function: (0, 0).
Setting breakpoint for id: 4 at 0, 0.
......@@ -18,4 +20,3 @@ Set breakpoint at non-breakable location: (0, 42).
Setting breakpoint for id: 4 at 0, 42.
Location match for (0, 43).
Initial location is expected to be breakable: false.
Finished!
\ No newline at end of file
......@@ -32,17 +32,14 @@ builder.addFunction('main', kSig_v_i)
var module_bytes = builder.toArray();
Protocol.Debugger.enable();
runTest()
.catch(reason => InspectorTest.log(`Failed: ${reason}.`))
.then(InspectorTest.completeTest);
async function runTest() {
InspectorTest.runAsyncTestSuite([
async function test() {
InspectorTest.log('Running test function...');
WasmInspectorTest.instantiate(module_bytes);
const [, {params: wasmScript}] = await Protocol.Debugger.onceScriptParsed(2);
await checkSetBreakpointForScript(wasmScript.scriptId);
InspectorTest.log('Finished!');
}
}
]);
function printFailure(message) {
if (!message.result) {
......
Tests stepping through wasm scripts.
Running test: test
Instantiating.
Waiting for wasm script (ignoring first non-wasm script).
Setting breakpoint at offset 54 on script wasm://wasm/0c10a5fe
......@@ -35,4 +37,3 @@ Breaking on byte offset 54
Breaking on byte offset 45
Breaking on byte offset 47
exports.main returned!
Finished!
Tests stepping through wasm scripts.
Running test: test
Instantiating.
Waiting for wasm script (ignoring first non-wasm script).
Setting breakpoint at offset 38 on script wasm://wasm/0c10a5fe
......@@ -425,4 +427,3 @@ at wasm_B (0:61):
at (anonymous) (0:17):
-- skipped
exports.main returned!
Finished!
......@@ -84,7 +84,8 @@ Protocol.Debugger.onPaused(async msg => {
Protocol.Debugger.resume();
});
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
// Spawn asynchronously:
......@@ -99,6 +100,5 @@ Protocol.Debugger.onPaused(async msg => {
InspectorTest.log('Calling main(4)');
await WasmInspectorTest.evalWithUrl('instance.exports.main(4)', 'runWasm');
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
......@@ -53,7 +53,8 @@ Protocol.Debugger.onPaused(pause_msg => {
Protocol.Debugger.resume();
});
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
// Spawn asynchronously:
......@@ -68,6 +69,5 @@ Protocol.Debugger.onPaused(pause_msg => {
InspectorTest.log('Calling main(4)');
await WasmInspectorTest.evalWithUrl('instance.exports.main(4)', 'runWasm');
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
Tests pausing a running script and stepping
Running test: testPauseAndStep
Instantiate
Wait for script
Got wasm script: wasm://wasm/c84b7cde
......@@ -9,4 +11,3 @@ Paused at offset 62; wasm-expression-stack: []; local: [12]
Paused at offset 64; wasm-expression-stack: [12]; local: [12]
Paused at offset 66; wasm-expression-stack: [12, 1]; local: [12]
Paused at offset 67; wasm-expression-stack: [13]; local: [12]
Finished!
......@@ -35,7 +35,8 @@ function instantiate(bytes, imports) {
return new WebAssembly.Instance(module, imports);
}
(async function pauseAndStep() {
InspectorTest.runAsyncTestSuite([
async function testPauseAndStep() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiate');
const instantiate_code = `var instance = (${instantiate})(${JSON.stringify(module_bytes)}, {'imports': {'pause': () => { %ScheduleBreak() } }});`;
......@@ -52,9 +53,8 @@ function instantiate(bytes, imports) {
await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('stepInto');
await waitForPauseAndStep('resume');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
async function waitForPauseAndStep(stepAction) {
const msg = await Protocol.Debugger.oncePaused();
......
Test scope inspection and stepping after a trap.
Running test: test
Instantiating.
Calling div function.
Paused at:
......@@ -61,4 +63,3 @@ Paused at:
-------------
-> resume
Finished.
......@@ -62,16 +62,16 @@ function call_div() {
contextGroup.addScript(call_div.toString());
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
await Protocol.Debugger.setPauseOnExceptions({state: 'all'});
InspectorTest.log('Instantiating.');
await WasmInspectorTest.instantiate(module_bytes);
InspectorTest.log('Calling div function.');
await Protocol.Runtime.evaluate({'expression': 'call_div()'});
InspectorTest.log('Finished.');
InspectorTest.completeTest();
})();
}
]);
async function printLocalScope(frame) {
InspectorTest.log(`scope at ${frame.functionName} (${
......
Step into a function that starts with a non-breakable opcode (i.e. block), then step from there. See https://crbug.com/1137710.
Running test: test
Setting up global instance variable.
Got wasm script: wasm://wasm/4658c40e
Setting breakpoint on offset 44
......
......@@ -21,7 +21,8 @@ var main = builder.addFunction('main', kSig_v_i)
var module_bytes = builder.toArray();
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
InspectorTest.logProtocolCommandCalls('Debugger.stepInto');
InspectorTest.logProtocolCommandCalls('Debugger.resume');
......@@ -50,5 +51,5 @@ var module_bytes = builder.toArray();
Protocol.Debugger[action]();
}
InspectorTest.log('exports.main returned.');
})().catch(reason => InspectorTest.log(`Failed: ${reason}`))
.finally(InspectorTest.completeTest);
}
]);
Tests stepping through wasm scripts by byte offsets
Running test: test
Setting up global instance variable.
Got wasm script: wasm://wasm/42af3c82
Setting breakpoint on offset 72 (should be propagated to 73, the offset of the call), url wasm://wasm/42af3c82
......@@ -66,4 +68,3 @@ Removing breakpoint
Debugger.stepOver called
Script wasm://wasm/42af3c82 byte offset 95: Wasm opcode 0x20 (kExprLocalGet)
Debugger.resume called
Finished!
Tests stepping from javascript into wasm
Running test: test
Calling instantiate function.
Waiting for wasm scripts to be parsed.
Ignoring script with url v8://test/instantiate
......@@ -28,4 +30,3 @@ paused
Script wasm://wasm/7d022e0e byte offset 37: Wasm opcode 0x41 (kExprI32Const)
Debugger.resume
exports.main returned!
Finished!
......@@ -44,7 +44,8 @@ function test() {
}
//# sourceURL=test.js`);
(async function Test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Calling instantiate function.');
WasmInspectorTest.instantiate(module_bytes);
......@@ -61,9 +62,8 @@ function test() {
InspectorTest.logMessage(msg.result.actualLocation);
await Protocol.Runtime.evaluate({expression: 'test()'});
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
function printFailure(message) {
if (!message.result) {
......
Tests that Liftoff does not merge opcodes while stepping
Running test: test
Setting breakpoint at offset 33.
Paused at offset 33: [0]
Paused at offset 35: [0, 0]
......@@ -11,4 +13,3 @@ Paused at offset 33: [13]
Paused at offset 35: [13, 13]
Paused at offset 36: [13, 0]
Paused at offset 38: [13]
Finished.
......@@ -21,7 +21,8 @@ let module_bytes = builder.toArray();
let wasm_script_id = undefined;
Protocol.Debugger.onPaused(printPauseLocationAndStep);
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
WasmInspectorTest.instantiate(module_bytes);
[, {params: {scriptId: wasm_script_id}}] = await Protocol.Debugger.onceScriptParsed(2);
......@@ -37,9 +38,8 @@ Protocol.Debugger.onPaused(printPauseLocationAndStep);
await Protocol.Runtime.evaluate(
{expression: `instance.exports.fun(${value})`});
}
InspectorTest.log('Finished.');
})().catch(reason => InspectorTest.log(`Failed: ${reason}`))
.finally(InspectorTest.completeTest);
}
]);
async function printPauseLocationAndStep(msg) {
// If we are outside of wasm, continue.
......
Tests stepping out from javascript to a wasm caller
Running test: test
Instantiating.
Running exports.main.
>>> First round
......
......@@ -32,7 +32,8 @@ function pauseAlternating() {
}
`);
(async function Test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Instantiating.');
const instantiate_code =
......@@ -56,6 +57,5 @@ function pauseAlternating() {
InspectorTest.log('>>> Third round');
await Protocol.Runtime.evaluate({expression: 'instance.exports.main()'});
InspectorTest.log('exports.main returned.');
InspectorTest.completeTest();
})();
}
]);
Tests stepping to javascript from wasm
Running test: test
Calling instantiate function.
Waiting for wasm scripts to be parsed.
Ignoring script with url v8://test/instantiate
......
......@@ -61,7 +61,8 @@ function test() {
}
//# sourceURL=test.js`);
(async function Test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Calling instantiate function.');
WasmInspectorTest.instantiate(module_bytes);
......@@ -79,8 +80,8 @@ function test() {
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished run '+ i +'!\n');
}
InspectorTest.completeTest();
})();
}
]);
function printFailure(message) {
if (!message.result) {
......
Tests stepping through wasm scripts by byte offsets
Running test: test
Setting up global instance variable
Got wasm script: wasm://wasm/befe41aa
{
......@@ -114,4 +116,3 @@ Input positions array is not sorted or contains duplicate values.
Test: skip list is not sorted
Testing stepInto with skipList: [{"scriptId":"4","start":{"lineNumber":0,"columnNumber":50},"end":{"lineNumber":0,"columnNumber":62}},{"scriptId":"4","start":{"lineNumber":0,"columnNumber":48},"end":{"lineNumber":0,"columnNumber":62}}]
Input positions array is not sorted or contains duplicate values.
Finished!
......@@ -44,11 +44,8 @@ const call_function_offset = loop_body_start_offset + 12;
const func_a_start_offset = func_a.body_offset;
const func_a_end_offset = func_a_start_offset + 2;
runTest()
.catch(reason => InspectorTest.log(`Failed: ${reason}`))
.then(InspectorTest.completeTest);
async function runTest() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
InspectorTest.log('Setting up global instance variable');
WasmInspectorTest.instantiate(module_bytes);
......@@ -65,9 +62,8 @@ async function runTest() {
await checkValidSkipLists(scriptId);
await checkInvalidSkipLists(scriptId);
InspectorTest.log('Finished!');
}
}
]);
async function checkValidSkipLists(scriptId) {
InspectorTest.log('Test with valid skip lists');
......
Tests stepping through wasm scripts with source maps
Running test: test
Got wasm script: wasm://wasm/9b4bf87e
Script sourceMapURL: abc
Requesting source for wasm://wasm/9b4bf87e...
......@@ -328,4 +330,3 @@ at (anonymous) (0:17):
-- skipped
Debugger.resume called
exports.main returned!
Finished!
......@@ -36,7 +36,8 @@ builder.addCustomSection('sourceMappingURL', [3, 97, 98, 99]);
var module_bytes = builder.toArray();
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
for (const action of ['stepInto', 'stepOver', 'stepOut', 'resume'])
InspectorTest.logProtocolCommandCalls('Debugger.' + action);
......@@ -74,9 +75,8 @@ var module_bytes = builder.toArray();
// then just resume.
await waitForPauseAndStep('resume');
InspectorTest.log('exports.main returned!');
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
async function waitForPauseAndStep(stepAction) {
const {params: {callFrames}} = await Protocol.Debugger.oncePaused();
......
......@@ -54,7 +54,8 @@ let fact = builder.addFunction('fact', kSig_i_i)
var module_bytes = builder.toArray();
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
for (const action of ['stepInto', 'stepOver', 'stepOut', 'resume'])
InspectorTest.logProtocolCommandCalls('Debugger.' + action);
......@@ -114,9 +115,8 @@ var module_bytes = builder.toArray();
await Protocol.Debugger.removeBreakpoint({breakpointId});
await Protocol.Debugger.stepOver();
await waitForPauseAndStep('resume');
InspectorTest.log('Finished!');
})().catch(reason => InspectorTest.log(`Failed: ${reason}`))
.finally(InspectorTest.completeTest);
}
]);
async function waitForPauseAndStep(stepAction) {
await waitForPause();
......
Tests unnamed function in wasm scripts
Running test: test
Running testFunction with generated wasm bytes...
Paused on 'debugger;'
Number of frames: 5
......@@ -7,4 +9,3 @@ Number of frames: 5
- [2] main
- [3] testFunction
- [4]
Finished!
......@@ -43,16 +43,15 @@ function testFunction(bytes) {
contextGroup.addScript(testFunction.toString());
(async function test() {
InspectorTest.runAsyncTestSuite([
async function test() {
await Protocol.Debugger.enable();
Protocol.Debugger.onPaused(handleDebuggerPaused);
InspectorTest.log('Running testFunction with generated wasm bytes...');
await Protocol.Runtime.evaluate(
{'expression': 'testFunction(' + JSON.stringify(module_bytes) + ')'});
InspectorTest.log('Finished!');
InspectorTest.completeTest();
})();
}
]);
function logStackTrace(messageObject) {
var frames = messageObject.params.callFrames;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment