mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Prepare for miri
This commit is contained in:
parent
f25a79595a
commit
df40889e1b
@ -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)'
|
||||
|
||||
@ -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(not(miri))]
|
||||
#[test]
|
||||
pub fn parse_example_wgsl() {
|
||||
let example_path = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
|
||||
@ -818,7 +818,9 @@ fn write_output_wgsl(
|
||||
input.write_output_file("wgsl", "wgsl", string);
|
||||
}
|
||||
|
||||
#[cfg(feature = "wgsl-in")]
|
||||
// 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(all(feature = "wgsl-in", not(miri)))]
|
||||
#[test]
|
||||
fn convert_snapshots_wgsl() {
|
||||
let _ = env_logger::try_init();
|
||||
@ -843,7 +845,8 @@ fn convert_snapshots_wgsl() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "spv-in")]
|
||||
// miri doesn't allow us to shell out to `spirv-as`
|
||||
#[cfg(all(feature = "spv-in", not(miri)))]
|
||||
#[test]
|
||||
fn convert_snapshots_spv() {
|
||||
use std::process::Command;
|
||||
@ -892,7 +895,9 @@ fn convert_snapshots_spv() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "glsl-in")]
|
||||
// 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(all(feature = "glsl-in", not(miri)))]
|
||||
#[allow(unused_variables)]
|
||||
#[test]
|
||||
fn convert_snapshots_glsl() {
|
||||
|
||||
@ -245,6 +245,7 @@ impl Corpus {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(miri))]
|
||||
#[test]
|
||||
fn test_api() {
|
||||
env_logger::init();
|
||||
|
||||
@ -67,9 +67,11 @@ trybuild.workspace = true
|
||||
# Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency.
|
||||
cargo_metadata.workspace = true
|
||||
env_logger.workspace = true
|
||||
nv-flip.workspace = true
|
||||
parking_lot = { workspace = true, features = ["deadlock_detection"] }
|
||||
|
||||
[target.'cfg(not(any(target_arch = "wasm32", miri)))'.dependencies]
|
||||
nv-flip.workspace = true
|
||||
|
||||
# Webassembly
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
console_log.workspace = true
|
||||
|
||||
@ -7,7 +7,7 @@ use wgpu::*;
|
||||
|
||||
use crate::TestingContext;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
async fn read_png(path: impl AsRef<Path>, width: u32, height: u32) -> Option<Vec<u8>> {
|
||||
let data = match std::fs::read(&path) {
|
||||
Ok(f) => f,
|
||||
@ -45,7 +45,7 @@ async fn read_png(path: impl AsRef<Path>, width: u32, height: u32) -> Option<Vec
|
||||
Some(buffer)
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
async fn write_png(
|
||||
path: impl AsRef<Path>,
|
||||
width: u32,
|
||||
@ -64,7 +64,7 @@ async fn write_png(
|
||||
writer.write_image_data(data).unwrap();
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", allow(unused))]
|
||||
#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))]
|
||||
fn add_alpha(input: &[u8]) -> Vec<u8> {
|
||||
input
|
||||
.chunks_exact(3)
|
||||
@ -72,7 +72,7 @@ fn add_alpha(input: &[u8]) -> Vec<u8> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", allow(unused))]
|
||||
#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))]
|
||||
fn remove_alpha(input: &[u8]) -> Vec<u8> {
|
||||
input
|
||||
.chunks_exact(4)
|
||||
@ -81,7 +81,7 @@ fn remove_alpha(input: &[u8]) -> Vec<u8> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
fn print_flip(pool: &mut nv_flip::FlipPool) {
|
||||
println!("\tMean: {:.6}", pool.mean());
|
||||
println!("\tMin Value: {:.6}", pool.min_value());
|
||||
@ -115,7 +115,7 @@ pub enum ComparisonType {
|
||||
}
|
||||
|
||||
impl ComparisonType {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
fn check(&self, pool: &mut nv_flip::FlipPool) -> bool {
|
||||
match *self {
|
||||
ComparisonType::Mean(v) => {
|
||||
@ -148,7 +148,7 @@ impl ComparisonType {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
pub async fn compare_image_output(
|
||||
path: impl AsRef<Path> + AsRef<OsStr>,
|
||||
adapter_info: &wgpu::AdapterInfo,
|
||||
@ -250,7 +250,7 @@ pub async fn compare_image_output(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(any(target_arch = "wasm32", miri))]
|
||||
pub async fn compare_image_output(
|
||||
path: impl AsRef<Path> + AsRef<OsStr>,
|
||||
adapter_info: &wgpu::AdapterInfo,
|
||||
@ -259,13 +259,13 @@ pub async fn compare_image_output(
|
||||
test_with_alpha: &[u8],
|
||||
checks: &[ComparisonType],
|
||||
) {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(any(target_arch = "wasm32", miri))]
|
||||
{
|
||||
let _ = (path, adapter_info, width, height, test_with_alpha, checks);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", allow(unused))]
|
||||
#[cfg_attr(any(target_arch = "wasm32", miri), allow(unused))]
|
||||
fn sanitize_for_path(s: &str) -> String {
|
||||
s.chars()
|
||||
.map(|ch| if ch.is_ascii_alphanumeric() { ch } else { '_' })
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#![cfg(not(miri))]
|
||||
// Tests that ensure that various constructs that should not compile do not compile.
|
||||
|
||||
#[test]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Cargo-metadata doesn't compile on wasm due to old cargo-util-schemas dependency.
|
||||
// Since this test isn't dependent on the current architecture, we can just skip it on wasm without any issues.
|
||||
#![cfg(not(target_arch = "wasm32"))]
|
||||
#![cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
mod multi_instance {
|
||||
#![cfg(not(target_arch = "wasm32"))]
|
||||
#![cfg(not(any(target_arch = "wasm32", miri)))]
|
||||
|
||||
async fn get() -> wgpu::Adapter {
|
||||
let adapter = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user