forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/w0-m5' into simplify/w0

Browse files at this commit

d60b2a63dc4c919cad87dd3efbe80f070abfedebAhmet Kaan GümüşParent: 7eb6d34fde442f
Cargo.lockmodified+3 -0
@@ -764,6 +764,7 @@ dependencies = [
764764 "archmage",
765765 "bytemuck",
766766 "ec-core",
767+ "ec-testkit",
767768 "multiversion",
768769 ]
769770
@@ -772,6 +773,7 @@ name = "ec-vp9"
772773 version = "0.1.0"
773774 dependencies = [
774775 "ec-core",
776+ "ec-testkit",
775777 "ec-vp9-syntax",
776778 ]
777779
@@ -780,6 +782,7 @@ name = "ec-vp9-syntax"
780782 version = "0.1.0"
781783 dependencies = [
782784 "ec-core",
785+ "ec-testkit",
783786 ]
784787
785788 [[package]]
crates/ec-vp8/Cargo.tomlmodified+3 -0
@@ -11,3 +11,6 @@ archmage = "=0.9.31-beta.1"
1111 bytemuck = "1"
1212 ec-core.workspace = true
1313 multiversion = "0.9"
14+
15+[dev-dependencies]
16+ec-testkit.workspace = true
crates/ec-vp8/fuzz/seed.shmodified+1 -2
@@ -5,13 +5,12 @@
55 # into corpus/decode_frame/. Whole IVF files up to 256 KiB go into corpus/decode_ivf/, and
66 # a 10-frame prefix of every larger file too. The corpus is generated, not committed.
77 #
8-# Usage: crates/ec-vp8/fuzz/seed.sh (from any directory; needs python3 and the fixtures/ link)
98 set -euo pipefail
109 here=$(cd -- "$(dirname -- "$0")" && pwd)
1110 repo=$(cd -- "$here/../../.." && pwd)
1211 rm -rf "$here/corpus"
1312 mkdir -p "$here/corpus/decode_frame" "$here/corpus/decode_ivf"
14-exec python3 -I - "$here" "decode_ivf" "$repo/fixtures/vp8/*.ivf" <<'PY'
13+exec python3 -I - "$here" "decode_ivf" "${EC_FIXTURES:-$repo/fixtures}/vp8/*.ivf" <<'PY'
1514 import glob, os, struct, sys
1615
1716 here, stream_target = sys.argv[1], sys.argv[2]
crates/ec-vp8/tests/it/common.rsmodified+2 -9
@@ -76,21 +76,14 @@ pub fn webp_vp8_chunk(bytes: &[u8]) -> Vec<u8> {
7676 panic!("no VP8 chunk in webp");
7777 }
7878
79-/// Root of the workspace checkout this test runs in (crates/ec-vp8/../..).
80-pub fn fixture_dir() -> Option<std::path::PathBuf> {
81- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp8");
82- if dir.is_dir() { Some(dir) } else { None }
83-}
84-
8579 /// ffmpeg's decoded rawvideo byte stream for an IVF file.
86-#[allow(dead_code)] // the malformed-input binary does not compare against ffmpeg
8780 pub fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
88- let out = std::process::Command::new("ffmpeg")
81+ let out = ec_testkit::ffmpeg()
8982 .args(["-v", "error", "-i"])
9083 .arg(path)
9184 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
9285 .output()
93- .expect("ffmpeg must be on PATH for the witnesses");
86+ .expect("ffmpeg runs");
9487 assert!(out.status.success(), "ffmpeg failed on {path:?}");
9588 out.stdout
9689 }
crates/ec-vp8/tests/it/header_parse.rsmodified+4 -16
@@ -18,11 +18,8 @@ const FIXTURES: &[(&str, u16, u16)] = &[
1818
1919 #[test]
2020 fn parses_real_key_frame_headers() {
21- let Some(dir) = common::fixture_dir() else {
22- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
23- };
2421 for (name, width, height) in FIXTURES {
25- let bytes = std::fs::read(dir.join(name)).unwrap();
22+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp8/{name}"))).unwrap();
2623 let (fourcc, w, h, frames) = common::parse_ivf(&bytes);
2724 assert_eq!(fourcc, "VP80", "{name}");
2825 assert_eq!((w, h), (*width, *height), "{name} IVF dimensions");
@@ -74,10 +71,7 @@ fn parses_real_key_frame_headers() {
7471
7572 #[test]
7673 fn parses_multi_partition_header() {
77- let Some(dir) = common::fixture_dir() else {
78- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
79- };
80- let bytes = std::fs::read(dir.join("mparts-160x96.ivf")).unwrap();
74+ let bytes = std::fs::read(ec_testkit::fixture("vp8/mparts-160x96.ivf")).unwrap();
8175 let (_, _, _, frames) = common::parse_ivf(&bytes);
8276 let mut state = PersistedState::default();
8377 let (header, _) = FrameHeader::parse(&frames[0].data, &mut state).unwrap();
@@ -89,10 +83,7 @@ fn parses_multi_partition_header() {
8983
9084 #[test]
9185 fn parses_vp8_in_webp_still() {
92- let Some(dir) = common::fixture_dir() else {
93- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
94- };
95- let Ok(bytes) = std::fs::read(dir.join("still.webp")) else {
86+ let Ok(bytes) = std::fs::read(ec_testkit::fixture("vp8/still.webp")) else {
9687 panic!("still.webp missing (libwebp encoder unavailable at generation time)");
9788 };
9889 let vp8 = common::webp_vp8_chunk(&bytes);
@@ -107,10 +98,7 @@ fn parses_vp8_in_webp_still() {
10798
10899 #[test]
109100 fn gop_key_frame_parses_and_coexists_with_inter() {
110- let Some(dir) = common::fixture_dir() else {
111- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
112- };
113- let bytes = std::fs::read(dir.join("gop-160x96.ivf")).unwrap();
101+ let bytes = std::fs::read(ec_testkit::fixture("vp8/gop-160x96.ivf")).unwrap();
114102 let (_, _, _, frames) = common::parse_ivf(&bytes);
115103 assert!(frames.len() >= 30);
116104
crates/ec-vp8/tests/it/keyframe_exact.rsmodified+9 -19
@@ -13,14 +13,8 @@ fn raw<'a>(pos: &mut usize, data: &'a [u8], len: usize) -> &'a [u8] {
1313 /// Decode every frame of an IVF with our decoder and compare each SHOWN
1414 /// frame's planes against ffmpeg's byte stream (ffmpeg skips hidden
1515 /// `show_frame == 0` frames exactly like a player).
16-fn compare(name: &str, skip_if_missing: bool) {
17- let Some(dir) = common::fixture_dir() else {
18- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
19- };
20- let path = dir.join(name);
21- if skip_if_missing && !path.exists() {
22- panic!("{name} missing (regenerate fixtures)");
23- }
16+fn compare(name: &str) {
17+ let path = ec_testkit::fixture(&format!("vp8/{name}"));
2418 let bytes = std::fs::read(&path).unwrap();
2519 let (_, w, h, frames) = common::parse_ivf(&bytes);
2620 let all = ffmpeg_raw_yuv(&path);
@@ -73,13 +67,13 @@ fn keyframes_match_ffmpeg() {
7367 ("kf-172x144-q25.ivf", 172, 144),
7468 ("kf-96x80-q63.ivf", 96, 80),
7569 ] {
76- compare(name, false);
70+ compare(name);
7771 }
7872 }
7973
8074 #[test]
8175 fn multi_partition_keyframe_matches_ffmpeg() {
82- compare("mparts-160x96.ivf", false);
76+ compare("mparts-160x96.ivf");
8377 }
8478
8579 /// M3 witness: full inter-frame streams — simple-filter GOP, multi-token-
@@ -95,8 +89,7 @@ fn interframe_streams_match_ffmpeg() {
9589 "altref-160x96.ivf",
9690 ] {
9791 if name == "altref-160x96.ivf" {
98- let dir = common::fixture_dir().expect("fixtures dir");
99- let bytes = std::fs::read(dir.join(name)).unwrap();
92+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp8/{name}"))).unwrap();
10093 let hidden = census_hidden(&bytes);
10194 assert!(
10295 hidden >= 6,
@@ -104,7 +97,7 @@ fn interframe_streams_match_ffmpeg() {
10497 scripts/gen_vp8_fixtures.sh (--auto-alt-ref=1 --passes=2)"
10598 );
10699 }
107- compare(name, false);
100+ compare(name);
108101 }
109102 }
110103
@@ -116,14 +109,11 @@ fn census_hidden(bytes: &[u8]) -> usize {
116109
117110 #[test]
118111 fn vp8_in_webp_still_matches_ffmpeg() {
119- let Some(dir) = common::fixture_dir() else {
120- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
121- };
122- let bytes = std::fs::read(dir.join("still.webp")).unwrap();
112+ let bytes = std::fs::read(ec_testkit::fixture("vp8/still.webp")).unwrap();
123113 let vp8 = common::webp_vp8_chunk(&bytes);
124- let reference = std::process::Command::new("ffmpeg")
114+ let reference = ec_testkit::ffmpeg()
125115 .args(["-v", "error", "-i"])
126- .arg(dir.join("still.webp"))
116+ .arg(ec_testkit::fixture("vp8/still.webp"))
127117 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
128118 .output()
129119 .unwrap();
crates/ec-vp8/tests/it/stream_exact.rsmodified+3 -12
@@ -25,11 +25,8 @@ const FIXTURES: &[&str] = &[
2525
2626 #[test]
2727 fn decode_stream_matches_ffmpeg_on_every_fixture() {
28- let Some(dir) = common::fixture_dir() else {
29- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
30- };
3128 for name in FIXTURES {
32- let path = dir.join(name);
29+ let path = ec_testkit::fixture(&format!("vp8/{name}"));
3330 let bytes = std::fs::read(&path).unwrap();
3431 let (_, w, h, frames) = common::parse_ivf(&bytes);
3532 let all = ffmpeg_raw_yuv(&path);
@@ -58,10 +55,7 @@ fn decode_stream_matches_ffmpeg_on_every_fixture() {
5855 /// ffmpeg.
5956 #[test]
6057 fn hidden_frames_update_references_and_produce_no_picture() {
61- let Some(dir) = common::fixture_dir() else {
62- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
63- };
64- let path = dir.join("altref-160x96.ivf");
58+ let path = ec_testkit::fixture("vp8/altref-160x96.ivf");
6559 let bytes = std::fs::read(&path).unwrap();
6660 let (_, w, h, frames) = common::parse_ivf(&bytes);
6761 let hidden_at: Vec<usize> = frames
@@ -105,10 +99,7 @@ fn hidden_frames_update_references_and_produce_no_picture() {
10599
106100 #[test]
107101 fn decode_stream_is_error_not_panic_on_bad_containers() {
108- let Some(dir) = common::fixture_dir() else {
109- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
110- };
111- let bytes = std::fs::read(dir.join("gop-160x96.ivf")).unwrap();
102+ let bytes = std::fs::read(ec_testkit::fixture("vp8/gop-160x96.ivf")).unwrap();
112103
113104 // Missing magic.
114105 let mut bad = bytes.clone();
crates/ec-vp8/tests/malformed_no_panic.rsmodified+1 -9
@@ -3,11 +3,6 @@
33 //! seeded single-byte corruptions; each decode runs under `catch_unwind` so a
44 //! failure names the file and the damage that caused it.
55
6-// Only `fixture_dir` is used here; the IVF parser serves the other test crates.
7-#[allow(dead_code)]
8-#[path = "it/common.rs"]
9-mod ivf;
10-
116 use std::panic::{AssertUnwindSafe, catch_unwind};
127
138 use ec_vp8::stream::decode_stream;
@@ -59,9 +54,6 @@ fn decode_must_not_panic(data: &[u8], what: &str) {
5954
6055 #[test]
6156 fn truncated_and_corrupted_fixtures_never_panic() {
62- let Some(dir) = ivf::fixture_dir() else {
63- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
64- };
6557 // Silence the default panic hook while probing; failures are reported
6658 // by the assertion above, which names the file and the damage.
6759 let hook = std::panic::take_hook();
@@ -70,7 +62,7 @@ fn truncated_and_corrupted_fixtures_never_panic() {
7062 let mut rng = Rng(SEED);
7163 let mut failures = Vec::new();
7264 for name in FIXTURES {
73- let bytes = std::fs::read(dir.join(name)).unwrap();
65+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp8/{name}"))).unwrap();
7466 assert!(bytes.len() > 32, "{name}: fixture too small");
7567
7668 for k in 1..=TRUNCATIONS {
crates/ec-vp9-syntax/Cargo.tomlmodified+3 -0
@@ -8,3 +8,6 @@ authors.workspace = true
88
99 [dependencies]
1010 ec-core.workspace = true
11+
12+[dev-dependencies]
13+ec-testkit.workspace = true
crates/ec-vp9-syntax/tests/streams.rsmodified+7 -43
@@ -1,19 +1,10 @@
11 //! Every VP9 fixture stream parsed end to end, field-compared against ffprobe.
2-//!
3-//! `scripts/gen-bitstream-fixtures.sh` remuxes the container fixtures to IVF and
4-//! encodes the branch cases (superframes, 4:4:4, tiles). Fixtures are gitignored,
5-//! so a checkout without them skips rather than fails.
62
73 use std::path::{Path, PathBuf};
8-use std::process::Command;
94
105 use ec_core::Error;
116 use ec_vp9_syntax::{FrameType, Vp9Parser, superframe};
127
13-fn bitstreams() -> PathBuf {
14- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams")
15-}
16-
178 /// The IVF frames of a file, payload only.
189 fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {
1910 let mut out = Vec::new();
@@ -31,7 +22,7 @@ fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {
3122 }
3223
3324 fn ffprobe(path: &Path, entries: &str) -> Vec<String> {
34- let out = Command::new("ffprobe")
25+ let out = ec_testkit::ffprobe()
3526 .args(["-v", "error", "-select_streams", "v:0", "-show_entries"])
3627 .arg(entries)
3728 .args(["-of", "csv=p=0"])
@@ -84,32 +75,15 @@ fn pix_fmt_geometry(pix_fmt: &str) -> (u8, u8, u8) {
8475 }
8576
8677 fn fixtures() -> Vec<PathBuf> {
87- let dir = bitstreams();
88- let Ok(entries) = std::fs::read_dir(&dir) else {
89- return Vec::new();
90- };
91- let mut files: Vec<PathBuf> = entries
92- .filter_map(|e| e.ok().map(|e| e.path()))
93- .filter(|p| {
94- p.extension().is_some_and(|e| e == "ivf")
95- && p.file_name()
96- .is_some_and(|n| n.to_string_lossy().starts_with("vp9-"))
97- })
98- .collect();
99- files.sort();
100- files
78+ ec_testkit::fixtures("bitstreams", "ivf")
79+ .into_iter()
80+ .filter(|p| p.file_name().is_some_and(|n| n.to_string_lossy().starts_with("vp9-")))
81+ .collect()
10182 }
10283
10384 #[test]
10485 fn every_fixture_matches_ffprobe() {
105- let files = fixtures();
106- if files.is_empty() {
107- eprintln!(
108- "skipped: no fixtures/bitstreams/vp9-*.ivf — run scripts/gen-bitstream-fixtures.sh"
109- );
110- return;
111- }
112- for path in files {
86+ for path in fixtures() {
11387 let name = path.file_name().unwrap().to_string_lossy().to_string();
11488 let (width, height, pix_fmt, profile) = probe_stream(&path);
11589 let (bit_depth, sx, sy) = pix_fmt_geometry(&pix_fmt);
@@ -197,11 +171,7 @@ fn every_fixture_matches_ffprobe() {
197171 /// genuine `show_existing_frame` headers; libaom uses them.)
198172 #[test]
199173 fn altref_fixture_has_superframes_and_hidden_frames() {
200- let path = bitstreams().join("vp9-superframe-altref.ivf");
201- if !path.exists() {
202- eprintln!("skipped: no vp9-superframe-altref.ivf");
203- return;
204- }
174+ let path = ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf");
205175 let data = std::fs::read(&path).unwrap();
206176 let mut parser = Vp9Parser::new();
207177 let (mut superframes, mut hidden) = (0, 0);
@@ -245,12 +215,6 @@ fn fuzz_10k_mutations_never_panics() {
245215 .collect::<Vec<_>>()
246216 })
247217 .collect();
248- let seeds = if seeds.is_empty() {
249- // No fixtures: still exercise the parser against pure noise.
250- vec![vec![0x82u8; 128]]
251- } else {
252- seeds
253- };
254218
255219 let mut state = 0x2545_f491_4f6c_dd1du64;
256220 let mut rng = move || {
crates/ec-vp9/Cargo.tomlmodified+3 -0
@@ -9,3 +9,6 @@ authors.workspace = true
99 [dependencies]
1010 ec-core.workspace = true
1111 ec-vp9-syntax.workspace = true
12+
13+[dev-dependencies]
14+ec-testkit.workspace = true
crates/ec-vp9/fuzz/seed.shmodified+1 -2
@@ -5,13 +5,12 @@
55 # into corpus/decode_frame/. Whole IVF files up to 256 KiB go into corpus/decode_stream/, and
66 # a 10-frame prefix of every larger file too. The corpus is generated, not committed.
77 #
8-# Usage: crates/ec-vp9/fuzz/seed.sh (from any directory; needs python3 and the fixtures/ link)
98 set -euo pipefail
109 here=$(cd -- "$(dirname -- "$0")" && pwd)
1110 repo=$(cd -- "$here/../../.." && pwd)
1211 rm -rf "$here/corpus"
1312 mkdir -p "$here/corpus/decode_frame" "$here/corpus/decode_stream"
14-exec python3 -I - "$here" "decode_stream" "$repo/fixtures/vp9/*.ivf" "$here/../tests/data/*.ivf" <<'PY'
13+exec python3 -I - "$here" "decode_stream" "${EC_FIXTURES:-$repo/fixtures}/vp9/*.ivf" "$here/../tests/data/*.ivf" <<'PY'
1514 import glob, os, struct, sys
1615
1716 here, stream_target = sys.argv[1], sys.argv[2]
crates/ec-vp9/tests/it/common.rsmodified+2 -26
@@ -1,37 +1,13 @@
11 //! Helpers shared by the integration-test modules of the `it` binary.
22
3-/// Fixture-presence probe for the committed-or-media-gated fixtures a test
4-/// decodes. Returns whether the fixture is present, but never silently: under
5-/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path
6-/// and the script that regenerates it, so a host whose fixture library drifted
7-/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure;
8-/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently
9-/// short-circuited because the probe ran first in a compound `if`).
10-///
11-/// Order is load-bearing: probe, assert, return. Never merge the probe into
12-/// the same `if` as the escape.
13-pub(crate) fn require_fixture(path: &std::path::Path, generator: &str) -> bool {
14- let present = path.exists();
15- assert!(
16- present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
17- "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}",
18- path.display(),
19- generator
20- );
21- if !present {
22- eprintln!("SKIP: fixture {} absent", path.display());
23- }
24- present
25-}
26-
273 /// ffmpeg's decoded rawvideo byte stream (frame-packed I420, `w`x`h`).
284 pub(crate) fn ffmpeg_raw_yuv(path: &std::path::Path, w: usize, h: usize) -> Vec<u8> {
29- let out = std::process::Command::new("ffmpeg")
5+ let out = ec_testkit::ffmpeg()
306 .args(["-v", "error", "-i"])
317 .arg(path)
328 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
339 .output()
34- .expect("ffmpeg on PATH");
10+ .expect("ffmpeg runs");
3511 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
3612 let frame = w * h + 2 * (w / 2) * (h / 2);
3713 assert_eq!(
crates/ec-vp9/tests/it/dump_probe.rsmodified+3 -4
@@ -2,13 +2,12 @@ use crate::ivf;
22 use ec_vp9::decode::Decoder;
33 #[test]
44 fn diff_stats() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
6- let bytes = std::fs::read(dir.join("fixtures/vp9/key-320.ivf")).unwrap();
5+ let bytes = std::fs::read(ec_testkit::fixture("vp9/key-320.ivf")).unwrap();
76 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
87 let mut d = Decoder::new();
98 let pic = d.decode(&frames[0].data).unwrap().unwrap();
10- let refout = std::process::Command::new("ffmpeg")
11- .args(["-v","error","-i",dir.join("fixtures/vp9/key-320.ivf").to_str().unwrap(),
9+ let refout = ec_testkit::ffmpeg()
10+ .args(["-v","error","-i",ec_testkit::fixture("vp9/key-320.ivf").to_str().unwrap(),
1211 "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])
1312 .output().unwrap().stdout;
1413 let w = 320usize;
crates/ec-vp9/tests/it/hbd_exact.rsmodified+4 -21
@@ -2,35 +2,21 @@
22 //! against ffmpeg's libvpx (`ffmpeg -v error -i in.ivf -f rawvideo -pix_fmt
33 //! yuv420p10le -`). Pre-fix the decoder refuses `profile 2` by name, so this
44 //! test fails at the first frame; post-fix every shown frame matches.
5-//!
6-//! Media-gated: the 10-bit corpus streams are gitignored, so the test prints
7-//! SKIP when the fixture is absent (set the fixture tree up per the lane
8-//! notes) -- and goes RED instead under `EC_REQUIRE_FIXTURES=1`, so a drifted
9-//! fixture library can never read as a pass. The 4:4:4 and 12-bit shapes are
10-//! covered by `subsampling_exact.rs`.
115
126 use crate::ivf;
13-use crate::common::require_fixture;
147
158 use ec_vp9::decode::Decoder;
16-use std::path::{Path, PathBuf};
17-
18-fn fixture(name: &str) -> PathBuf {
19- let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
20- p.pop();
21- p.pop();
22- p.join("fixtures/bitstreams").join(name)
23-}
9+use std::path::Path;
2410
2511 /// ffmpeg's rawvideo `yuv420p10le` bytes (little-endian u16 samples,
2612 /// stride == visible width).
2713 fn ffmpeg_raw_yuv10(path: &Path) -> Vec<u8> {
28- let out = std::process::Command::new("ffmpeg")
14+ let out = ec_testkit::ffmpeg()
2915 .args(["-v", "error", "-i"])
3016 .arg(path)
3117 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p10le", "-"])
3218 .output()
33- .expect("ffmpeg must be on PATH for the witnesses");
19+ .expect("ffmpeg runs for the witnesses");
3420 assert!(out.status.success(), "ffmpeg failed on {path:?}");
3521 out.stdout
3622 }
@@ -58,10 +44,7 @@ fn decode_all(path: &Path) -> (Vec<Vec<u8>>, u8) {
5844 /// produces, sample for sample.
5945 #[test]
6046 fn profile2_10bit_is_byte_exact() {
61- let a = fixture("vp9-1080p-23.976-10bit.ivf");
62- if !require_fixture(&a, "scripts/gen-bitstream-fixtures.sh") {
63- return;
64- }
47+ let a = ec_testkit::fixture("bitstreams/vp9-1080p-23.976-10bit.ivf");
6548 let (ours, bd) = decode_all(&a);
6649 assert_eq!(bd, 10, "the fixture must decode at 10 bits");
6750 let want = ffmpeg_raw_yuv10(&a);
crates/ec-vp9/tests/it/inter_pixels_exact.rsmodified+6 -14
@@ -7,7 +7,7 @@
77 //! `tests/scratch_pixdump.rs` (env-gated) instead; see `lanes/vp9pix.report.md`.
88
99 use crate::ivf;
10-use crate::common::{ffmpeg_raw_yuv, require_fixture};
10+use crate::common::ffmpeg_raw_yuv;
1111
1212 use ec_vp9::decode::Decoder;
1313 /// Generate a GOP fixture with libvpx: 6 frames of testsrc2 at 320x240,
@@ -19,7 +19,7 @@ fn ensure_fixture(path: &std::path::Path, tile_columns: u32) {
1919 if let Some(dir) = path.parent() {
2020 std::fs::create_dir_all(dir).unwrap();
2121 }
22- let st = std::process::Command::new("ffmpeg")
22+ let st = ec_testkit::ffmpeg()
2323 .args([
2424 "-v",
2525 "error",
@@ -44,7 +44,7 @@ fn ensure_fixture(path: &std::path::Path, tile_columns: u32) {
4444 .args(["-pix_fmt", "yuv420p", "-f", "ivf"])
4545 .arg(path)
4646 .output()
47- .expect("ffmpeg with libvpx-vp9 must be on PATH for the witnesses");
47+ .expect("ffmpeg with libvpx-vp9 runs for the witnesses");
4848 assert!(st.status.success(), "fixture generation failed: {st:?}");
4949 }
5050
@@ -98,7 +98,7 @@ fn compare(path: &std::path::Path) -> usize {
9898
9999 #[test]
100100 fn inter_gop_matches_ffmpeg() {
101- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/vp9-witness");
101+ let dir = std::env::temp_dir().join("ec-vp9-witness");
102102 let path = dir.join("inter-gop.ivf");
103103 ensure_fixture(&path, 0);
104104 assert!(compare(&path) >= 2);
@@ -106,7 +106,7 @@ fn inter_gop_matches_ffmpeg() {
106106
107107 #[test]
108108 fn inter_gop_with_tile_columns_matches_ffmpeg() {
109- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/vp9-witness");
109+ let dir = std::env::temp_dir().join("ec-vp9-witness");
110110 let path = dir.join("inter-gop-tc1.ivf");
111111 ensure_fixture(&path, 1);
112112 assert!(compare(&path) >= 2);
@@ -118,17 +118,9 @@ fn inter_gop_with_tile_columns_matches_ffmpeg() {
118118 /// write-back window runs past the frame bottom edge kept the window's
119119 /// TAIL slot set (`write_tx_context`), and the next row of blocks read it
120120 /// as an entropy context. Every shown frame must match ffmpeg.
121-///
122-/// Media-gated: the corpus fixture is not versioned, so the witness prints
123-/// SKIP when `fixtures/bitstreams/vp9-1080p-60-8bit.ivf` is absent -- and goes
124-/// RED instead under `EC_REQUIRE_FIXTURES=1`.
125121 #[test]
126122 fn corpus_1080p_60fps_matches_ffmpeg_past_frame_72() {
127- let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
128- .join("../../fixtures/bitstreams/vp9-1080p-60-8bit.ivf");
129- if !require_fixture(&path, "scripts/gen-bitstream-fixtures.sh") {
130- return;
131- }
123+ let path = ec_testkit::fixture("bitstreams/vp9-1080p-60-8bit.ivf");
132124 let shown = compare(&path);
133125 assert!(
134126 shown >= 73,
crates/ec-vp9/tests/it/ivf.rsmodified+0 -19
@@ -47,22 +47,3 @@ pub fn parse_ivf(bytes: &[u8]) -> (&str, u16, u16, Vec<IvfFrame>) {
4747 (fourcc, width, height, frames)
4848 }
4949
50-/// Root of the workspace checkout this test runs in (crates/ec-vp9/../..).
51-#[allow(dead_code)] // shared by the `it` test binary
52-///
53-/// With `EC_REQUIRE_FIXTURES` set, an absent directory is a hard failure, so a
54-/// host without the fixtures cannot pass by skipping.
55-pub fn fixture_dir() -> Option<std::path::PathBuf> {
56- let bitstreams =
57- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams");
58- if bitstreams.is_dir() {
59- Some(bitstreams)
60- } else {
61- assert!(
62- std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
63- "EC_REQUIRE_FIXTURES=1 but {} is absent",
64- bitstreams.display()
65- );
66- None
67- }
68-}
crates/ec-vp9/tests/it/keyframe_exact.rsmodified+5 -46
@@ -6,49 +6,14 @@ use crate::ivf;
66
77 use ec_vp9::decode::Decoder;
88
9-/// Generate the small all-keyframe fixture with libvpx if it is absent
10-/// (2 keyframes of 320x240 testsrc2, realtime cpu-used 4).
11-fn ensure_fixture(path: &std::path::Path) {
12- if path.exists() {
13- return;
14- }
15- if let Some(dir) = path.parent() {
16- std::fs::create_dir_all(dir).unwrap();
17- }
18- let st = std::process::Command::new("ffmpeg")
19- .args([
20- "-y",
21- "-f",
22- "lavfi",
23- "-i",
24- "testsrc2=size=320x240:rate=30:duration=1",
25- "-pix_fmt",
26- "yuv420p",
27- "-c:v",
28- "libvpx-vp9",
29- "-g",
30- "1",
31- "-cpu-used",
32- "4",
33- "-deadline",
34- "realtime",
35- "-frames:v",
36- "2",
37- ])
38- .arg(path)
39- .output()
40- .expect("ffmpeg with libvpx-vp9 must be on PATH for the witnesses");
41- assert!(st.status.success(), "fixture generation failed: {st:?}");
42-}
43-
449 /// ffmpeg's decoded rawvideo byte stream for the same file.
4510 fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
46- let out = std::process::Command::new("ffmpeg")
11+ let out = ec_testkit::ffmpeg()
4712 .args(["-v", "error", "-i"])
4813 .arg(path)
4914 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
5015 .output()
51- .expect("ffmpeg must be on PATH for the witnesses");
16+ .expect("ffmpeg runs for the witnesses");
5217 assert!(out.status.success(), "ffmpeg failed on {path:?}");
5318 out.stdout
5419 }
@@ -113,16 +78,13 @@ fn compare(path: &std::path::Path) {
11378
11479 #[test]
11580 fn keyframes_match_ffmpeg() {
116- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp9");
117- let path = dir.join("key-320.ivf");
118- ensure_fixture(&path);
81+ let path = ec_testkit::fixture("vp9/key-320.ivf");
11982 compare(&path);
12083 }
12184
12285 #[test]
12386 fn lossless_64_matches_ffmpeg() {
124- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
125- let path = dir.join("fixtures/vp9/lossless-64.ivf");
87+ let path = ec_testkit::fixture("vp9/lossless-64.ivf");
12688 let bytes = std::fs::read(&path).unwrap();
12789 let (_fourcc, w, h, frames) = ivf::parse_ivf(&bytes);
12890 let reference = ffmpeg_raw_yuv(&path);
@@ -157,10 +119,7 @@ fn inter_stream_decodes_and_matches_ffmpeg() {
157119 // used to be the "inter is refused by name" witness. Inter frames decode
158120 // now, so the witness is the pixels: every shown frame must match
159121 // ffmpeg's libvpx output byte for byte.
160- let Some(dir) = ivf::fixture_dir() else {
161- return;
162- };
163- let path = dir.join("vp9-superframe-altref.ivf");
122+ let path = ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf");
164123 let bytes = std::fs::read(&path).unwrap();
165124 let (_, w, h, frames) = ivf::parse_ivf(&bytes);
166125 let (w, h) = (w as usize, h as usize);
crates/ec-vp9/tests/it/libvpx_vectors.rsmodified+2 -22
@@ -9,18 +9,10 @@
99 //! The test decodes every vector, digests every returned picture and compares
1010 //! the digest with the matching line, in order. Any frame-count or digest
1111 //! difference fails the test and is listed by vector name and frame index.
12-//! Vectors are read from the fixture tree (`scripts/fetch-vectors.sh
13-//! vp9-libvpx`). Without the fixtures the test skips, unless
14-//! `EC_REQUIRE_FIXTURES` is set, in which case it fails.
1512
1613 use ec_vp9::decode::{Decoder, Picture};
1714 use std::path::{Path, PathBuf};
1815
19-/// Directory of the fetched libvpx vectors (crates/ec-vp9/../../fixtures).
20-fn vector_dir() -> PathBuf {
21- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vectors/vp9-libvpx")
22-}
23-
2416 // ------------------------------------------------------------------ MD5 ----
2517
2618 /// RFC 1321 MD5 of `data`, as lowercase hex.
@@ -253,20 +245,8 @@ fn check_vector(name: &str, frames: &[&[u8]], expected: &[String]) -> Vec<String
253245
254246 #[test]
255247 fn libvpx_vectors_match_per_frame_md5() {
256- let dir = vector_dir();
257- let require = std::env::var_os("EC_REQUIRE_FIXTURES").is_some();
258- let entries = match std::fs::read_dir(&dir) {
259- Ok(e) => e,
260- Err(_) => {
261- assert!(
262- !require,
263- "EC_REQUIRE_FIXTURES=1 but {} is absent (run scripts/fetch-vectors.sh vp9-libvpx)",
264- dir.display()
265- );
266- eprintln!("skip: {} absent", dir.display());
267- return;
268- }
269- };
248+ let dir = ec_testkit::fixture("vectors/vp9-libvpx");
249+ let entries = std::fs::read_dir(&dir).expect("vector directory");
270250 let mut md5_files: Vec<PathBuf> = entries
271251 .filter_map(|e| e.ok().map(|e| e.path()))
272252 .filter(|p| p.extension().is_some_and(|x| x == "md5"))
crates/ec-vp9/tests/it/main.rsmodified+0 -1
@@ -25,7 +25,6 @@ mod scratch_lossless;
2525 mod scratch_pixdump10;
2626 mod scratch_pixdump;
2727 mod scratch_realsweep;
28-mod scratch_synth;
2928 mod scratch_tiledbg;
3029 mod scratch_tok;
3130 mod subsampling_exact;
crates/ec-vp9/tests/it/odd_dimensions_exact.rsmodified+5 -5
@@ -27,7 +27,7 @@ fn ensure_even_fixture(path: &Path) {
2727 if let Some(dir) = path.parent() {
2828 std::fs::create_dir_all(dir).unwrap();
2929 }
30- let st = std::process::Command::new("ffmpeg")
30+ let st = ec_testkit::ffmpeg()
3131 .args([
3232 "-v",
3333 "error",
@@ -55,7 +55,7 @@ fn ensure_even_fixture(path: &Path) {
5555 ])
5656 .arg(path)
5757 .output()
58- .expect("ffmpeg with libvpx-vp9 must be on PATH for the witnesses");
58+ .expect("ffmpeg with libvpx-vp9 runs for the witnesses");
5959 assert!(st.status.success(), "fixture generation failed: {st:?}");
6060 }
6161
@@ -86,12 +86,12 @@ fn patched(ivf: &[u8], nw: u16, nh: u16) -> Vec<u8> {
8686
8787 /// ffmpeg's decoded rawvideo byte stream (frame-packed I420, ceil chroma).
8888 fn ffmpeg_raw_yuv(path: &Path) -> Vec<u8> {
89- let out = std::process::Command::new("ffmpeg")
89+ let out = ec_testkit::ffmpeg()
9090 .args(["-v", "error", "-i"])
9191 .arg(path)
9292 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
9393 .output()
94- .expect("ffmpeg on PATH");
94+ .expect("ffmpeg runs");
9595 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
9696 out.stdout
9797 }
@@ -100,7 +100,7 @@ fn ffmpeg_raw_yuv(path: &Path) -> Vec<u8> {
100100 /// every frame must carry the odd coded size (frame 0 sets it, the rest
101101 /// inherit it), and there must be inter frames.
102102 fn check(nw: u16, nh: u16) {
103- let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/vp9-witness");
103+ let dir = std::env::temp_dir().join("ec-vp9-witness");
104104 let even = dir.join("odd-src-322x242.ivf");
105105 ensure_even_fixture(&even);
106106 let odd = dir.join(format!("odd-{nw}x{nh}.ivf"));
crates/ec-vp9/tests/it/scaledref_exact.rsmodified+2 -2
@@ -40,13 +40,13 @@ fn fixture(name: &str) -> std::path::PathBuf {
4040
4141 /// Run ffmpeg over `path` with `args` and return its rawvideo stdout.
4242 fn ffmpeg_raw(path: &std::path::Path, args: &[&str]) -> Vec<u8> {
43- let out = std::process::Command::new("ffmpeg")
43+ let out = ec_testkit::ffmpeg()
4444 .args(["-v", "error", "-y", "-i"])
4545 .arg(path)
4646 .args(args)
4747 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
4848 .output()
49- .expect("ffmpeg on PATH");
49+ .expect("ffmpeg runs");
5050 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
5151 out.stdout
5252 }
crates/ec-vp9/tests/it/scratch_bool.rsmodified+1 -2
@@ -3,8 +3,7 @@ use ec_vp9::bool::BoolDecoder;
33
44 #[test]
55 fn probe_first_bools() {
6- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
7- let bytes = std::fs::read(dir.join("fixtures/vp9/lossless-64.ivf")).unwrap();
6+ let bytes = std::fs::read(ec_testkit::fixture("vp9/lossless-64.ivf")).unwrap();
87 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
98 let frame = &frames[0].data;
109 println!("slice bytes: {:02x?}", &frame[18..26]);
crates/ec-vp9/tests/it/scratch_err.rsmodified+2 -6
@@ -2,14 +2,10 @@ use crate::ivf;
22 use ec_vp9::decode::Decoder;
33 #[test]
44 fn show_err() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
6- let bytes = std::fs::read(dir.join("fixtures/bitstreams/vp9-superframe-altref.ivf")).unwrap();
5+ let bytes = std::fs::read(ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf")).unwrap();
76 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
87 let mut d = Decoder::new();
9- let dir2 = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
10- let b2 = std::fs::read(dir2.join("fixtures/bitstreams/vp9-superframe-altref.ivf")).unwrap();
11- let (_, _, _, f2) = ivf::parse_ivf(&b2);
12- println!("f0 bytes: {:02x?}", &f2[0].data[16..24]);
8+ println!("f0 bytes: {:02x?}", &frames[0].data[16..24]);
139 match d.decode(&frames[0].data) {
1410 Ok(_) => println!("OK"),
1511 Err(e) => println!("ERR: {e}"),
crates/ec-vp9/tests/it/scratch_hdr.rsmodified+1 -4
@@ -2,10 +2,7 @@ use ec_vp9_syntax::Vp9Parser;
22 #[test]
33 fn hdr_probe() {
44 for name in ["lossless-64.ivf", "key-320.ivf"] {
5- let mut p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
6- p.pop(); p.pop();
7- p = p.join("fixtures/vp9").join(name);
8- let bytes = std::fs::read(&p).unwrap();
5+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp9/{name}"))).unwrap();
96 let fsize = u32::from_le_bytes(bytes[32..36].try_into().unwrap()) as usize;
107 let frame = &bytes[44..44 + fsize];
118 let mut pp = Vp9Parser::new();
crates/ec-vp9/tests/it/scratch_hdr2.rsmodified+1 -2
@@ -2,8 +2,7 @@ use crate::ivf;
22 use ec_vp9_syntax::Vp9Parser;
33 #[test]
44 fn dump_hdr() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
6- let bytes = std::fs::read(dir.join("fixtures/vp9/lossless-64.ivf")).unwrap();
5+ let bytes = std::fs::read(ec_testkit::fixture("vp9/lossless-64.ivf")).unwrap();
76 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
87 let mut p = Vp9Parser::new();
98 let h = p.parse_frame(&frames[0].data).unwrap();
crates/ec-vp9/tests/it/scratch_hdr3.rsmodified+1 -2
@@ -2,8 +2,7 @@ use crate::ivf;
22 use ec_vp9_syntax::Vp9Parser;
33 #[test]
44 fn dump_hdr() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
6- let bytes = std::fs::read(dir.join("fixtures/bitstreams/vp9-superframe-altref.ivf")).unwrap();
5+ let bytes = std::fs::read(ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf")).unwrap();
76 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
87 let subs = ec_vp9_syntax::superframe::split(&frames[0].data).unwrap();
98 println!("subframes: {}", subs.len());
crates/ec-vp9/tests/it/scratch_lfdump.rsmodified+9 -9
@@ -6,12 +6,12 @@ use crate::ivf;
66 use ec_vp9::decode::Decoder;
77
88 fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
9- let out = std::process::Command::new("ffmpeg")
9+ let out = ec_testkit::ffmpeg()
1010 .args(["-v", "error", "-i"])
1111 .arg(path)
1212 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
1313 .output()
14- .expect("ffmpeg on PATH");
14+ .expect("ffmpeg runs");
1515 assert!(out.status.success());
1616 out.stdout
1717 }
@@ -19,7 +19,7 @@ fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
1919 #[test]
2020 fn dump_lf_diff_map() {
2121 let path =
22- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp9/key-320.ivf");
22+ ec_testkit::fixture("vp9/key-320.ivf");
2323 let bytes = std::fs::read(&path).unwrap();
2424 let (_f, _w, _h, frames) = ivf::parse_ivf(&bytes);
2525 let reference = ffmpeg_raw_yuv(&path);
@@ -38,9 +38,9 @@ fn dump_lf_diff_map() {
3838 dec.decode(&fr.data).expect("decode");
3939 }
4040 let pic_pre = dec.decode(&frames[fi].data).expect("decode").expect("shown");
41- std::fs::write("/tmp/y_pre_ours.raw", pic_pre.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
42- std::fs::write("/tmp/u_pre_ours.raw", pic_pre.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
43- std::fs::write("/tmp/v_pre_ours.raw", pic_pre.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
41+ std::fs::write(std::env::temp_dir().join("y_pre_ours.raw"), pic_pre.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
42+ std::fs::write(std::env::temp_dir().join("u_pre_ours.raw"), pic_pre.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
43+ std::fs::write(std::env::temp_dir().join("v_pre_ours.raw"), pic_pre.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
4444 drop(skip_lf);
4545
4646 // Post-LF run (fresh decoder).
@@ -49,9 +49,9 @@ fn dump_lf_diff_map() {
4949 dec.decode(&fr.data).expect("decode");
5050 }
5151 let pic_post = dec.decode(&frames[fi].data).expect("decode").expect("shown");
52- std::fs::write("/tmp/y_post_ours.raw", pic_post.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
53- std::fs::write("/tmp/u_post_ours.raw", pic_post.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
54- std::fs::write("/tmp/v_post_ours.raw", pic_post.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
52+ std::fs::write(std::env::temp_dir().join("y_post_ours.raw"), pic_post.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
53+ std::fs::write(std::env::temp_dir().join("u_post_ours.raw"), pic_post.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
54+ std::fs::write(std::env::temp_dir().join("v_post_ours.raw"), pic_post.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
5555
5656 let fsz = ysz + 2 * (w / 2) * (h / 2);
5757 let ff = &reference[fi * fsz..fi * fsz + ysz];
crates/ec-vp9/tests/it/scratch_lossless.rsmodified+2 -3
@@ -2,11 +2,10 @@ use crate::ivf;
22 use ec_vp9::decode::Decoder;
33 #[test]
44 fn lossless_matches() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
6- let path = dir.join("fixtures/vp9/lossless-64.ivf");
5+ let path = ec_testkit::fixture("vp9/lossless-64.ivf");
76 let bytes = std::fs::read(&path).unwrap();
87 let (_, w, h, frames) = ivf::parse_ivf(&bytes);
9- let refout = std::process::Command::new("ffmpeg")
8+ let refout = ec_testkit::ffmpeg()
109 .args(["-v","error","-i", path.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])
1110 .output().unwrap().stdout;
1211 let mut d = Decoder::new();
crates/ec-vp9/tests/it/scratch_pixdump.rsmodified+3 -4
@@ -9,11 +9,10 @@
99 use ec_vp9::decode::Decoder;
1010
1111 #[test]
12+#[ignore = "manual dump: set INTER_IVF and EC_VP9_PIXDUMP"]
1213 fn pixdump() {
13- let (Ok(ivf), Ok(out)) = (std::env::var("INTER_IVF"), std::env::var("EC_VP9_PIXDUMP")) else {
14- eprintln!("SKIP scratch_pixdump: set INTER_IVF and EC_VP9_PIXDUMP");
15- return;
16- };
14+ let ivf = std::env::var("INTER_IVF").expect("set INTER_IVF");
15+ let out = std::env::var("EC_VP9_PIXDUMP").expect("set EC_VP9_PIXDUMP");
1716 let bytes = std::fs::read(&ivf).expect("read ivf");
1817 let (_, w, h, frames) = parse_ivf(&bytes);
1918 let mut decoder = Decoder::new();
crates/ec-vp9/tests/it/scratch_pixdump10.rsmodified+3 -4
@@ -10,11 +10,10 @@
1010 use ec_vp9::decode::Decoder;
1111
1212 #[test]
13+#[ignore = "manual dump: set INTER_IVF and EC_VP9_PIXDUMP"]
1314 fn pixdump10() {
14- let (Ok(ivf), Ok(out)) = (std::env::var("INTER_IVF"), std::env::var("EC_VP9_PIXDUMP")) else {
15- eprintln!("SKIP scratch_pixdump10: set INTER_IVF and EC_VP9_PIXDUMP");
16- return;
17- };
15+ let ivf = std::env::var("INTER_IVF").expect("set INTER_IVF");
16+ let out = std::env::var("EC_VP9_PIXDUMP").expect("set EC_VP9_PIXDUMP");
1817 let bytes = std::fs::read(&ivf).expect("read ivf");
1918 let (_, w, h, frames) = parse_ivf(&bytes);
2019 let mut decoder = Decoder::new();
crates/ec-vp9/tests/it/scratch_realsweep.rsmodified+4 -4
@@ -17,12 +17,12 @@ use crate::ivf;
1717 use ec_vp9::decode::Decoder;
1818
1919 #[test]
20+#[ignore = "manual sweep: set SWEEP_SRC or SWEEP_IVF"]
2021 fn real_content_sweep() {
2122 let src = std::env::var("SWEEP_SRC").unwrap_or_default();
2223 let prebuilt = std::env::var("SWEEP_IVF").ok();
2324 if src.is_empty() && prebuilt.is_none() {
24- println!("SKIP: set SWEEP_SRC=<video> [SWEEP_N=<frames>] or SWEEP_IVF=<ivf>");
25- return;
25+ panic!("set SWEEP_SRC=<video> or SWEEP_IVF=<ivf>");
2626 }
2727 let n: usize = std::env::var("SWEEP_N")
2828 .ok()
@@ -34,7 +34,7 @@ fn real_content_sweep() {
3434 if let Some(p) = &prebuilt {
3535 std::fs::copy(p, &ivf_path).unwrap();
3636 } else {
37- let enc = std::process::Command::new("ffmpeg")
37+ let enc = ec_testkit::ffmpeg()
3838 .args(["-v", "error", "-y", "-i", &src, "-frames:v"])
3939 .arg(n.to_string())
4040 .args([
@@ -65,7 +65,7 @@ fn real_content_sweep() {
6565 assert!(enc.success(), "ffmpeg encode of {src} failed");
6666 }
6767 // Decode list as a human would, to prove our YUV probe is honest.
68- let raw = std::process::Command::new("ffmpeg")
68+ let raw = ec_testkit::ffmpeg()
6969 .args(["-v", "error", "-i"])
7070 .arg(&ivf_path)
7171 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
crates/ec-vp9/tests/it/scratch_synth.rsdeleted+0 -21
@@ -1,21 +0,0 @@
1-//! [scratch] Parse a synthetic keyframe header dump.
2-//!
3-//! The dump was produced ad hoc in an earlier session and lives in tmpfs
4-//! (`/tmp/synth-kf-frame.bin`), so the test skips - loudly - when it is gone:
5-//! a missing tmpfs fixture is not a regression.
6-use ec_vp9_syntax::Vp9Parser;
7-#[test]
8-fn synth() {
9- let Ok(frame) = std::fs::read("/tmp/synth-kf-frame.bin") else {
10- println!("SKIP: /tmp/synth-kf-frame.bin absent (tmpfs fixture)");
11- return;
12- };
13- let mut p = Vp9Parser::new();
14- match p.parse_frame(&frame) {
15- Ok(h) => println!(
16- "w={} h={} uhs={} hsib={}",
17- h.width, h.height, h.uncompressed_header_size, h.header_size_in_bytes
18- ),
19- Err(e) => println!("ERR {e}"),
20- }
21-}
crates/ec-vp9/tests/it/scratch_tiledbg.rsmodified+2 -4
@@ -6,11 +6,9 @@ use crate::ivf;
66 use ec_vp9_syntax::Vp9Parser;
77
88 #[test]
9+#[ignore = "manual: set TILE_SRC=<ivf>"]
910 fn tile_dbg() {
10- let Ok(src) = std::env::var("TILE_SRC") else {
11- println!("SKIP: set TILE_SRC=<ivf>");
12- return;
13- };
11+ let src = std::env::var("TILE_SRC").expect("set TILE_SRC=<ivf>");
1412 let bytes = std::fs::read(&src).unwrap();
1513 let (_f, w, h, frames) = ivf::parse_ivf(&bytes);
1614 println!("ivf {w}x{h} frames {}", frames.len());
crates/ec-vp9/tests/it/scratch_tok.rsmodified+1 -1
@@ -8,7 +8,7 @@ use ec_vp9::decode::Decoder;
88 #[test]
99 fn dump_tok_trace() {
1010 let path =
11- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp9/key-320.ivf");
11+ ec_testkit::fixture("vp9/key-320.ivf");
1212 let bytes = std::fs::read(&path).unwrap();
1313 let (_f, _w, _h, frames) = ivf::parse_ivf(&bytes);
1414 let mut dec = Decoder::new();
crates/ec-vp9/tests/it/subsampling_exact.rsmodified+4 -25
@@ -2,20 +2,12 @@
22 //! 4:2:2 / 4:4:0 at 8 and 10 bits) and profile 2/3 12-bit decode byte-exact
33 //! against ffmpeg's libvpx.
44 //!
5-//! Every fixture under `tests/data/` is committed (see the lane report for
6-//! the exact generator commands), so these cases always run; the two
7-//! `corpus_*` cases additionally cover the media-gated 4:4:4 corpus streams
8-//! and print SKIP when the fixture is absent -- RED instead under
9-//! `EC_REQUIRE_FIXTURES=1`, so a drifted fixture library can never read as a
10-//! pass.
11-//!
125 //! The comparison is the whole flattened plane stream (u16 samples) against
136 //! ffmpeg's `rawvideo` output for the matching `pix_fmt` — full-resolution
147 //! chroma for 4:4:4, half-width for 4:2:2, half-height for 4:4:0, and the
158 //! 16-bit LE sample layout for 10/12-bit.
169
1710 use crate::ivf;
18-use crate::common::require_fixture;
1911
2012 use ec_vp9::decode::Decoder;
2113 use std::path::{Path, PathBuf};
@@ -26,22 +18,15 @@ fn data(name: &str) -> PathBuf {
2618 .join(name)
2719 }
2820
29-fn corpus(name: &str) -> PathBuf {
30- let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
31- p.pop();
32- p.pop();
33- p.join("fixtures/bitstreams").join(name)
34-}
35-
3621 /// ffmpeg's decoded samples as a flat u16 stream (8-bit zero-extended,
3722 /// 10/12-bit little-endian pairs).
3823 fn ffmpeg_samples(path: &Path, pix_fmt: &str, bd: u8) -> Vec<u16> {
39- let out = std::process::Command::new("ffmpeg")
24+ let out = ec_testkit::ffmpeg()
4025 .args(["-v", "error", "-i"])
4126 .arg(path)
4227 .args(["-f", "rawvideo", "-pix_fmt", pix_fmt, "-"])
4328 .output()
44- .expect("ffmpeg must be on PATH for the witnesses");
29+ .expect("ffmpeg runs for the witnesses");
4530 assert!(out.status.success(), "ffmpeg failed on {path:?}");
4631 if bd == 8 {
4732 out.stdout.iter().map(|&b| b as u16).collect()
@@ -121,18 +106,12 @@ fn profile_matrix_is_byte_exact() {
121106
122107 #[test]
123108 fn corpus_profile1_444_matches_ffmpeg() {
124- let p = corpus("vp9-profile1-444.ivf");
125- if !require_fixture(&p, "scripts/gen-bitstream-fixtures.sh") {
126- return;
127- }
109+ let p = ec_testkit::fixture("bitstreams/vp9-profile1-444.ivf");
128110 check(&p, "yuv444p", 8);
129111 }
130112
131113 #[test]
132114 fn corpus_profile3_444_10bit_matches_ffmpeg() {
133- let p = corpus("vp9-profile3-444-10bit.ivf");
134- if !require_fixture(&p, "scripts/gen-bitstream-fixtures.sh") {
135- return;
136- }
115+ let p = ec_testkit::fixture("bitstreams/vp9-profile3-444-10bit.ivf");
137116 check(&p, "yuv444p10le", 10);
138117 }
crates/ec-vp9/tests/scratch_sweep.rsmodified+2 -4
@@ -4,12 +4,10 @@ use ec_vp9::decode::Decoder;
44 #[test]
55 fn sweep() {
66 std::panic::set_hook(Box::new(|_| {}));
7- let mut p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
8- p.pop(); p.pop();
9- p = p.join("fixtures/vp9/lossless-64.ivf");
7+ let p = ec_testkit::fixture("vp9/lossless-64.ivf");
108 let bytes = std::fs::read(&p).unwrap();
119 let (_, w, h, frames) = ivf::parse_ivf(&bytes);
12- let refout = std::process::Command::new("ffmpeg")
10+ let refout = ec_testkit::ffmpeg()
1311 .args(["-v","error","-i", p.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])
1412 .output().unwrap().stdout;
1513 let ylen = w as usize * h as usize;