forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-hwwt' (a191a35b): test fixture selection matched the whole checkout path, so a worktree named after a codec fed foreign fixtures to it; swept to ec-image/ec-ogg/ec-mp4

Browse files at this commit

c9c94fc17e1bf7bb599248fd0d27588c43d0a403Ahmet Kaan GümüşParent: 6c19568a8b31aa
crates/ec-hw/tests/gpu.rsmodified+32 -3
@@ -366,13 +366,23 @@ fn compare_against_ffmpeg(files: &[PathBuf], codec: Codec, ten_bit: bool) {
366366 }
367367 }
368368
369+/// The fixture's own name. Never the whole path: a checkout directory called
370+/// `edith_codecs-av1fast` made every `.ivf` — VP9 included — select as an AV1
371+/// fixture, and the VP9 streams then came back as `obu_forbidden_bit is set`.
372+fn name_of(p: &Path) -> String {
373+ p.file_name()
374+ .unwrap_or_default()
375+ .to_string_lossy()
376+ .to_string()
377+}
378+
369379 /// The 4:2:0 fixtures of one kind; the 4:4:4 and monochrome ones are the
370380 /// profiles this GPU does not decode, and have their own test.
371381 fn profile_420(pattern: &str, codec: &str) -> Vec<PathBuf> {
372382 fixtures(pattern)
373383 .into_iter()
374384 .filter(|p| {
375- let name = p.to_string_lossy().to_string();
385+ let name = name_of(p);
376386 name.contains(codec) && !name.contains("444") && !name.contains("monochrome")
377387 })
378388 .collect()
@@ -381,17 +391,36 @@ fn profile_420(pattern: &str, codec: &str) -> Vec<PathBuf> {
381391 fn eight_bit(pattern: &str, codec: &str) -> Vec<PathBuf> {
382392 profile_420(pattern, codec)
383393 .into_iter()
384- .filter(|p| !p.to_string_lossy().contains("10bit"))
394+ .filter(|p| !name_of(p).contains("10bit"))
385395 .collect()
386396 }
387397
388398 fn ten_bit(pattern: &str, codec: &str) -> Vec<PathBuf> {
389399 profile_420(pattern, codec)
390400 .into_iter()
391- .filter(|p| p.to_string_lossy().contains("10bit"))
401+ .filter(|p| name_of(p).contains("10bit"))
392402 .collect()
393403 }
394404
405+/// The selection must not depend on where the repository is checked out.
406+#[test]
407+fn fixture_selection_ignores_the_checkout_path() {
408+ for p in eight_bit(".ivf", "av1") {
409+ let name = name_of(&p);
410+ assert!(
411+ name.starts_with("av1") && !name.contains("10bit"),
412+ "{name} is not an 8-bit AV1 fixture"
413+ );
414+ }
415+ for p in ten_bit(".ivf", "vp9") {
416+ let name = name_of(&p);
417+ assert!(
418+ name.starts_with("vp9") && name.contains("10bit"),
419+ "{name} is not a 10-bit VP9 fixture"
420+ );
421+ }
422+}
423+
395424 #[test]
396425 fn h264_matches_ffmpeg() {
397426 compare_against_ffmpeg(&fixtures(".264"), Codec::H264, false);
crates/ec-image/tests/differential.rsmodified+12 -3
@@ -11,6 +11,15 @@
1111 use image::GenericImageView;
1212 use std::path::{Path, PathBuf};
1313
14+/// The fixture's own name — never the whole path, which carries the checkout
15+/// directory and has matched fixture keywords by accident.
16+fn name_of(p: &std::path::Path) -> String {
17+ p.file_name()
18+ .unwrap_or_default()
19+ .to_string_lossy()
20+ .to_string()
21+}
22+
1423 fn fixtures() -> PathBuf {
1524 Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/stills")
1625 }
@@ -115,7 +124,7 @@ fn png_decodes_pixel_exactly() {
115124 fn webp_lossless_decodes_pixel_exactly() {
116125 let files: Vec<PathBuf> = corpus("webp")
117126 .into_iter()
118- .filter(|p| p.to_string_lossy().contains("lossless"))
127+ .filter(|p| name_of(p).contains("lossless"))
119128 .collect();
120129 if files.is_empty() && skip("webp") {
121130 return;
@@ -183,7 +192,7 @@ fn jpeg_matches_the_incumbent_within_rounding() {
183192 fn webp_lossy_reconstructs_at_least_as_well_as_the_incumbent() {
184193 let files: Vec<PathBuf> = corpus("webp")
185194 .into_iter()
186- .filter(|p| p.to_string_lossy().contains("lossy"))
195+ .filter(|p| name_of(p).contains("lossy"))
187196 .collect();
188197 if files.is_empty() && skip("webp") {
189198 return;
@@ -235,7 +244,7 @@ fn header_dimensions_match_the_incumbent() {
235244 let mut checked = 0;
236245 for extension in ["png", "jpg", "webp"] {
237246 for path in corpus(extension) {
238- if path.to_string_lossy().contains("animated") {
247+ if name_of(&path).contains("animated") {
239248 continue;
240249 }
241250 let bytes = std::fs::read(&path).unwrap();
crates/ec-mp4/tests/mp4.rsmodified+1 -1
@@ -246,7 +246,7 @@ fn every_fixture_demuxes_into_the_streams_ffprobe_reports() {
246246 rates[i],
247247 avg_rates[i]
248248 );
249- if path.to_string_lossy().contains("23.976") {
249+ if name_of(&path).contains("23.976") {
250250 assert_eq!(
251251 video.frame_rate,
252252 Some(TimeBase::new(24_000, 1001)),
crates/ec-ogg/tests/ogg.rsmodified+12 -3
@@ -19,6 +19,15 @@ use ec_core::{
1919 };
2020 use ec_ogg::{Mapping, OggDemuxer, OggMuxer, granule_of, granule_side_data};
2121
22+/// The fixture's own name — never the whole path, which carries the checkout
23+/// directory and has matched fixture keywords by accident.
24+fn name_of(p: &std::path::Path) -> String {
25+ p.file_name()
26+ .unwrap_or_default()
27+ .to_string_lossy()
28+ .to_string()
29+}
30+
2231 fn fixtures() -> PathBuf {
2332 Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/audio")
2433 }
@@ -327,7 +336,7 @@ fn page_size_does_not_change_the_audio() {
327336 let files = ogg_fixtures();
328337 let Some(path) = files
329338 .iter()
330- .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-48000"))
339+ .find(|p| name_of(p).contains("vorbis-ogg-stereo-48000"))
331340 else {
332341 eprintln!("fixtures absent — skipping");
333342 return;
@@ -341,7 +350,7 @@ fn damage_costs_one_page_and_no_more() {
341350 let files = ogg_fixtures();
342351 let Some(path) = files
343352 .iter()
344- .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-44100"))
353+ .find(|p| name_of(p).contains("vorbis-ogg-stereo-44100"))
345354 else {
346355 eprintln!("fixtures absent — skipping");
347356 return;
@@ -458,7 +467,7 @@ fn reads_flac_in_ogg() {
458467 let files = ogg_fixtures();
459468 let Some(source) = files
460469 .iter()
461- .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-44100"))
470+ .find(|p| name_of(p).contains("vorbis-ogg-stereo-44100"))
462471 else {
463472 eprintln!("fixtures absent — skipping");
464473 return;