Files
photocraft/crates/gpu/tests/it/init_timeout.rs
FredApps a348a2a460 test(gpu): treat an already-answered request as a skipped smoke check; test_gpu waits without limit
The zero-timeout smoke tests now skip, instead of failing, if the driver
answered first, whether with a success or an initialization error.
test_gpu waits for its timed-out request without a limit while it holds the
GPU lock. A request that never finishes then shows up as a slow test,
instead of the next GPU test starting beside it.

Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-18 16:31:19 +07:00

28 lines
1.2 KiB
Rust

//! A request that times out leaves its initialization thread inside the driver. The process must
//! be able to wait for that thread before it exits: exiting under it crashes Lavapipe, which is
//! how two passing headless GPU tests ended in a SIGSEGV on CI (#9824).
use std::sync::PoisonError;
use std::time::Duration;
use photocraft_gpu::{GpuContextError, NativeContext, NativeContextOptions};
use crate::GPU_LOCK;
#[test]
fn a_timed_out_request_can_be_waited_for_before_exit() {
let _gpu = GPU_LOCK.lock().unwrap_or_else(PoisonError::into_inner);
// `NativeContext::request` makes and drops an instance of its own; the kept one keeps the
// Vulkan loader from being torn down when it goes.
let _kept = crate::instance();
let opts = NativeContextOptions { timeout: Some(Duration::ZERO), ..Default::default() };
let res = NativeContext::request(&opts);
let Err(GpuContextError::TimedOut { pending, .. }) = &res else {
// The driver answered before the caller even waited: nothing was abandoned.
eprintln!("SKIPPED: the GPU request did not time out ({res:?})");
return;
};
assert!(pending.wait(Duration::from_secs(120)), "the abandoned initialization thread never finished");
assert!(pending.is_finished());
}