mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
Add CTS telemetry harness support
Migrates harness support files added in https://chromium-review.googlesource.com/c/chromium/src/+/3541414 into Dawn's repo. Tested in https://chromium-review.googlesource.com/c/chromium/src/+/3537743 Bug: chromium:1306640 Change-Id: I3000b1223219a1da293af910bf442570b70b7c92 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/84043 Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
65
webgpu-cts/test_runner.js
Normal file
65
webgpu-cts/test_runner.js
Normal file
@@ -0,0 +1,65 @@
|
||||
// Copyright 2022 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { DefaultTestFileLoader } from '../third_party/webgpu-cts/src/common/internal/file_loader.js';
|
||||
import { prettyPrintLog } from '../third_party/webgpu-cts/src/common/internal/logging/log_message.js';
|
||||
import { Logger } from '../third_party/webgpu-cts/src/common/internal/logging/logger.js';
|
||||
import { parseQuery } from '../third_party/webgpu-cts/src/common/internal/query/parseQuery.js';
|
||||
|
||||
import { TestWorker } from '../third_party/webgpu-cts/src/common/runtime/helper/test_worker.js';
|
||||
|
||||
var socket;
|
||||
|
||||
async function setupWebsocket(port) {
|
||||
socket = new WebSocket('ws://127.0.0.1:' + port)
|
||||
socket.addEventListener('message', runCtsTestViaSocket);
|
||||
}
|
||||
|
||||
async function runCtsTestViaSocket(event) {
|
||||
let input = JSON.parse(event.data);
|
||||
runCtsTest(input['q'], input['w']);
|
||||
}
|
||||
|
||||
async function runCtsTest(query, use_worker) {
|
||||
const workerEnabled = use_worker;
|
||||
const worker = workerEnabled ? new TestWorker(false) : undefined;
|
||||
|
||||
const loader = new DefaultTestFileLoader();
|
||||
const filterQuery = parseQuery(query);
|
||||
const testcases = await loader.loadCases(filterQuery);
|
||||
|
||||
const expectations = [];
|
||||
|
||||
const log = new Logger();
|
||||
|
||||
for (const testcase of testcases) {
|
||||
const name = testcase.query.toString();
|
||||
|
||||
const wpt_fn = async () => {
|
||||
const [rec, res] = log.record(name);
|
||||
if (worker) {
|
||||
await worker.run(rec, name, expectations);
|
||||
} else {
|
||||
await testcase.run(rec, expectations);
|
||||
}
|
||||
|
||||
socket.send(JSON.stringify({'s': res.status,
|
||||
'l': (res.logs ?? []).map(prettyPrintLog)}));
|
||||
};
|
||||
await wpt_fn();
|
||||
}
|
||||
}
|
||||
|
||||
window.runCtsTest = runCtsTest;
|
||||
window.setupWebsocket = setupWebsocket
|
||||
Reference in New Issue
Block a user