Skip to content

Commit

Permalink
[WebGPU] Update CTS tests
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268638
<radar://122193777>

Reviewed by Dan Glastonbury.

Update WebGPU CTS to latest revision so other PRs don't include manual
updates to the CTS tests so they can pass with run-webkit-tests

* LayoutTests/http/tests/webgpu/webgpu/api/operation/adapter/requestAdapter.spec.js:
Truncated due to commit message length, it was an auto import using import-webgpu-cts

Canonical link: https://commits.webkit.org/274107@main
  • Loading branch information
mwyrzykowski committed Feb 5, 2024
1 parent 67bfc13 commit ccc515d
Show file tree
Hide file tree
Showing 872 changed files with 96,357 additions and 66,305 deletions.
112 changes: 99 additions & 13 deletions LayoutTests/http/tests/webgpu/common/framework/data_cache.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,66 @@
/**
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/ /**
* Utilities to improve the performance of the CTS, by caching data that is
* expensive to build using a two-level cache (in-memory, pre-computed file).
*/import { assert } from '../util/util.js';

/** DataCache is an interface to a data store used to hold cached data */




/** Logger is a basic debug logger function */


/**
* DataCacheNode represents a single cache entry in the LRU DataCache.
* DataCacheNode is a doubly linked list, so that least-recently-used entries can be removed, and
* cache hits can move the node to the front of the list.
*/
class DataCacheNode {
constructor(path, data) {
this.path = path;
this.data = data;
}

/** insertAfter() re-inserts this node in the doubly-linked list after `prev` */
insertAfter(prev) {
this.unlink();
this.next = prev.next;
this.prev = prev;
prev.next = this;
if (this.next) {
this.next.prev = this;
}
}

/** unlink() removes this node from the doubly-linked list */
unlink() {
const prev = this.prev;
const next = this.next;
if (prev) {
prev.next = next;
}
if (next) {
next.prev = prev;
}
this.prev = null;
this.next = null;
}

// The file path this node represents
// The deserialized data for this node
prev = null; // The previous node in the doubly-linked list
next = null; // The next node in the doubly-linked list
}

/** DataCache is an interface to a LRU-cached data store used to hold data cached by path */
export class DataCache {
constructor() {
this.lruHeadNode.next = this.lruTailNode;
this.lruTailNode.prev = this.lruHeadNode;
}

/** setDataStore() sets the backing data store used by the data cache */
setStore(dataStore) {
this.dataStore = dataStore;
Expand All @@ -20,11 +77,14 @@ export class DataCache {
* building the data and storing it in the cache.
*/
async fetch(cacheable) {
// First check the in-memory cache
let data = this.cache.get(cacheable.path);
if (data !== undefined) {
this.log('in-memory cache hit');
return Promise.resolve(data);
{
// First check the in-memory cache
const node = this.cache.get(cacheable.path);
if (node !== undefined) {
this.log('in-memory cache hit');
node.insertAfter(this.lruHeadNode);
return Promise.resolve(node.data);
}
}
this.log('in-memory cache miss');
// In in-memory cache miss.
Expand All @@ -41,25 +101,51 @@ export class DataCache {
}
if (serialized !== undefined) {
this.log(`deserializing`);
data = cacheable.deserialize(serialized);
this.cache.set(cacheable.path, data);
const data = cacheable.deserialize(serialized);
this.addToCache(cacheable.path, data);
return data;
}
}
// Not found anywhere. Build the data, and cache for future lookup.
this.log(`cache: building (${cacheable.path})`);
data = await cacheable.build();
this.cache.set(cacheable.path, data);
const data = await cacheable.build();
this.addToCache(cacheable.path, data);
return data;
}

/**
* addToCache() creates a new node for `path` and `data`, inserting the new node at the front of
* the doubly-linked list. If the number of entries in the cache exceeds this.maxCount, then the
* least recently used entry is evicted
* @param path the file path for the data
* @param data the deserialized data
*/
addToCache(path, data) {
if (this.cache.size >= this.maxCount) {
const toEvict = this.lruTailNode.prev;
assert(toEvict !== null);
toEvict.unlink();
this.cache.delete(toEvict.path);
this.log(`evicting ${toEvict.path}`);
}
const node = new DataCacheNode(path, data);
node.insertAfter(this.lruHeadNode);
this.cache.set(path, node);
this.log(`added ${path}. new count: ${this.cache.size}`);
}

log(msg) {
if (this.debugLogger !== null) {
this.debugLogger(`DataCache: ${msg}`);
}
}

// Max number of entries in the cache before LRU entries are evicted.
maxCount = 4;

cache = new Map();
lruHeadNode = new DataCacheNode('', null); // placeholder node (no path or data)
lruTailNode = new DataCacheNode('', null); // placeholder node (no path or data)
unavailableFiles = new Set();
dataStore = null;
debugLogger = null;
Expand All @@ -86,4 +172,4 @@ export function setIsBuildingDataCache(value = true) {
* DataCache.
* The 'npm run gen_cache' tool will look for module-scope variables of this
* interface, with the name `d`.
*/
*/
92 changes: 67 additions & 25 deletions LayoutTests/http/tests/webgpu/common/framework/fixture.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/ import { assert, unreachable } from '../util/util.js';
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/import { assert, unreachable } from '../util/util.js';

export class SkipTestCase extends Error {}
export class UnexpectedPassError extends Error {}
Expand All @@ -9,15 +9,20 @@ export { TestCaseRecorder } from '../internal/logging/test_case_recorder.js';

/** The fully-general type for params passed to a test function invocation. */









export class SubcaseBatchState {
constructor(
recorder,
/** The case parameters for this test fixture shared state. Subcase params are not included. */
params
) {
this.recorder = recorder;
this.params = params;
}
recorder,
/** The case parameters for this test fixture shared state. Subcase params are not included. */
params)
{this.recorder = recorder;this.params = params;}

/**
* Runs before the `.before()` function.
Expand All @@ -42,6 +47,8 @@ export class SubcaseBatchState {
* (i.e. every time the test function is run).
*/
export class Fixture {


/**
* Interface for recording logs and test status.
*
Expand Down Expand Up @@ -138,11 +145,11 @@ export class Fixture {
tryTrackForCleanup(o) {
if (typeof o === 'object' && o !== null) {
if (
'destroy' in o ||
'close' in o ||
o instanceof WebGLRenderingContext ||
o instanceof WebGL2RenderingContext
) {
'destroy' in o ||
'close' in o ||
o instanceof WebGLRenderingContext ||
o instanceof WebGL2RenderingContext)
{
this.objectsToCleanUp.push(o);
}
}
Expand Down Expand Up @@ -214,7 +221,7 @@ export class Fixture {

/** Expect that the provided promise resolves (fulfills). */
shouldResolve(p, msg) {
this.eventualAsyncExpectation(async niceStack => {
this.eventualAsyncExpectation(async (niceStack) => {
const m = msg ? ': ' + msg : '';
try {
await p;
Expand All @@ -230,16 +237,26 @@ export class Fixture {
}

/** Expect that the provided promise rejects, with the provided exception name. */
shouldReject(expectedName, p, msg) {
this.eventualAsyncExpectation(async niceStack => {
const m = msg ? ': ' + msg : '';
shouldReject(
expectedName,
p,
{ allowMissingStack = false, message } = {})
{
this.eventualAsyncExpectation(async (niceStack) => {
const m = message ? ': ' + message : '';
try {
await p;
niceStack.message = 'DID NOT REJECT' + m;
this.rec.expectationFailed(niceStack);
} catch (ex) {
niceStack.message = 'rejected as expected' + m;
this.expectErrorValue(expectedName, ex, niceStack);
if (!allowMissingStack) {
if (!(ex instanceof Error && typeof ex.stack === 'string')) {
const exMessage = ex instanceof Error ? ex.message : '?';
niceStack.message = `rejected as expected, but missing stack (${exMessage})${m}`;
this.rec.expectationFailed(niceStack);
}
}
}
});
}
Expand All @@ -250,8 +267,12 @@ export class Fixture {
*
* MAINTENANCE_TODO: Change to `string | false` so the exception name is always checked.
*/
shouldThrow(expectedError, fn, msg) {
const m = msg ? ': ' + msg : '';
shouldThrow(
expectedError,
fn,
{ allowMissingStack = false, message } = {})
{
const m = message ? ': ' + message : '';
try {
fn();
if (expectedError === false) {
Expand All @@ -264,6 +285,11 @@ export class Fixture {
this.rec.expectationFailed(new Error('threw unexpectedly' + m));
} else {
this.expectErrorValue(expectedError, ex, new Error(m));
if (!allowMissingStack) {
if (!(ex instanceof Error && typeof ex.stack === 'string')) {
this.rec.expectationFailed(new Error('threw as expected, but missing stack' + m));
}
}
}
}
}
Expand All @@ -283,8 +309,11 @@ export class Fixture {
* If the argument is an `Error`, fail (or warn). If it's `undefined`, no-op.
* If the argument is an array, apply the above behavior on each of elements.
*/
expectOK(error, { mode = 'fail', niceStack } = {}) {
const handleError = error => {
expectOK(
error,
{ mode = 'fail', niceStack } = {})
{
const handleError = (error) => {
if (error instanceof Error) {
if (niceStack) {
error.stack = niceStack.stack;
Expand All @@ -308,9 +337,22 @@ export class Fixture {
}
}

eventualExpectOK(error, { mode = 'fail' } = {}) {
this.eventualAsyncExpectation(async niceStack => {
eventualExpectOK(
error,
{ mode = 'fail' } = {})
{
this.eventualAsyncExpectation(async (niceStack) => {
this.expectOK(await error, { mode, niceStack });
});
}
}



/**
* FixtureClass encapsulates a constructor for fixture and a corresponding
* shared state factory function. An interface version of the type is also
* defined for mixin declaration use ONLY. The interface version is necessary
* because mixin classes need a constructor with a single any[] rest
* parameter.
*/
18 changes: 15 additions & 3 deletions LayoutTests/http/tests/webgpu/common/framework/metadata.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
/**
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/ import { assert } from '../util/util.js'; /** Metadata about tests (that can't be derived at runtime). */
* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
**/import { assert } from '../util/util.js'; /** Metadata about tests (that can't be derived at runtime). */













export function loadMetadataForSuite(suiteDir) {
assert(typeof require !== 'undefined', 'loadMetadataForSuite is only implemented on Node');
Expand All @@ -13,4 +25,4 @@ export function loadMetadataForSuite(suiteDir) {

const metadata = JSON.parse(fs.readFileSync(metadataFile, 'utf8'));
return metadata;
}
}
Loading

0 comments on commit ccc515d

Please sign in to comment.