blob: 43eb13972860f0e92db0e3921eeb760c35d40d36 [file] [log] [blame]
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test Error Scopes.</title>
<body>
<script src="js/webgpu-functions.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
let tests = {};
tests["Capture a single GPUValidation error."] = async device => {
device.pushErrorScope("validation");
causeValidationError(device);
return popValidationError(device);
};
tests["Capture a single GPUOutOfMemory error."] = async device => {
device.pushErrorScope("out-of-memory");
causeMemoryError(device);
return popMemoryError(device);
};
tests["Ignore errors past the first."] = async device => {
device.pushErrorScope("validation");
device.pushErrorScope("validation");
causeValidationError(device);
causeValidationError(device);
const error = await device.popErrorScope();
assertValidationError(error);
return popNullError(device);
};
tests["Captured errors match error scope filter."] = async device => {
device.pushErrorScope("validation");
device.pushErrorScope("out-of-memory");
causeValidationError(device);
const shouldBeNull = await device.popErrorScope();
assertNull(shouldBeNull);
return popValidationError(device);
};
tests["Reject popErrorScope if no scope exists."] = async device => {
const promise = device.popErrorScope().then(() => assert_unreached(), async e => {
assert_false(e === undefined);
// Pop the extra 'none' scope.
await popNullError(device);
});
// 'promise' should still reject if a scope is pushed here.
device.pushErrorScope("none");
return promise;
};
tests["Filter 'none' should capture but not report errors."] = async device => {
device.pushErrorScope("out-of-memory");
device.pushErrorScope("none");
causeMemoryError(device);
const shouldBeNull = await device.popErrorScope();
assertNull(shouldBeNull);
return popNullError(device);
};
tests["Push and pop many error scopes with no rejections."] = async device => {
const numIterations = 128;
for (let i = 0; i < numIterations; ++i)
device.pushErrorScope("out-of-memory");
for (let i = 0; i < numIterations - 1; ++i)
await popNullError(device);
return popNullError(device);
};
tests["Catch many errors in nested scopes."] = async device => {
const numIterations = 128;
for (let i = 0; i < numIterations; ++i) {
device.pushErrorScope("validation");
causeValidationError(device);
}
for (let i = 0; i < numIterations - 1; ++i)
await popValidationError(device);
return popValidationError(device);
};
runTestsWithDevice(tests);
/* Helper Functions */
const causeValidationError = device => device.createBuffer({ size: 4, usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.MAP_WRITE });
const causeMemoryError = device => device.createBuffer({ size: 99999999999, usage: GPUBufferUsage.NONE });
</script>
</body>