From cfb84748bf31612719de2e128cb69955193680db Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Wed, 23 Jun 2021 20:47:35 -0400 Subject: [PATCH] Exclude llvmpipe due to segfaults --- wgpu/examples/cube/main.rs | 7 ++++++- wgpu/tests/common/mod.rs | 37 +++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/wgpu/examples/cube/main.rs b/wgpu/examples/cube/main.rs index f0a41e1d4f..3ea3d4fc3c 100644 --- a/wgpu/examples/cube/main.rs +++ b/wgpu/examples/cube/main.rs @@ -400,7 +400,12 @@ fn cube_lines() { width: 1024, height: 768, optional_features: wgpu::Features::NON_FILL_POLYGON_MODE, - base_test_parameters: framework::test_common::TestParameters::default(), + base_test_parameters: framework::test_common::TestParameters::default().specific_failure( + Some(wgpu::BackendBit::VULKAN), + None, + Some("llvmpipe"), + true, + ), tollerance: 2, max_outliers: 400, // Line rasterization is very different between vendors }); diff --git a/wgpu/tests/common/mod.rs b/wgpu/tests/common/mod.rs index 3c5e215aba..4b4422a5ed 100644 --- a/wgpu/tests/common/mod.rs +++ b/wgpu/tests/common/mod.rs @@ -76,7 +76,12 @@ pub struct TestParameters { pub required_limits: Limits, pub required_downlevel_properties: DownlevelCapabilities, // Backends where test should fail. - pub failures: Vec<(Option, Option, Option)>, + pub failures: Vec<( + Option, + Option, + Option, + bool, + )>, } impl Default for TestParameters { @@ -120,31 +125,35 @@ impl TestParameters { /// Mark the test as always failing, equivilant to specific_failure(None, None, None) pub fn failure(mut self) -> Self { - self.failures.push((None, None, None)); + self.failures.push((None, None, None, false)); self } /// Mark the test as always failing on a specific backend, equivilant to specific_failure(backend, None, None) pub fn backend_failures(mut self, backends: wgpu::BackendBit) -> Self { - self.failures.push((Some(backends), None, None)); + self.failures.push((Some(backends), None, None, false)); self } /// Determines if a test should fail under a particular set of conditions. If any of these are None, that means that it will match anything in that field. /// /// ex. - /// `specific_failure(Some(wgpu::BackendBit::DX11 | wgpu::BackendBit::DX12), None, Some("RTX"))` + /// `specific_failure(Some(wgpu::BackendBit::DX11 | wgpu::BackendBit::DX12), None, Some("RTX"), false)` /// means that this test will fail on all cards with RTX in their name on either D3D backend, no matter the vendor ID. + /// + /// If segfault is set to true, the test won't be run at all due to avoid segfaults. pub fn specific_failure( mut self, backends: Option, vendor: Option, device: Option<&'static str>, + segfault: bool, ) -> Self { self.failures.push(( backends, vendor, device.as_ref().map(AsRef::as_ref).map(str::to_lowercase), + segfault, )); self } @@ -212,10 +221,8 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te queue, }; - let panicked = catch_unwind(AssertUnwindSafe(|| test_function(context))).is_err(); - let failure_reason = parameters.failures.iter().find_map( - |(backend_failure, vendor_failure, adapter_failure)| { + |(backend_failure, vendor_failure, adapter_failure, segfault)| { let always = backend_failure.is_none() && vendor_failure.is_none() && adapter_failure.is_none(); @@ -232,13 +239,13 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te if expect_failure_backend && expect_failure_vendor && expect_failure_adapter { if always { - Some(FailureReason::ALWAYS) + Some((FailureReason::ALWAYS, *segfault)) } else { let mut reason = FailureReason::empty(); reason.set(FailureReason::BACKEND, expect_failure_backend); reason.set(FailureReason::VENDOR, expect_failure_vendor); reason.set(FailureReason::ADAPTER, expect_failure_adapter); - Some(reason) + Some((reason, *segfault)) } } else { None @@ -246,11 +253,21 @@ pub fn initialize_test(parameters: TestParameters, test_function: impl FnOnce(Te }, ); + if let Some((reason, true)) = failure_reason { + println!( + "EXPECTED TEST FAILURE SKIPPED DUE TO SEGFAULT: {:?}", + reason + ); + return; + } + + let panicked = catch_unwind(AssertUnwindSafe(|| test_function(context))).is_err(); + let expect_failure = failure_reason.is_some(); if panicked == expect_failure { // We got the conditions we expected - if let Some(reason) = failure_reason { + if let Some((reason, _)) = failure_reason { // Print out reason for the failure println!("GOT EXPECTED TEST FAILURE: {:?}", reason); }