Repository navigation
Draft for discussion: auto-generated execution tests, found by mutation testing Mesa - #4720
Draft
ambergorzynski wants to merge 2 commits into
Draft
ambergorzynski wants to merge 2 commits into
ambergorzynski wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #4299
@afd and I have been working on generating CTS tests through mutation testing, which we discussed some time ago in #4299. This draft proposes a first batch of five tests, so we can agree on their form before generating more.
Recap
The idea: we deliberately mutate (i.e. introduce a small bug into) part of a WebGPU implementation or a downstream driver, and run the CTS against the mutated version. If no test fails, the CTS has a gap: it doesn't detect that change. We then use a WGSL fuzzer to find a shader that does fail on the mutated code, and propose adding it as a test, so that the CTS will catch future bugs in that part of the code.
Each test is a small fuzzer-generated program that the unmodified compiler runs correctly and the mutated one does not. For these five tests:
In the earlier discussion, @dneto0 made some helpful suggestions that we have incorporated here: the tests live in a separate bucket, organised by the implementation that was mutated, and each one has a machine-readable label saying what was mutated and where.
What the tests look like
The tests are in
src/webgpu/mutation/mesa/, in two files:no_input.spec.ts(shaders without an input buffer) anduniform_input.spec.ts(shaders that read a uniform buffer). Each test runs its shader once and compares the whole output buffer with the expected bytes. For example:As suggested:
webgpu:mutation,mesa,*).kMutations: git commits and the mutated source location. (generatedFrommarks a file that Mesa generates during the build.) TheMutationtype is shared, insrc/webgpu/mutation/mutation_info.ts.shader_10c2ef9cnir_constant_expressions.c, line 50895shader_101299f4nir_constant_expressions.c, line 48527shader_7ea91b04nir_range_analysis.c, line 1178shader_429a8325nir_constant_expressions.c, line 51437shader_7be24930nir_opt_if.c, line 839Questions
webgpu:mutation,mesa,*, as suggested by @dneto0. The alternative is a separate top-level tree,webgpu-mutation:*; the earlier discussion left this open.kMutationsformat useful? Each entry is written just above its test and collected in a table each file exports. Should it contain more or less detail, e.g. the mutation itself rather than just its line?new Float32Array([1, 1, 0, 0, 10, 10])for amat3x2<f32>), which is easier to read. Would you prefer the typed form?padding.spec.tsdoes? And if we move to typed values, should padding still be checked, or only the struct members?shader_<8 hex digits>), with a description naming the area of the mutation. Is there a naming scheme you'd prefer?+@afd