Skip to content

Commit df40889

Browse files
committed
Prepare for miri
1 parent f25a795 commit df40889

File tree

9 files changed

+32
-16
lines changed

9 files changed

+32
-16
lines changed

.config/nextest.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ slow-timeout = { period = "45s", terminate-after = 2 }
66
fail-fast = false
77
retries = 0
88

9+
[profile.default-miri]
10+
# Miri is very very slow, so give it a much longer timeout.
11+
slow-timeout = { period = "120s", terminate-after = 4 }
12+
913
# Use two threads for tests with "2 threads" in their name
1014
[[profile.default.overrides]]
1115
filter = 'test(~2_threads) | test(~2 threads)'

naga/tests/naga/example_wgsl.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use naga::{front::wgsl, valid::Validator};
44
use std::{ffi::OsStr, fs, path::Path};
55

66
/// Runs through all example shaders and ensures they are valid wgsl.
7+
// While we _can_ run this test under miri, it is extremely slow (>5 minutes),
8+
// and naga isn't the primary target for miri testing, so we disable it.
9+
#[cfg(not(miri))]
710
#[test]
811
pub fn parse_example_wgsl() {
912
let example_path = Path::new(env!("CARGO_MANIFEST_DIR"))

naga/tests/naga/snapshots.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,9 @@ fn write_output_wgsl(
818818
input.write_output_file("wgsl", "wgsl", string);
819819
}
820820

821-
#[cfg(feature = "wgsl-in")]
821+
// While we _can_ run this test under miri, it is extremely slow (>5 minutes),
822+
// and naga isn't the primary target for miri testing, so we disable it.
823+
#[cfg(all(feature = "wgsl-in", not(miri)))]
822824
#[test]
823825
fn convert_snapshots_wgsl() {
824826
let _ = env_logger::try_init();
@@ -843,7 +845,8 @@ fn convert_snapshots_wgsl() {
843845
}
844846
}
845847

846-
#[cfg(feature = "spv-in")]
848+
// miri doesn't allow us to shell out to `spirv-as`
849+
#[cfg(all(feature = "spv-in", not(miri)))]
847850
#[test]
848851
fn convert_snapshots_spv() {
849852
use std::process::Command;
@@ -892,7 +895,9 @@ fn convert_snapshots_spv() {
892895
}
893896
}
894897

895-
#[cfg(feature = "glsl-in")]
898+
// While we _can_ run this test under miri, it is extremely slow (>5 minutes),
899+
// and naga isn't the primary target for miri testing, so we disable it.
900+
#[cfg(all(feature = "glsl-in", not(miri)))]
896901
#[allow(unused_variables)]
897902
#[test]
898903
fn convert_snapshots_glsl() {

player/tests/player/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ impl Corpus {
245245
}
246246
}
247247

248+
#[cfg(not(miri))]
248249
#[test]
249250
fn test_api() {
250251
env_logger::init();

tests/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ trybuild.workspace = true
6767
# Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency.
6868
cargo_metadata.workspace = true
6969
env_logger.workspace = true
70-
nv-flip.workspace = true
7170
parking_lot = { workspace = true, features = ["deadlock_detection"] }
7271

72+
[target.'cfg(not(any(target_arch = "wasm32", miri)))'.dependencies]
73+
nv-flip.workspace = true
74+
7375
# Webassembly
7476
[target.'cfg(target_arch = "wasm32")'.dependencies]
7577
console_log.workspace = true

tests/src/image.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use wgpu::*;
77

88
use crate::TestingContext;
99

10-
#[cfg(not(target_arch = "wasm32"))]
10+
#[cfg(not(any(target_arch = "wasm32", miri)))]
1111
async fn read_png(path: impl AsRef<Path>, width: u32, height: u32) -> Option<Vec<u8>> {
1212
let data = match std::fs::read(&path) {
1313
Ok(f) => f,
@@ -45,7 +45,7 @@ async fn read_png(path: impl AsRef<Path>, width: u32, height: u32) -> Option<Vec
4545
Some(buffer)
4646
}
4747

48-
#[cfg(not(target_arch = "wasm32"))]
48+
#[cfg(not(any(target_arch = "wasm32", miri)))]
4949
async fn write_png(
5050
path: impl AsRef<Path>,
5151
width: u32,
@@ -64,15 +64,15 @@ async fn write_png(
6464
writer.write_image_data(data).unwrap();
6565
}
6666

67-
#[cfg_attr(target_arch = "wasm32", allow(unused))]
67+
#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))]
6868
fn add_alpha(input: &[u8]) -> Vec<u8> {
6969
input
7070
.chunks_exact(3)
7171
.flat_map(|chunk| [chunk[0], chunk[1], chunk[2], 255])
7272
.collect()
7373
}
7474

75-
#[cfg_attr(target_arch = "wasm32", allow(unused))]
75+
#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))]
7676
fn remove_alpha(input: &[u8]) -> Vec<u8> {
7777
input
7878
.chunks_exact(4)
@@ -81,7 +81,7 @@ fn remove_alpha(input: &[u8]) -> Vec<u8> {
8181
.collect()
8282
}
8383

84-
#[cfg(not(target_arch = "wasm32"))]
84+
#[cfg(not(any(target_arch = "wasm32", miri)))]
8585
fn print_flip(pool: &mut nv_flip::FlipPool) {
8686
println!("\tMean: {:.6}", pool.mean());
8787
println!("\tMin Value: {:.6}", pool.min_value());
@@ -115,7 +115,7 @@ pub enum ComparisonType {
115115
}
116116

117117
impl ComparisonType {
118-
#[cfg(not(target_arch = "wasm32"))]
118+
#[cfg(not(any(target_arch = "wasm32", miri)))]
119119
fn check(&self, pool: &mut nv_flip::FlipPool) -> bool {
120120
match *self {
121121
ComparisonType::Mean(v) => {
@@ -148,7 +148,7 @@ impl ComparisonType {
148148
}
149149
}
150150

151-
#[cfg(not(target_arch = "wasm32"))]
151+
#[cfg(not(any(target_arch = "wasm32", miri)))]
152152
pub async fn compare_image_output(
153153
path: impl AsRef<Path> + AsRef<OsStr>,
154154
adapter_info: &wgpu::AdapterInfo,
@@ -250,7 +250,7 @@ pub async fn compare_image_output(
250250
}
251251
}
252252

253-
#[cfg(target_arch = "wasm32")]
253+
#[cfg(any(target_arch = "wasm32", miri))]
254254
pub async fn compare_image_output(
255255
path: impl AsRef<Path> + AsRef<OsStr>,
256256
adapter_info: &wgpu::AdapterInfo,
@@ -259,13 +259,13 @@ pub async fn compare_image_output(
259259
test_with_alpha: &[u8],
260260
checks: &[ComparisonType],
261261
) {
262-
#[cfg(target_arch = "wasm32")]
262+
#[cfg(any(target_arch = "wasm32", miri))]
263263
{
264264
let _ = (path, adapter_info, width, height, test_with_alpha, checks);
265265
}
266266
}
267267

268-
#[cfg_attr(target_arch = "wasm32", allow(unused))]
268+
#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))]
269269
fn sanitize_for_path(s: &str) -> String {
270270
s.chars()
271271
.map(|ch| if ch.is_ascii_alphanumeric() { ch } else { '_' })

tests/tests/wgpu-compile/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(not(miri))]
12
// Tests that ensure that various constructs that should not compile do not compile.
23

34
#[test]

tests/tests/wgpu-dependency/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency.
22
// Since this test isn't dependent on the current architecture, we can just skip it on wasm without any issues.
3-
#![cfg(not(target_arch = "wasm32"))]
3+
#![cfg(not(any(target_arch = "wasm32", miri)))]
44

55
use std::process::Command;
66

tests/tests/wgpu-validation/api/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mod multi_instance {
2-
#![cfg(not(target_arch = "wasm32"))]
2+
#![cfg(not(any(target_arch = "wasm32", miri)))]
33

44
async fn get() -> wgpu::Adapter {
55
let adapter = {

0 commit comments

Comments
 (0)