Skip to content

Add support for miri to the codebase #7940

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

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ slow-timeout = { period = "45s", terminate-after = 2 }
fail-fast = false
retries = 0

[profile.default-miri]
# Miri is very very slow, so give it a much longer timeout.
slow-timeout = { period = "120s", terminate-after = 4 }

# Use two threads for tests with "2 threads" in their name
[[profile.default.overrides]]
filter = 'test(~2_threads) | test(~2 threads)'
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/big_compute_buffers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,4 @@ pub fn main() {

#[cfg(test)]
#[cfg(not(target_arch = "wasm32"))]
mod tests;
pub mod tests;
2 changes: 1 addition & 1 deletion examples/features/src/big_compute_buffers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;
use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters};

#[gpu_test]
static TWO_BUFFERS: GpuTestConfiguration = GpuTestConfiguration::new()
pub static TWO_BUFFERS: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
TestParameters::default()
.features(
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/boids/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "boids",
// Generated on 1080ti on Vk/Windows
image_path: "/examples/features/src/boids/screenshot.png",
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/bunnymark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "bunnymark",
image_path: "/examples/features/src/bunnymark/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/conservative_raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "conservative-raster",
image_path: "/examples/features/src/conservative_raster/screenshot.png",
width: 1024,
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/cube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "cube",
// Generated on 1080ti on Vk/Windows
image_path: "/examples/features/src/cube/screenshot.png",
Expand All @@ -397,7 +397,7 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_LINES: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_LINES: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "cube-lines",
// Generated on 1080ti on Vk/Windows
image_path: "/examples/features/src/cube/screenshot-lines.png",
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/hello_synchronization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ pub fn main() {
}

#[cfg(test)]
mod tests;
pub mod tests;
2 changes: 1 addition & 1 deletion examples/features/src/hello_synchronization/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::*;
use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters};

#[gpu_test]
static SYNC: GpuTestConfiguration = GpuTestConfiguration::new()
pub static SYNC: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
// Taken from hello-compute tests.
TestParameters::default()
Expand Down
50 changes: 49 additions & 1 deletion examples/features/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,52 @@ pub mod uniform_values;
pub mod water;

#[cfg(test)]
wgpu_test::gpu_test_main!();
fn all_tests() -> Vec<wgpu_test::GpuTestInitializer> {
#[cfg_attr(
target_arch = "wasm32",
expect(unused_mut, reason = "non-wasm32 needs this mutable")
)]
let mut test_list = vec![
boids::TEST,
bunnymark::TEST,
conservative_raster::TEST,
cube::TEST,
cube::TEST_LINES,
hello_synchronization::tests::SYNC,
mipmap::TEST,
mipmap::TEST_QUERY,
msaa_line::TEST,
multiple_render_targets::TEST,
ray_cube_compute::TEST,
ray_cube_fragment::TEST,
ray_cube_normals::TEST,
ray_scene::TEST,
ray_shadows::TEST,
ray_traced_triangle::TEST,
shadow::TEST,
skybox::TEST,
skybox::TEST_ASTC,
skybox::TEST_BCN,
skybox::TEST_ETC2,
srgb_blend::TEST_LINEAR,
srgb_blend::TEST_SRGB,
stencil_triangles::TEST,
texture_arrays::TEST,
texture_arrays::TEST_NON_UNIFORM,
texture_arrays::TEST_UNIFORM,
timestamp_queries::tests::TIMESTAMPS_ENCODER,
timestamp_queries::tests::TIMESTAMPS_PASSES,
timestamp_queries::tests::TIMESTAMPS_PASS_BOUNDARIES,
water::TEST,
];

#[cfg(not(target_arch = "wasm32"))]
{
test_list.push(big_compute_buffers::tests::TWO_BUFFERS);
}

test_list
}

#[cfg(test)]
wgpu_test::gpu_test_main!(all_tests());
4 changes: 2 additions & 2 deletions examples/features/src/mipmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "mipmap",
image_path: "/examples/features/src/mipmap/screenshot.png",
width: 1024,
Expand All @@ -521,7 +521,7 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_QUERY: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_QUERY: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "mipmap-query",
image_path: "/examples/features/src/mipmap/screenshot_query.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/msaa_line/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "msaa-line",
image_path: "/examples/features/src/msaa_line/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/multiple_render_targets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: EXAMPLE_NAME,
image_path: "/examples/features/src/multiple_render_targets/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/ray_cube_compute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "ray_cube_compute",
image_path: "/examples/features/src/ray_cube_compute/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/ray_cube_fragment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "ray_cube_fragment",
image_path: "/examples/features/src/ray_cube_fragment/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/ray_cube_normals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "ray_cube_normals",
image_path: "/examples/features/src/ray_cube_normals/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/ray_scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "ray_scene",
image_path: "/examples/features/src/ray_scene/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/ray_shadows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "ray_shadows",
image_path: "/examples/features/src/ray_shadows/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/ray_traced_triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "ray_traced_triangle",
image_path: "/examples/features/src/ray_traced_triangle/screenshot.png",
width: 1024,
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/shadow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "shadow",
image_path: "/examples/features/src/shadow/screenshot.png",
width: 1024,
Expand Down
8 changes: 4 additions & 4 deletions examples/features/src/skybox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "skybox",
image_path: "/examples/features/src/skybox/screenshot.png",
width: 1024,
Expand All @@ -485,7 +485,7 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_BCN: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_BCN: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "skybox-bc7",
image_path: "/examples/features/src/skybox/screenshot_bc7.png",
width: 1024,
Expand All @@ -498,7 +498,7 @@ static TEST_BCN: crate::framework::ExampleTestParams = crate::framework::Example

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_ETC2: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_ETC2: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "skybox-etc2",
image_path: "/examples/features/src/skybox/screenshot_etc2.png",
width: 1024,
Expand All @@ -511,7 +511,7 @@ static TEST_ETC2: crate::framework::ExampleTestParams = crate::framework::Exampl

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_ASTC: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_ASTC: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "skybox-astc",
image_path: "/examples/features/src/skybox/screenshot_astc.png",
width: 1024,
Expand Down
4 changes: 2 additions & 2 deletions examples/features/src/srgb_blend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_SRGB: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_SRGB: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "srgb-blend-srg",
// Generated on WARP/Windows
image_path: "/examples/features/src/srgb_blend/screenshot-srgb.png",
Expand All @@ -237,7 +237,7 @@ static TEST_SRGB: crate::framework::ExampleTestParams = crate::framework::Exampl

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_LINEAR: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST_LINEAR: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "srgb-blend-linear",
// Generated on WARP/Windows
image_path: "/examples/features/src/srgb_blend/screenshot-linear.png",
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/stencil_triangles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "stencil-triangles",
image_path: "/examples/features/src/stencil_triangles/screenshot.png",
width: 1024,
Expand Down
25 changes: 13 additions & 12 deletions examples/features/src/texture_arrays/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "texture-arrays",
image_path: "/examples/features/src/texture_arrays/screenshot.png",
width: 1024,
Expand All @@ -444,20 +444,21 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_UNIFORM: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "texture-arrays-uniform",
image_path: "/examples/features/src/texture_arrays/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::empty(),
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[wgpu_test::ComparisonType::Mean(0.0)],
_phantom: std::marker::PhantomData::<Example>,
};
pub static TEST_UNIFORM: crate::framework::ExampleTestParams =
crate::framework::ExampleTestParams {
name: "texture-arrays-uniform",
image_path: "/examples/features/src/texture_arrays/screenshot.png",
width: 1024,
height: 768,
optional_features: wgpu::Features::empty(),
base_test_parameters: wgpu_test::TestParameters::default(),
comparisons: &[wgpu_test::ComparisonType::Mean(0.0)],
_phantom: std::marker::PhantomData::<Example>,
};

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST_NON_UNIFORM: crate::framework::ExampleTestParams =
pub static TEST_NON_UNIFORM: crate::framework::ExampleTestParams =
crate::framework::ExampleTestParams {
name: "texture-arrays-non-uniform",
image_path: "/examples/features/src/texture_arrays/screenshot.png",
Expand Down
8 changes: 4 additions & 4 deletions examples/features/src/timestamp_queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,13 @@ pub fn main() {
}

#[cfg(test)]
mod tests {
pub mod tests {
use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration};

use super::{submit_render_and_compute_pass_with_queries, QueryResults};

#[gpu_test]
static TIMESTAMPS_PASS_BOUNDARIES: GpuTestConfiguration = GpuTestConfiguration::new()
pub static TIMESTAMPS_PASS_BOUNDARIES: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
wgpu_test::TestParameters::default()
.limits(wgpu::Limits::downlevel_defaults())
Expand All @@ -441,7 +441,7 @@ mod tests {
.run_sync(|ctx| test_timestamps(ctx, false, false));

#[gpu_test]
static TIMESTAMPS_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new()
pub static TIMESTAMPS_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
wgpu_test::TestParameters::default()
.limits(wgpu::Limits::downlevel_defaults())
Expand All @@ -455,7 +455,7 @@ mod tests {
.run_sync(|ctx| test_timestamps(ctx, true, false));

#[gpu_test]
static TIMESTAMPS_PASSES: GpuTestConfiguration = GpuTestConfiguration::new()
pub static TIMESTAMPS_PASSES: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
wgpu_test::TestParameters::default()
.limits(wgpu::Limits::downlevel_defaults())
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/water/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ pub fn main() {

#[cfg(test)]
#[wgpu_test::gpu_test]
static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
pub static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
name: "water",
image_path: "/examples/features/src/water/screenshot.png",
width: 1024,
Expand Down
3 changes: 3 additions & 0 deletions naga/tests/naga/example_wgsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use naga::{front::wgsl, valid::Validator};
use std::{ffi::OsStr, fs, path::Path};

/// Runs through all example shaders and ensures they are valid wgsl.
// While we _can_ run this test under miri, it is extremely slow (>5 minutes),
// and naga isn't the primary target for miri testing, so we disable it.
#[cfg_attr(miri, ignore)]
#[test]
pub fn parse_example_wgsl() {
let example_path = Path::new(env!("CARGO_MANIFEST_DIR"))
Expand Down
Loading