From 91c13355d94321e04d7e7ae0c983027001e0c5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 1 Sep 2026 21:50:33 +0300 Subject: [PATCH] fix(av1): have_ffmpeg() SKIPped green under EC_AV1_REQUIRE_AOMENC=1 Every real-aomenc gate opens `if !have_ffmpeg() || !have_aomenc()`, and only have_aomenc() asserted under the require flag -- have_ffmpeg() is evaluated first and short-circuits, so a machine without ffmpeg printed SKIP and the whole 20-gate batch reported green with the require flag set (class gate-skips-on-its-own-failure). have_ffmpeg() now mirrors have_aomenc(): absence panics when EC_AV1_REQUIRE_FFMPEG=1 or EC_AV1_REQUIRE_AOMENC=1 is set (an aomenc gate decodes its stream through ffmpeg, so requiring the oracle implies requiring ffmpeg). Applied to all five copies of the helper (stream/tile/decode/encode/encoder test modules), which had the same silent-false shape. --- crates/ec-av1/src/decode.rs | 18 ++++++++++++++++-- crates/ec-av1/src/encode.rs | 18 ++++++++++++++++-- crates/ec-av1/src/encoder.rs | 18 ++++++++++++++++-- crates/ec-av1/src/stream.rs | 18 ++++++++++++++++-- crates/ec-av1/src/tile.rs | 18 ++++++++++++++++-- 5 files changed, 80 insertions(+), 10 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index a382326b..86c7cf41 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -13682,13 +13682,27 @@ mod tests { use std::io::Write; use std::process::{Command, Stdio}; + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes one AV1 OBU stream with ffmpeg and hands back its one 4:2:0 diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index b84fdf92..2c12a1e7 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -3063,13 +3063,27 @@ mod tests { use std::io::Write; use std::process::{Command, Stdio}; + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes an AV1 OBU stream with ffmpeg and hands back the three planes. diff --git a/crates/ec-av1/src/encoder.rs b/crates/ec-av1/src/encoder.rs index 06b07c32..0aabdf12 100644 --- a/crates/ec-av1/src/encoder.rs +++ b/crates/ec-av1/src/encoder.rs @@ -362,13 +362,27 @@ mod tests { use super::*; use std::process::{Command, Stdio}; + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } fn test_card(width: usize, height: usize, shift: usize) -> Picture { diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 20dbbc98..f1595d1d 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -867,13 +867,27 @@ mod tests { hash } + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes `frames` concatenated 4:2:0 frames out of one AV1 OBU stream. diff --git a/crates/ec-av1/src/tile.rs b/crates/ec-av1/src/tile.rs index ab0b3b7c..60fcc201 100644 --- a/crates/ec-av1/src/tile.rs +++ b/crates/ec-av1/src/tile.rs @@ -2983,13 +2983,27 @@ mod tests { } } + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes an AV1 OBU stream with ffmpeg and hands back the planes.