Switch to message protocol

Switches the WebGPU CTS test runner JavaScript code to use the defined
message protocol instead of the ad-hoc solution we were using before.

Bug: chromium:1340602
Change-Id: Ieaf26b5b2409f69d7859d3db4ce7757780de6712
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98684
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@google.com>
This commit is contained in:
Brian Sheedy 2022-08-11 14:39:51 +00:00 committed by Dawn LUCI CQ
parent 6af4c8b97d
commit 0653501212

View File

@ -55,6 +55,7 @@ async function runCtsTest(query, use_worker) {
const name = testcase.query.toString(); const name = testcase.query.toString();
const wpt_fn = async () => { const wpt_fn = async () => {
sendMessageTestStarted();
const [rec, res] = log.record(name); const [rec, res] = log.record(name);
if (worker) { if (worker) {
await worker.run(rec, name, expectations); await worker.run(rec, name, expectations);
@ -62,8 +63,19 @@ async function runCtsTest(query, use_worker) {
await testcase.run(rec, expectations); await testcase.run(rec, expectations);
} }
sendMessageTestStatus(res.status, res.timems);
let fullLogs = (res.logs ?? []).map(prettyPrintLog); let fullLogs = (res.logs ?? []).map(prettyPrintLog);
fullLogs = fullLogs.join('\n\n\n'); fullLogs = fullLogs.join('\n\n\n');
let logPieces = splitLogsForPayload(fullLogs);
sendMessageTestLog(logPieces);
sendMessageTestFinished();
};
await wpt_fn();
}
}
function splitLogsForPayload(fullLogs) {
let logPieces = [fullLogs] let logPieces = [fullLogs]
// Split the log pieces until they all are guaranteed to fit into a // Split the log pieces until they all are guaranteed to fit into a
// websocket payload. // websocket payload.
@ -84,18 +96,28 @@ async function runCtsTest(query, use_worker) {
} }
logPieces = tempLogPieces; logPieces = tempLogPieces;
} }
return logPieces
}
logPieces.forEach((piece, index, arr) => { function sendMessageTestStarted() {
let isFinal = index == arr.length - 1; socket.send(JSON.stringify({'type': 'TEST_STARTED'}));
socket.send(JSON.stringify({'s': res.status, }
'l': piece,
'final': isFinal, function sendMessageTestStatus(status, jsDurationMs) {
'js_duration_ms': res.timems, socket.send(JSON.stringify({'type': 'TEST_STATUS',
'type': 'TEST_FINISHED'})); 'status': status,
'js_duration_ms': jsDurationMs}));
}
function sendMessageTestLog(logPieces) {
logPieces.forEach((piece) => {
socket.send(JSON.stringify({'type': 'TEST_LOG',
'log': piece}));
}); });
}; }
await wpt_fn();
} function sendMessageTestFinished() {
socket.send(JSON.stringify({'type': 'TEST_FINISHED'}));
} }
window.runCtsTest = runCtsTest; window.runCtsTest = runCtsTest;