Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add differential testing harness #216

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Conversation

LegNeato
Copy link
Collaborator

@LegNeato LegNeato commented Feb 4, 2025

The test harness compiles and runs Rust
shaders/kernels and compares the output with those produced by equivalent WGSL
shaders/kernels. Unlike traditional reference, golden, or snapshot tests—which check
against static outputs—differential testing compares two independent implementations.
This approach is more robust because discrepancies between them are more likely to
indicate real bugs rather than issues with outdated reference files.

You can run difftests via cargo difftest. This is an alias set up in .cargo/config
for cargo run --release -p difftest --. You can filter to run specific tests by
passing the (partial) filenames to cargo difftest some_file_name.

This runs wgsl shaders and rust shaders and compares the output.
If the output differs, the test fails. Differential testing is better
than snapshot testing or golden file testing as there are no reference
files to get outdated.

Note that we are only using wgpu for now, but I want to also vary
the host-side crate / use `ash`. At least we are using `wgpu`'s vulkan
support on linux, so we are not just testing naga's translation.
@LegNeato LegNeato marked this pull request as ready for review February 6, 2025 23:29
@LegNeato
Copy link
Collaborator Author

LegNeato commented Feb 6, 2025

I think I'd like eyes on this before I do a clean up in case people have major feedback.

@LegNeato
Copy link
Collaborator Author

Perhaps better DX is to have directories and just cargo run --release in each?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant