From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../tests/webgpu/common/framework/data_cache.js | 89 +++ .../tests/webgpu/common/framework/fixture.js | 310 ++++++++++ .../webgpu/common/framework/params_builder.js | 213 +++++++ .../tests/webgpu/common/framework/resources.js | 111 ++++ .../tests/webgpu/common/framework/test_config.js | 10 + .../tests/webgpu/common/framework/test_group.js | 3 + .../tests/webgpu/common/internal/file_loader.js | 96 +++ .../webgpu/common/internal/file_loader.js.map | 1 + .../webgpu/common/internal/logging/log_message.js | 45 ++ .../common/internal/logging/log_message.js.map | 1 + .../tests/webgpu/common/internal/logging/logger.js | 31 + .../webgpu/common/internal/logging/logger.js.map | 1 + .../tests/webgpu/common/internal/logging/result.js | 4 + .../webgpu/common/internal/logging/result.js.map | 1 + .../common/internal/logging/test_case_recorder.js | 159 +++++ .../internal/logging/test_case_recorder.js.map | 1 + .../tests/webgpu/common/internal/params_utils.js | 125 ++++ .../webgpu/common/internal/params_utils.js.map | 1 + .../tests/webgpu/common/internal/query/compare.js | 95 +++ .../webgpu/common/internal/query/compare.js.map | 1 + .../common/internal/query/encode_selectively.js | 24 + .../internal/query/encode_selectively.js.map | 1 + .../common/internal/query/json_param_value.js | 84 +++ .../common/internal/query/json_param_value.js.map | 1 + .../webgpu/common/internal/query/parseQuery.js | 156 +++++ .../webgpu/common/internal/query/parseQuery.js.map | 1 + .../tests/webgpu/common/internal/query/query.js | 263 +++++++++ .../webgpu/common/internal/query/query.js.map | 1 + .../webgpu/common/internal/query/separators.js | 15 + .../webgpu/common/internal/query/separators.js.map | 1 + .../common/internal/query/stringify_params.js | 45 ++ .../common/internal/query/stringify_params.js.map | 1 + .../webgpu/common/internal/query/validQueryPart.js | 4 + .../common/internal/query/validQueryPart.js.map | 1 + .../mozilla/tests/webgpu/common/internal/stack.js | 83 +++ .../tests/webgpu/common/internal/stack.js.map | 1 + .../tests/webgpu/common/internal/test_group.js | 647 +++++++++++++++++++++ .../tests/webgpu/common/internal/test_group.js.map | 1 + .../webgpu/common/internal/test_suite_listing.js | 4 + .../common/internal/test_suite_listing.js.map | 1 + .../mozilla/tests/webgpu/common/internal/tree.js | 576 ++++++++++++++++++ .../tests/webgpu/common/internal/tree.js.map | 1 + .../mozilla/tests/webgpu/common/internal/util.js | 11 + .../tests/webgpu/common/internal/util.js.map | 1 + .../tests/webgpu/common/internal/version.js | 3 + .../tests/webgpu/common/runtime/helper/options.js | 18 + .../tests/webgpu/common/runtime/helper/sys.js | 37 ++ .../common/runtime/helper/test_worker-worker.js | 32 + .../webgpu/common/runtime/helper/test_worker.js | 37 ++ .../mozilla/tests/webgpu/common/runtime/wpt.js | 73 +++ .../tests/webgpu/common/util/collect_garbage.js | 59 ++ .../webgpu/common/util/collect_garbage.js.map | 1 + .../mozilla/tests/webgpu/common/util/colors.js | 128 ++++ .../mozilla/tests/webgpu/common/util/colors.js.map | 1 + .../tests/webgpu/common/util/data_tables.js | 40 ++ .../tests/webgpu/common/util/data_tables.js.map | 1 + .../tests/webgpu/common/util/navigator_gpu.js | 75 +++ .../tests/webgpu/common/util/navigator_gpu.js.map | 1 + .../tests/webgpu/common/util/preprocessor.js | 150 +++++ .../tests/webgpu/common/util/preprocessor.js.map | 1 + .../mozilla/tests/webgpu/common/util/timeout.js | 8 + .../tests/webgpu/common/util/timeout.js.map | 1 + .../mozilla/tests/webgpu/common/util/types.js | 60 ++ .../mozilla/tests/webgpu/common/util/types.js.map | 1 + .../mozilla/tests/webgpu/common/util/util.js | 304 ++++++++++ .../mozilla/tests/webgpu/common/util/util.js.map | 1 + .../tests/webgpu/common/util/wpt_reftest_wait.js | 25 + .../webgpu/common/util/wpt_reftest_wait.js.map | 1 + 68 files changed, 4280 insertions(+) create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/framework/data_cache.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/framework/fixture.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/framework/params_builder.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/framework/resources.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/framework/test_config.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/framework/test_group.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/file_loader.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/file_loader.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/log_message.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/log_message.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/logger.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/logger.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/result.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/result.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/test_case_recorder.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/logging/test_case_recorder.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/params_utils.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/params_utils.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/compare.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/compare.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/encode_selectively.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/encode_selectively.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/json_param_value.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/json_param_value.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/parseQuery.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/parseQuery.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/query.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/query.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/separators.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/separators.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/stringify_params.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/stringify_params.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/validQueryPart.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/query/validQueryPart.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/stack.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/stack.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/test_group.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/test_group.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/test_suite_listing.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/test_suite_listing.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/tree.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/tree.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/util.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/util.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/internal/version.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/runtime/helper/options.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/runtime/helper/sys.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/runtime/helper/test_worker-worker.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/runtime/helper/test_worker.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/runtime/wpt.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/colors.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/colors.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/types.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/types.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/util.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/util.js.map create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js create mode 100644 testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js.map (limited to 'testing/web-platform/mozilla/tests/webgpu/common') diff --git a/testing/web-platform/mozilla/tests/webgpu/common/framework/data_cache.js b/testing/web-platform/mozilla/tests/webgpu/common/framework/data_cache.js new file mode 100644 index 0000000000..e426ffbbc9 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/framework/data_cache.js @@ -0,0 +1,89 @@ +/** + * AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts + **/ + +/** DataCache is an interface to a data store used to hold cached data */ +export class DataCache { + /** setDataStore() sets the backing data store used by the data cache */ + setStore(dataStore) { + this.dataStore = dataStore; + } + + /** setDebugLogger() sets the verbose logger */ + setDebugLogger(logger) { + this.debugLogger = logger; + } + + /** + * fetch() retrieves cacheable data from the data cache, first checking the + * in-memory cache, then the data store (if specified), then resorting to + * 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); + } + this.log('in-memory cache miss'); + // In in-memory cache miss. + // Next, try the data store. + if (this.dataStore !== null && !this.unavailableFiles.has(cacheable.path)) { + let serialized; + try { + serialized = await this.dataStore.load(cacheable.path); + this.log('loaded serialized'); + } catch (err) { + // not found in data store + this.log(`failed to load (${cacheable.path}): ${err}`); + this.unavailableFiles.add(cacheable.path); + } + if (serialized !== undefined) { + this.log(`deserializing`); + data = cacheable.deserialize(serialized); + this.cache.set(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); + return data; + } + + log(msg) { + if (this.debugLogger !== null) { + this.debugLogger(`DataCache: ${msg}`); + } + } + + cache = new Map(); + unavailableFiles = new Set(); + dataStore = null; + debugLogger = null; +} + +/** The data cache */ +export const dataCache = new DataCache(); + +/** true if the current process is building the cache */ +let isBuildingDataCache = false; + +/** @returns true if the data cache is currently being built */ +export function getIsBuildingDataCache() { + return isBuildingDataCache; +} + +/** Sets whether the data cache is currently being built */ +export function setIsBuildingDataCache(value = true) { + isBuildingDataCache = value; +} + +/** + * Cacheable is the interface to something that can be stored into the + * DataCache. + * The 'npm run gen_cache' tool will look for module-scope variables of this + * interface, with the name `d`. + */ diff --git a/testing/web-platform/mozilla/tests/webgpu/common/framework/fixture.js b/testing/web-platform/mozilla/tests/webgpu/common/framework/fixture.js new file mode 100644 index 0000000000..1611e9a742 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/framework/fixture.js @@ -0,0 +1,310 @@ +/** + * 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 {} + +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(params) { + this._params = params; + } + + /** + * Returns the case parameters for this test fixture shared state. Subcase params + * are not included. + */ + get params() { + return this._params; + } + + /** + * Runs before the `.before()` function. + * @internal MAINTENANCE_TODO: Make this not visible to test code? + */ + async init() {} + /** + * Runs between the `.before()` function and the subcases. + * @internal MAINTENANCE_TODO: Make this not visible to test code? + */ + async postInit() {} + /** + * Runs after all subcases finish. + * @internal MAINTENANCE_TODO: Make this not visible to test code? + */ + async finalize() {} +} + +/** + * A Fixture is a class used to instantiate each test sub/case at run time. + * A new instance of the Fixture is created for every single test subcase + * (i.e. every time the test function is run). + */ +export class Fixture { + /** + * Interface for recording logs and test status. + * + * @internal + */ + + eventualExpectations = []; + numOutstandingAsyncExpectations = 0; + objectsToCleanUp = []; + + static MakeSharedState(params) { + return new SubcaseBatchState(params); + } + + /** @internal */ + constructor(sharedState, rec, params) { + this._sharedState = sharedState; + this.rec = rec; + this._params = params; + } + + /** + * Returns the (case+subcase) parameters for this test function invocation. + */ + get params() { + return this._params; + } + + /** + * Gets the test fixture's shared state. This object is shared between subcases + * within the same testcase. + */ + get sharedState() { + return this._sharedState; + } + + /** + * Override this to do additional pre-test-function work in a derived fixture. + * This has to be a member function instead of an async `createFixture` function, because + * we need to be able to ergonomically override it in subclasses. + * + * @internal MAINTENANCE_TODO: Make this not visible to test code? + */ + async init() {} + + /** + * Override this to do additional post-test-function work in a derived fixture. + * + * Called even if init was unsuccessful. + * + * @internal MAINTENANCE_TODO: Make this not visible to test code? + */ + async finalize() { + assert( + this.numOutstandingAsyncExpectations === 0, + 'there were outstanding immediateAsyncExpectations (e.g. expectUncapturedError) at the end of the test' + ); + + // Loop to exhaust the eventualExpectations in case they chain off each other. + while (this.eventualExpectations.length) { + const p = this.eventualExpectations.shift(); + try { + await p; + } catch (ex) { + this.rec.threw(ex); + } + } + + // And clean up any objects now that they're done being used. + for (const o of this.objectsToCleanUp) { + if ('getExtension' in o) { + const WEBGL_lose_context = o.getExtension('WEBGL_lose_context'); + if (WEBGL_lose_context) WEBGL_lose_context.loseContext(); + } else if ('destroy' in o) { + o.destroy(); + } else { + o.close(); + } + } + } + + /** + * Tracks an object to be cleaned up after the test finishes. + * + * MAINTENANCE_TODO: Use this in more places. (Will be easier once .destroy() is allowed on + * invalid objects.) + */ + trackForCleanup(o) { + this.objectsToCleanUp.push(o); + return o; + } + + /** Tracks an object, if it's destroyable, to be cleaned up after the test finishes. */ + tryTrackForCleanup(o) { + if (typeof o === 'object' && o !== null) { + if ( + 'destroy' in o || + 'close' in o || + o instanceof WebGLRenderingContext || + o instanceof WebGL2RenderingContext + ) { + this.objectsToCleanUp.push(o); + } + } + return o; + } + + /** Log a debug message. */ + debug(msg) { + this.rec.debug(new Error(msg)); + } + + /** Throws an exception marking the subcase as skipped. */ + skip(msg) { + throw new SkipTestCase(msg); + } + + /** Log a warning and increase the result status to "Warn". */ + warn(msg) { + this.rec.warn(new Error(msg)); + } + + /** Log an error and increase the result status to "ExpectFailed". */ + fail(msg) { + this.rec.expectationFailed(new Error(msg)); + } + + /** + * Wraps an async function. Tracks its status to fail if the test tries to report a test status + * before the async work has finished. + */ + async immediateAsyncExpectation(fn) { + this.numOutstandingAsyncExpectations++; + const ret = await fn(); + this.numOutstandingAsyncExpectations--; + return ret; + } + + /** + * Wraps an async function, passing it an `Error` object recording the original stack trace. + * The async work will be implicitly waited upon before reporting a test status. + */ + eventualAsyncExpectation(fn) { + const promise = fn(new Error()); + this.eventualExpectations.push(promise); + } + + expectErrorValue(expectedError, ex, niceStack) { + if (!(ex instanceof Error)) { + niceStack.message = `THREW non-error value, of type ${typeof ex}: ${ex}`; + this.rec.expectationFailed(niceStack); + return; + } + const actualName = ex.name; + if (expectedError !== true && actualName !== expectedError) { + niceStack.message = `THREW ${actualName}, instead of ${expectedError}: ${ex}`; + this.rec.expectationFailed(niceStack); + } else { + niceStack.message = `OK: threw ${actualName}: ${ex.message}`; + this.rec.debug(niceStack); + } + } + + /** Expect that the provided promise resolves (fulfills). */ + shouldResolve(p, msg) { + this.eventualAsyncExpectation(async niceStack => { + const m = msg ? ': ' + msg : ''; + try { + await p; + niceStack.message = 'resolved as expected' + m; + } catch (ex) { + niceStack.message = `REJECTED${m}`; + if (ex instanceof Error) { + niceStack.message += '\n' + ex.message; + } + this.rec.expectationFailed(niceStack); + } + }); + } + + /** Expect that the provided promise rejects, with the provided exception name. */ + shouldReject(expectedName, p, msg) { + this.eventualAsyncExpectation(async niceStack => { + const m = msg ? ': ' + msg : ''; + 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); + } + }); + } + + /** + * Expect that the provided function throws. + * If an `expectedName` is provided, expect that the throw exception has that name. + */ + shouldThrow(expectedError, fn, msg) { + const m = msg ? ': ' + msg : ''; + try { + fn(); + if (expectedError === false) { + this.rec.debug(new Error('did not throw, as expected' + m)); + } else { + this.rec.expectationFailed(new Error('unexpectedly did not throw' + m)); + } + } catch (ex) { + if (expectedError === false) { + this.rec.expectationFailed(new Error('threw unexpectedly' + m)); + } else { + this.expectErrorValue(expectedError, ex, new Error(m)); + } + } + } + + /** Expect that a condition is true. */ + expect(cond, msg) { + if (cond) { + const m = msg ? ': ' + msg : ''; + this.rec.debug(new Error('expect OK' + m)); + } else { + this.rec.expectationFailed(new Error(msg)); + } + return cond; + } + + /** + * 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 => { + if (error instanceof Error) { + if (niceStack) { + error.stack = niceStack.stack; + } + if (mode === 'fail') { + this.rec.expectationFailed(error); + } else if (mode === 'warn') { + this.rec.warn(error); + } else { + unreachable(); + } + } + }; + + if (Array.isArray(error)) { + for (const e of error) { + handleError(e); + } + } else { + handleError(error); + } + } + + eventualExpectOK(error, { mode = 'fail' } = {}) { + this.eventualAsyncExpectation(async niceStack => { + this.expectOK(await error, { mode, niceStack }); + }); + } +} diff --git a/testing/web-platform/mozilla/tests/webgpu/common/framework/params_builder.js b/testing/web-platform/mozilla/tests/webgpu/common/framework/params_builder.js new file mode 100644 index 0000000000..787911f964 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/framework/params_builder.js @@ -0,0 +1,213 @@ +/** + * AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts + **/ import { mergeParams } from '../internal/params_utils.js'; +import { stringifyPublicParams } from '../internal/query/stringify_params.js'; +import { assert, mapLazy } from '../util/util.js'; + +// ================================================================ +// "Public" ParamsBuilder API / Documentation +// ================================================================ + +/** + * Provides doc comments for the methods of CaseParamsBuilder and SubcaseParamsBuilder. + * (Also enforces rough interface match between them.) + */ + +/** + * Base class for `CaseParamsBuilder` and `SubcaseParamsBuilder`. + */ +export class ParamsBuilderBase { + constructor(cases) { + this.cases = cases; + } + + /** + * Hidden from test files. Use `builderIterateCasesWithSubcases` to access this. + */ +} + +/** + * Calls the (normally hidden) `iterateCasesWithSubcases()` method. + */ +export function builderIterateCasesWithSubcases(builder) { + return builder.iterateCasesWithSubcases(); +} + +/** + * Builder for combinatorial test **case** parameters. + * + * CaseParamsBuilder is immutable. Each method call returns a new, immutable object, + * modifying the list of cases according to the method called. + * + * This means, for example, that the `unit` passed into `TestBuilder.params()` can be reused. + */ +export class CaseParamsBuilder extends ParamsBuilderBase { + *iterateCasesWithSubcases() { + for (const a of this.cases()) { + yield [a, undefined]; + } + } + + [Symbol.iterator]() { + return this.cases(); + } + + /** @inheritDoc */ + expandWithParams(expander) { + const newGenerator = expanderGenerator(this.cases, expander); + return new CaseParamsBuilder(() => newGenerator({})); + } + + /** @inheritDoc */ + expand(key, expander) { + return this.expandWithParams(function* (p) { + for (const value of expander(p)) { + yield { [key]: value }; + } + }); + } + + /** @inheritDoc */ + combineWithParams(newParams) { + assertNotGenerator(newParams); + const seenValues = new Set(); + for (const params of newParams) { + const paramsStr = stringifyPublicParams(params); + assert(!seenValues.has(paramsStr), `Duplicate entry in combine[WithParams]: ${paramsStr}`); + seenValues.add(paramsStr); + } + + return this.expandWithParams(() => newParams); + } + + /** @inheritDoc */ + combine(key, values) { + assertNotGenerator(values); + const mapped = mapLazy(values, v => ({ [key]: v })); + return this.combineWithParams(mapped); + } + + /** @inheritDoc */ + filter(pred) { + const newGenerator = filterGenerator(this.cases, pred); + return new CaseParamsBuilder(() => newGenerator({})); + } + + /** @inheritDoc */ + unless(pred) { + return this.filter(x => !pred(x)); + } + + /** + * "Finalize" the list of cases and begin defining subcases. + * Returns a new SubcaseParamsBuilder. Methods called on SubcaseParamsBuilder + * generate new subcases instead of new cases. + */ + beginSubcases() { + return new SubcaseParamsBuilder( + () => this.cases(), + function* () { + yield {}; + } + ); + } +} + +/** + * The unit CaseParamsBuilder, representing a single case with no params: `[ {} ]`. + * + * `punit` is passed to every `.params()`/`.paramsSubcasesOnly()` call, so `kUnitCaseParamsBuilder` + * is only explicitly needed if constructing a ParamsBuilder outside of a test builder. + */ +export const kUnitCaseParamsBuilder = new CaseParamsBuilder(function* () { + yield {}; +}); + +/** + * Builder for combinatorial test _subcase_ parameters. + * + * SubcaseParamsBuilder is immutable. Each method call returns a new, immutable object, + * modifying the list of subcases according to the method called. + */ +export class SubcaseParamsBuilder extends ParamsBuilderBase { + constructor(cases, generator) { + super(cases); + this.subcases = generator; + } + + *iterateCasesWithSubcases() { + for (const caseP of this.cases()) { + const subcases = Array.from(this.subcases(caseP)); + if (subcases.length) { + yield [caseP, subcases]; + } + } + } + + /** @inheritDoc */ + expandWithParams(expander) { + return new SubcaseParamsBuilder(this.cases, expanderGenerator(this.subcases, expander)); + } + + /** @inheritDoc */ + expand(key, expander) { + return this.expandWithParams(function* (p) { + for (const value of expander(p)) { + // TypeScript doesn't know here that NewPKey is always a single literal string type. + yield { [key]: value }; + } + }); + } + + /** @inheritDoc */ + combineWithParams(newParams) { + assertNotGenerator(newParams); + return this.expandWithParams(() => newParams); + } + + /** @inheritDoc */ + combine(key, values) { + assertNotGenerator(values); + return this.expand(key, () => values); + } + + /** @inheritDoc */ + filter(pred) { + return new SubcaseParamsBuilder(this.cases, filterGenerator(this.subcases, pred)); + } + + /** @inheritDoc */ + unless(pred) { + return this.filter(x => !pred(x)); + } +} + +function expanderGenerator(baseGenerator, expander) { + return function* (base) { + for (const a of baseGenerator(base)) { + for (const b of expander(mergeParams(base, a))) { + yield mergeParams(a, b); + } + } + }; +} + +function filterGenerator(baseGenerator, pred) { + return function* (base) { + for (const a of baseGenerator(base)) { + if (pred(mergeParams(base, a))) { + yield a; + } + } + }; +} + +/** Assert an object is not a Generator (a thing returned from a generator function). */ +function assertNotGenerator(x) { + if ('constructor' in x) { + assert( + x.constructor !== (function* () {})().constructor, + 'Argument must not be a generator, as generators are not reusable' + ); + } +} diff --git a/testing/web-platform/mozilla/tests/webgpu/common/framework/resources.js b/testing/web-platform/mozilla/tests/webgpu/common/framework/resources.js new file mode 100644 index 0000000000..72eabeda4e --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/framework/resources.js @@ -0,0 +1,111 @@ +/** + * AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts + **/ /** + * Base path for resources. The default value is correct for non-worker WPT, but standalone and + * workers must access resources using a different base path, so this is overridden in + * `test_worker-worker.ts` and `standalone.ts`. + */ let baseResourcePath = './resources'; +let crossOriginHost = ''; + +function getAbsoluteBaseResourcePath(path) { + // Path is already an absolute one. + if (path[0] === '/') { + return path; + } + + // Path is relative + const relparts = window.location.pathname.split('/'); + relparts.pop(); + const pathparts = path.split('/'); + + let i; + for (i = 0; i < pathparts.length; ++i) { + switch (pathparts[i]) { + case '': + break; + case '.': + break; + case '..': + relparts.pop(); + break; + default: + relparts.push(pathparts[i]); + break; + } + } + + return relparts.join('/'); +} + +function runningOnLocalHost() { + const hostname = window.location.hostname; + return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1'; +} + +/** + * Get a path to a resource in the `resources` directory relative to the current execution context + * (html file or worker .js file), for `fetch()`, ``, `