fix(tests): make the platform-specific suites portable and deterministic

Four independent CI failures the first real cross-platform run surfaced:

- macOS SIGSEGV: the real-GL unit tests in gl_bridge ran wherever CGL is
  available, including the headless CI runner. Gate them with the same
  OAK_GPU_TESTS switch the integration GL tests already use (skip on CI,
  opt in on a real Mac).
- Windows build: examples compile under `cargo test`, and bench_playback
  used libc::getrusage unconditionally. Keep the Unix CPU accounting
  behind #[cfg(unix)] and report zero CPU seconds elsewhere.
- openKylin arm64: engine_without_a_project_hits_the_guard_paths assumed
  the library backend was unconfigured while a parallel config test
  transiently set Storage/Backend=sqlite. Take the shared config lock and
  pin the key off for the test's duration.
- openKylin x64: the prefetch smoke test asserted an exact decode count,
  but the hand-off LRU holds only DECODE_LRU_CAP (2) frames, so a request
  can miss the prefetched copy under scheduling pressure and re-run the
  producer (the eval cache still serves the pixels). Bound the count
  instead of pinning it; the deterministic sibling test pins read-ahead
  usage.
This commit is contained in:
2026-09-24 14:45:12 +08:00
parent 21dbde8435
commit b13ef477a8
4 changed files with 45 additions and 4 deletions
+9
View File
@@ -801,7 +801,16 @@ mod tests {
use crate::render::VideoParams;
/// GL 不可用时 skip(无 GPU 无头环境);可用时返回 guard。
///
/// macOS 的真实 CGL 验收与集成 GL 测试同一门禁:CI 无头且用例并行,
/// 默认只做可用性探测;设 `OAK_GPU_TESTS=1` 才跑真实 GL 用例
/// (`crates/oak-plugin/tests/gl_render_test.rs` 同约定)。
fn maybe_gl() -> Option<GlGuard> {
#[cfg(target_os = "macos")]
if std::env::var_os("OAK_GPU_TESTS").is_none() {
println!("SKIP: 真实 GL 桥用例需 OAK_GPU_TESTS(本机 GPU 验收;CI 一律跳过)");
return None;
}
match acquire() {
Ok(g) => Some(g),
Err(e) => {