CTS: Hook into CTS heartbeat mechanism instead of wrapping TestCaseRecorder

Bug: chromium:1340602
Change-Id: I6272432c69c65fa45cbae9bedc02aec82ba68c8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100561
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Austin Eng 2022-08-26 22:34:27 +00:00 committed by Dawn LUCI CQ
parent 81d62d7ca9
commit b00c50edc6
1 changed files with 4 additions and 21 deletions

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { globalTestConfig } from '../third_party/webgpu-cts/src/common/framework/test_config.js';
import { DefaultTestFileLoader } from '../third_party/webgpu-cts/src/common/internal/file_loader.js'; 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 { 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 { Logger } from '../third_party/webgpu-cts/src/common/internal/logging/logger.js';
@ -130,24 +131,7 @@ wrapPromiseWithHeartbeat(GPUQueue.prototype, 'onSubmittedWorkDone');
wrapPromiseWithHeartbeat(GPUBuffer.prototype, 'mapAsync'); wrapPromiseWithHeartbeat(GPUBuffer.prototype, 'mapAsync');
wrapPromiseWithHeartbeat(GPUShaderModule.prototype, 'compilationInfo'); wrapPromiseWithHeartbeat(GPUShaderModule.prototype, 'compilationInfo');
// Make a wrapper around TestCaseRecorder that sends a heartbeat before any globalTestConfig.testHeartbeatCallback = sendHeartbeat;
// recording operations.
function makeRecorderWithHeartbeat(rec) {
return new Proxy(rec, {
// Create a wrapper around all methods of the TestCaseRecorder.
get(target, prop, receiver) {
const orig = Reflect.get(target, prop, receiver);
if (typeof orig !== 'function') {
// Return the original property if it is not a function.
return orig;
}
return (...args) => {
sendHeartbeat();
return orig.call(receiver, ...args)
}
}
});
}
async function runCtsTest(query, use_worker) { async function runCtsTest(query, use_worker) {
const workerEnabled = use_worker; const workerEnabled = use_worker;
@ -167,13 +151,12 @@ async function runCtsTest(query, use_worker) {
const wpt_fn = async () => { const wpt_fn = async () => {
sendMessageTestStarted(); sendMessageTestStarted();
const [rec, res] = log.record(name); const [rec, res] = log.record(name);
const recWithHeartbeat = makeRecorderWithHeartbeat(rec);
beginHeartbeatScope(); beginHeartbeatScope();
if (worker) { if (worker) {
await worker.run(recWithHeartbeat, name, expectations); await worker.run(rec, name, expectations);
} else { } else {
await testcase.run(recWithHeartbeat, expectations); await testcase.run(rec, expectations);
} }
endHeartbeatScope(); endHeartbeatScope();