//! The render node the hardware tests run on.
use std::path::PathBuf;
use std::sync::Arc;
use crate::Display;
/// The render node every hardware test opens, from `KODECS_VAAPI_DEVICE`.
///
/// Fixtures, encoders, and decoders share one node, so a DMA-BUF one makes is
/// importable by the next and each run exercises a single GPU. `just vaapi`
/// sets it to each Intel and AMD node in turn.
pub fn device() -> PathBuf {
match std::env::var_os("KODECS_VAAPI_DEVICE") {
Some(path) => PathBuf::from(path),
None => panic!("set KODECS_VAAPI_DEVICE to a render node, or run `just vaapi`"),
}
}
/// Opens [`device`].
pub fn display() -> Arc<Display> {
let device = device();
Display::open_drm_display(&device).unwrap_or_else(|err| panic!("open {}: {err}", device.display()))
}