From 92bd1ce2e0450bb314f796fea5511a1dfaed6e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 04:39:23 +0300 Subject: [PATCH] ec-av1-syntax: streams test reads ec_testkit bitstreams fixtures and ffprobe; missing fixtures fail instead of skipping --- Cargo.lock | 1 + crates/ec-av1-syntax/Cargo.toml | 3 ++ crates/ec-av1-syntax/tests/streams.rs | 48 +++++---------------------- 3 files changed, 13 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe04af07..b16036fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -384,6 +384,7 @@ name = "ec-av1-syntax" version = "0.1.0" dependencies = [ "ec-core", + "ec-testkit", ] [[package]] diff --git a/crates/ec-av1-syntax/Cargo.toml b/crates/ec-av1-syntax/Cargo.toml index c85a3976..cf309a86 100644 --- a/crates/ec-av1-syntax/Cargo.toml +++ b/crates/ec-av1-syntax/Cargo.toml @@ -8,3 +8,6 @@ authors.workspace = true [dependencies] ec-core.workspace = true + +[dev-dependencies] +ec-testkit.workspace = true diff --git a/crates/ec-av1-syntax/tests/streams.rs b/crates/ec-av1-syntax/tests/streams.rs index 18bf7657..8e7c2db7 100644 --- a/crates/ec-av1-syntax/tests/streams.rs +++ b/crates/ec-av1-syntax/tests/streams.rs @@ -1,19 +1,13 @@ //! Every AV1 fixture stream parsed end to end, field-compared against ffprobe. //! //! `scripts/gen-bitstream-fixtures.sh` remuxes the container fixtures to IVF and -//! encodes the branch cases (4:4:4, monochrome, tiles, hidden ALTREF). Fixtures -//! are gitignored, so a checkout without them skips rather than fails. +//! encodes the branch cases (4:4:4, monochrome, tiles, hidden ALTREF). use std::path::{Path, PathBuf}; -use std::process::Command; use ec_av1_syntax::{Av1Parser, FrameType, ObuKind}; use ec_core::Error; -fn bitstreams() -> PathBuf { - Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams") -} - /// The IVF frames of a file — for AV1, each is one temporal unit. fn ivf_frames(data: &[u8]) -> Vec<&[u8]> { let mut out = Vec::new(); @@ -31,7 +25,7 @@ fn ivf_frames(data: &[u8]) -> Vec<&[u8]> { } fn ffprobe(path: &Path, entries: &str) -> Vec { - let out = Command::new("ffprobe") + let out = ec_testkit::ffprobe() .args(["-v", "error", "-select_streams", "v:0", "-show_entries"]) .arg(entries) .args(["-of", "csv=p=0"]) @@ -89,19 +83,13 @@ fn pix_fmt_geometry(pix_fmt: &str) -> (u8, bool, u8, u8) { } fn fixtures() -> Vec { - let Ok(entries) = std::fs::read_dir(bitstreams()) else { - return Vec::new(); - }; - let mut files: Vec = entries - .filter_map(|e| e.ok().map(|e| e.path())) + ec_testkit::fixtures("bitstreams", "ivf") + .into_iter() .filter(|p| { - p.extension().is_some_and(|e| e == "ivf") - && p.file_name() - .is_some_and(|n| n.to_string_lossy().starts_with("av1-")) + p.file_name() + .is_some_and(|n| n.to_string_lossy().starts_with("av1-")) }) - .collect(); - files.sort(); - files + .collect() } /// One pass over a stream: what the parser saw. @@ -117,14 +105,7 @@ struct Tally { #[test] fn every_fixture_matches_ffprobe() { - let files = fixtures(); - if files.is_empty() { - eprintln!( - "skipped: no fixtures/bitstreams/av1-*.ivf — run scripts/gen-bitstream-fixtures.sh" - ); - return; - } - for path in files { + for path in fixtures() { let name = path.file_name().unwrap().to_string_lossy().to_string(); let (width, height, pix_fmt, profile) = probe_stream(&path); let (bit_depth, mono, sx, sy) = pix_fmt_geometry(&pix_fmt); @@ -236,11 +217,7 @@ fn every_fixture_matches_ffprobe() { /// cannot prove. #[test] fn altref_fixture_has_hidden_frames_and_show_existing() { - let path = bitstreams().join("av1-altref.ivf"); - if !path.exists() { - eprintln!("skipped: no av1-altref.ivf"); - return; - } + let path = ec_testkit::fixture("bitstreams/av1-altref.ivf"); let data = std::fs::read(&path).unwrap(); let mut parser = Av1Parser::new(); let (mut hidden, mut show_existing, mut showable) = (0usize, 0usize, 0usize); @@ -287,13 +264,6 @@ fn fuzz_10k_mutations_never_panics() { .collect::>() }) .collect(); - let seeds = if seeds.is_empty() { - vec![vec![ - 0x0au8, 0x0b, 0x00, 0x00, 0x00, 0x24, 0xcf, 0x7f, 0x0d, 0xbf, 0xff, 0x30, 0x08, - ]] - } else { - seeds - }; let mut state = 0x9e37_79b9_7f4a_7c15u64; let mut rng = move || {