From 4e715a8b222d0a7cc35804580c9fd157ce5196bb Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 14 Sep 2023 18:29:20 -0700 Subject: [PATCH] Tests for wgpu#4139. --- tests/tests/query_set.rs | 23 +++++++++++++++++++++++ tests/tests/root.rs | 1 + 2 files changed, 24 insertions(+) create mode 100644 tests/tests/query_set.rs diff --git a/tests/tests/query_set.rs b/tests/tests/query_set.rs new file mode 100644 index 00000000000..d2592908ff8 --- /dev/null +++ b/tests/tests/query_set.rs @@ -0,0 +1,23 @@ +use wgpu_test::{initialize_test, TestParameters}; + +#[test] +fn drop_failed_timestamp_query_set() { + initialize_test(TestParameters::default(), |ctx| { + // Enter an error scope, so the validation catch-all doesn't + // report the error too early. + ctx.device.push_error_scope(wgpu::ErrorFilter::Validation); + + // Creating this query set should fail, since we didn't include + // TIMESTAMP_QUERY in our required features. + let bad_query_set = ctx.device.create_query_set(&wgpu::QuerySetDescriptor { + label: Some("doomed query set"), + ty: wgpu::QueryType::Timestamp, + count: 1, + }); + + // Dropping this should not panic. + drop(bad_query_set); + + assert!(pollster::block_on(ctx.device.pop_error_scope()).is_some()); + }); +} diff --git a/tests/tests/root.rs b/tests/tests/root.rs index 85901ae4919..b2695fd8275 100644 --- a/tests/tests/root.rs +++ b/tests/tests/root.rs @@ -20,6 +20,7 @@ mod instance; mod occlusion_query; mod partially_bounded_arrays; mod poll; +mod query_set; mod queue_transfer; mod resource_descriptor_accessor; mod resource_error;