From cfef9d8e25a35bd991a70637b095fbf364b865b4 Mon Sep 17 00:00:00 2001 From: emirduran707 Date: Tue, 24 Nov 2026 21:54:57 +0300 Subject: [PATCH] Tests: XCL_REQUIRE_GPU does not fail the heap-window skip (#1651) Heap windows are opt-in (XCL_HEAP_WINDOWS=1), so the skip of heap_window_out_of_memory_falls_back_to_the_switch_form without them is no missing GPU coverage, but skip_test turned it into a panic under XCL_REQUIRE_GPU=mesh or =wave64 on every GPU, and cargo stopped before the later test binaries. The rule moves into skip_fails, which leaves opt-in reasons out, with a unit test. Fixes #1651 Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/gpu/recomp/runner.rs | 43 ++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index f647dbd2c6..d3f768dfae 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -454,23 +454,33 @@ pub fn mesh_shaders_supported() -> Result { /// "no wave64", "no mesh shaders": `SKIPPED : ` written to stderr itself, so the /// line shows without `--nocapture` (libtest captures only `print!` / `eprint!`), and /// `scripts/test.ps1` counts them. `XCL_REQUIRE_GPU=wave64` or `=mesh` (or both, comma-separated) -/// turns a skip that leaves that coverage out into a failure. +/// turns a skip that leaves that coverage out into a failure; "no heap windows" (an opt-in left off) +/// never is. pub fn skip_test(reason: &str) { use std::io::Write; let thread = std::thread::current(); let test = thread.name().unwrap_or("?"); let required = std::env::var("XCL_REQUIRE_GPU").unwrap_or_default(); - let fails = required.split(',').map(str::trim).any(|r| match r { - "wave64" => reason != "no mesh shaders", - "mesh" => reason != "no wave64", - _ => false, - }); - if fails { + if skip_fails(&required, reason) { panic!("{test}: {reason}, but XCL_REQUIRE_GPU={required}"); } let _ = writeln!(std::io::stderr(), "SKIPPED {test}: {reason}"); } +/// Skip reasons that name an opt-in feature left off (`XCL_HEAP_WINDOWS` unset), not something +/// the adapter lacks: `XCL_REQUIRE_GPU` does not turn them into failures. +const OPT_IN_SKIPS: &[&str] = &["no heap windows"]; + +/// Whether `XCL_REQUIRE_GPU=` turns a skip for `reason` into a failure. +fn skip_fails(required: &str, reason: &str) -> bool { + !OPT_IN_SKIPS.contains(&reason) + && required.split(',').map(str::trim).any(|r| match r { + "wave64" => reason != "no mesh shaders", + "mesh" => reason != "no wave64", + _ => false, + }) +} + /// Run a compiled kernel (DXIL) with `state` and flat memory `mem`. pub fn run(dxil: &[u8], state: &KernelState, mem: &[u32]) -> Result { run_with(dxil, state, mem, &[], &[]) @@ -1593,3 +1603,22 @@ fn dispatch_with( Ok((out, ms)) } } + +#[cfg(test)] +mod tests { + use super::skip_fails; + + /// An opt-in feature left off is no missing GPU coverage: `XCL_REQUIRE_GPU` fails the skips + /// for missing hardware, not the heap-window test's skip without `XCL_HEAP_WINDOWS=1` (#1651). + #[test] + fn required_gpu_fails_missing_hardware_not_opt_in_features() { + for required in ["mesh", "wave64", "wave64,mesh"] { + assert!(!skip_fails(required, "no heap windows"), "XCL_REQUIRE_GPU={required}"); + assert!(skip_fails(required, "no GPU"), "XCL_REQUIRE_GPU={required}"); + } + assert!(!skip_fails("mesh", "no wave64")); + assert!(!skip_fails("wave64", "no mesh shaders")); + assert!(skip_fails("wave64,mesh", "no wave64")); + assert!(!skip_fails("", "no GPU")); + } +}