ec-av1: route every test-pin write through dumpio::LoudDump
Browse files at this commitf3fd848913ff55a9b17ada3e2f56f3252f9da278Parent: 79a4e313 changed files +204 -32
- crates/ec-av1/src/dumpio.rs +166 -5
- crates/ec-av1/src/msac.rs +9 -9
- crates/ec-av1/src/stream.rs +29 -18
crates/ec-av1/src/dumpio.rsmodified+166 -5
| @@ -155,7 +155,9 @@ impl LoudDump { | |||
| 155 | /// filesystem-level reservation failure all land here rather than in | 155 | /// filesystem-level reservation failure all land here rather than in |
| 156 | /// `write`. | 156 | /// `write`. |
| 157 | pub fn finish(mut self) { | 157 | pub fn finish(mut self) { |
| 158 | - let Some(mut file) = self.file.take() else { return }; | 158 | + let Some(mut file) = self.file.take() else { |
| 159 | + return; | ||
| 160 | + }; | ||
| 159 | if let Err(e) = file.flush() { | 161 | if let Err(e) = file.flush() { |
| 160 | abort( | 162 | abort( |
| 161 | &self.site, | 163 | &self.site, |
| @@ -193,18 +195,83 @@ impl LoudDump { | |||
| 193 | /// The single failure line every short dump now ends on. `site`, the path, the | 195 | /// The single failure line every short dump now ends on. `site`, the path, the |
| 194 | /// bytes on disk vs the bytes owed, and the reason. | 196 | /// bytes on disk vs the bytes owed, and the reason. |
| 195 | fn abort(site: &str, path: &Path, got: usize, expected: Option<usize>, why: &str) -> ! { | 197 | fn abort(site: &str, path: &Path, got: usize, expected: Option<usize>, why: &str) -> ! { |
| 198 | + panic!("{}", failure_line(site, path, got, expected, why)); | ||
| 199 | +} | ||
| 200 | + | ||
| 201 | +/// The failure line itself, so the fatal and the reporting shapes cannot | ||
| 202 | +/// drift apart. | ||
| 203 | +fn failure_line(site: &str, path: &Path, got: usize, expected: Option<usize>, why: &str) -> String { | ||
| 196 | let owed = match expected { | 204 | let owed = match expected { |
| 197 | Some(e) => format!("{e}"), | 205 | Some(e) => format!("{e}"), |
| 198 | None => "an unknown number of".to_string(), | 206 | None => "an unknown number of".to_string(), |
| 199 | }; | 207 | }; |
| 200 | - panic!( | 208 | + format!( |
| 201 | "ec-av1 dump FAILED [{}] {}: wrote {} of {} bytes: {}", | 209 | "ec-av1 dump FAILED [{}] {}: wrote {} of {} bytes: {}", |
| 202 | site, | 210 | site, |
| 203 | path.display(), | 211 | path.display(), |
| 204 | got, | 212 | got, |
| 205 | owed, | 213 | owed, |
| 206 | why | 214 | why |
| 207 | - ); | 215 | + ) |
| 216 | +} | ||
| 217 | + | ||
| 218 | +/// Write `bytes` to `path` as a FATAL pin, loud on any shortfall -- [`pin`]'s | ||
| 219 | +/// counterpart to [`write_planes`], for the single-blob case. | ||
| 220 | +/// | ||
| 221 | +/// lane-av1pinloud: the test-pin sites in `stream.rs` wrote with | ||
| 222 | +/// `let _ = std::fs::write(..)` and then named the path in the panic that | ||
| 223 | +/// followed ("stream pinned at {}"), so an `ENOSPC`/`EFBIG` left a TRUNCATED | ||
| 224 | +/// stream at exactly the path the reader was told to replay -- the same | ||
| 225 | +/// silent-truncation class as the dump path, one hop later. Success path is | ||
| 226 | +/// byte-identical: same bytes, same path, truncate-then-write. | ||
| 227 | +pub fn pin(site: &str, path: impl AsRef<Path>, bytes: &[u8]) { | ||
| 228 | + let mut d = LoudDump::create(site, path, bytes.len()); | ||
| 229 | + d.write(bytes); | ||
| 230 | + d.finish(); | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +/// [`pin`] for a site that must NOT die on a failed pin -- a gate whose real | ||
| 234 | +/// failure is the assert that comes after the pin attempt, and whose comment | ||
| 235 | +/// says so. Non-fatal, but not silent: a shortfall comes back as the very same | ||
| 236 | +/// failure line [`pin`] would have panicked with, expected-vs-on-disk counts | ||
| 237 | +/// included, for the caller to print as a warning. | ||
| 238 | +pub fn pin_reporting(site: &str, path: impl AsRef<Path>, bytes: &[u8]) -> Result<(), String> { | ||
| 239 | + let path = path.as_ref(); | ||
| 240 | + let expected = bytes.len(); | ||
| 241 | + if let Err(e) = std::fs::write(path, bytes) { | ||
| 242 | + let on_disk = std::fs::metadata(path) | ||
| 243 | + .map(|m| m.len() as usize) | ||
| 244 | + .unwrap_or(0); | ||
| 245 | + return Err(failure_line( | ||
| 246 | + site, | ||
| 247 | + path, | ||
| 248 | + on_disk, | ||
| 249 | + Some(expected), | ||
| 250 | + &format!("could not write the pin: {e}"), | ||
| 251 | + )); | ||
| 252 | + } | ||
| 253 | + let on_disk = match std::fs::metadata(path) { | ||
| 254 | + Ok(m) => m.len() as usize, | ||
| 255 | + Err(e) => { | ||
| 256 | + return Err(failure_line( | ||
| 257 | + site, | ||
| 258 | + path, | ||
| 259 | + expected, | ||
| 260 | + Some(expected), | ||
| 261 | + &format!("could not stat the written pin: {e}"), | ||
| 262 | + )); | ||
| 263 | + } | ||
| 264 | + }; | ||
| 265 | + if on_disk != expected { | ||
| 266 | + return Err(failure_line( | ||
| 267 | + site, | ||
| 268 | + path, | ||
| 269 | + on_disk, | ||
| 270 | + Some(expected), | ||
| 271 | + "the pinned file on disk is not the length of the stream", | ||
| 272 | + )); | ||
| 273 | + } | ||
| 274 | + Ok(()) | ||
| 208 | } | 275 | } |
| 209 | 276 | ||
| 210 | /// Write `planes` (already narrowed to their dump's sample width) as ONE dump | 277 | /// Write `planes` (already narrowed to their dump's sample width) as ONE dump |
| @@ -391,9 +458,103 @@ mod tests { | |||
| 391 | if std::env::var("EC_AV1_DUMPLOUD_CHILD").is_err() { | 458 | if std::env::var("EC_AV1_DUMPLOUD_CHILD").is_err() { |
| 392 | return; | 459 | return; |
| 393 | } | 460 | } |
| 394 | - let path = | 461 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |
| 395 | - std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/420_mixll_256x128_6f.obu"); | 462 | + .join("fixtures/420_mixll_256x128_6f.obu"); |
| 396 | let bytes = std::fs::read(&path).expect("the pinned fixture"); | 463 | let bytes = std::fs::read(&path).expect("the pinned fixture"); |
| 397 | let _ = crate::stream::decode_stream(&bytes); | 464 | let _ = crate::stream::decode_stream(&bytes); |
| 398 | } | 465 | } |
| 466 | + | ||
| 467 | + #[test] | ||
| 468 | + fn pin_success_path_is_byte_identical() { | ||
| 469 | + let p = scratch("pin-ok"); | ||
| 470 | + pin("EC_AV1_PIN", &p, b"stream bytes"); | ||
| 471 | + assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); | ||
| 472 | + let _ = std::fs::remove_file(&p); | ||
| 473 | + } | ||
| 474 | + | ||
| 475 | + #[test] | ||
| 476 | + #[cfg(unix)] | ||
| 477 | + fn pin_to_a_full_device_is_loud() { | ||
| 478 | + let msg = caught(|| pin("EC_AV1_PIN", "/dev/full", b"stream bytes")); | ||
| 479 | + assert!( | ||
| 480 | + msg.starts_with("ec-av1 dump FAILED [EC_AV1_PIN] /dev/full: wrote "), | ||
| 481 | + "{msg}" | ||
| 482 | + ); | ||
| 483 | + assert!(msg.contains("No space left on device"), "{msg}"); | ||
| 484 | + assert!(msg.contains(" of 12 bytes"), "{msg}"); | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + /// The reporting shape: same failure line, returned instead of panicked, | ||
| 488 | + /// so a gate whose real failure is the assert after the pin keeps that | ||
| 489 | + /// assert -- but the reader still learns the pin is short. | ||
| 490 | + #[test] | ||
| 491 | + #[cfg(unix)] | ||
| 492 | + fn pin_reporting_is_loud_but_not_fatal() { | ||
| 493 | + let line = pin_reporting("EC_AV1_PIN", "/dev/full", b"stream bytes").unwrap_err(); | ||
| 494 | + assert!( | ||
| 495 | + line.contains("ec-av1 dump FAILED [EC_AV1_PIN] /dev/full"), | ||
| 496 | + "{line}" | ||
| 497 | + ); | ||
| 498 | + assert!(line.contains(" of 12 bytes"), "{line}"); | ||
| 499 | + let p = scratch("pin-reporting-ok"); | ||
| 500 | + pin_reporting("EC_AV1_PIN", &p, b"stream bytes").expect("a healthy pin reports nothing"); | ||
| 501 | + assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); | ||
| 502 | + let _ = std::fs::remove_file(&p); | ||
| 503 | + } | ||
| 504 | + | ||
| 505 | + /// The pin path's own reproduction: a real `RLIMIT_FSIZE` leaves a real | ||
| 506 | + /// truncated stream at the path the panic names. Without the check the | ||
| 507 | + /// reader replays the fragment and blames the decoder. | ||
| 508 | + #[test] | ||
| 509 | + #[cfg(unix)] | ||
| 510 | + fn a_pin_under_a_file_size_cap_fails_loudly() { | ||
| 511 | + let dir = std::env::temp_dir().join(format!("ec-av1-pin-cap-{}", std::process::id())); | ||
| 512 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 513 | + std::fs::create_dir_all(&dir).unwrap(); | ||
| 514 | + let out = Command::new("bash") | ||
| 515 | + .args([ | ||
| 516 | + "-c", | ||
| 517 | + "ulimit -f 8; trap \"\" XFSZ; exec \"$0\" \"$@\"", | ||
| 518 | + std::env::current_exe().unwrap().to_str().unwrap(), | ||
| 519 | + "--exact", | ||
| 520 | + "dumpio::tests::pin_child_under_cap", | ||
| 521 | + "--nocapture", | ||
| 522 | + ]) | ||
| 523 | + .env("EC_AV1_PINLOUD_CHILD", &dir) | ||
| 524 | + .output() | ||
| 525 | + .expect("spawning the capped child"); | ||
| 526 | + let stderr = String::from_utf8_lossy(&out.stderr); | ||
| 527 | + assert!(!out.status.success(), "a short pin must fail\n{stderr}"); | ||
| 528 | + assert!( | ||
| 529 | + stderr.contains("ec-av1 dump FAILED [EC_AV1_PIN]"), | ||
| 530 | + "{stderr}" | ||
| 531 | + ); | ||
| 532 | + assert!(stderr.contains("File too large"), "{stderr}"); | ||
| 533 | + let frag = std::fs::metadata(dir.join("cap-pinned.obu")).unwrap().len(); | ||
| 534 | + assert!( | ||
| 535 | + frag < 32768, | ||
| 536 | + "the capped child left {frag} bytes where 32768 B was owed" | ||
| 537 | + ); | ||
| 538 | + assert!( | ||
| 539 | + stderr.contains(&format!("wrote {frag} of 32768 bytes")), | ||
| 540 | + "{stderr}" | ||
| 541 | + ); | ||
| 542 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 543 | + } | ||
| 544 | + | ||
| 545 | + /// Child half of [`a_pin_under_a_file_size_cap_fails_loudly`]. Not a gate: | ||
| 546 | + /// with no `EC_AV1_PINLOUD_CHILD` set it writes nothing and asserts nothing. | ||
| 547 | + #[test] | ||
| 548 | + fn pin_child_under_cap() { | ||
| 549 | + let Ok(dir) = std::env::var("EC_AV1_PINLOUD_CHILD") else { | ||
| 550 | + return; | ||
| 551 | + }; | ||
| 552 | + // `ulimit -f 8` is 8 KiB, so 4x that is guaranteed to run PAST the cap | ||
| 553 | + // (a write of exactly the cap size succeeds) and land a fragment. | ||
| 554 | + pin( | ||
| 555 | + "EC_AV1_PIN", | ||
| 556 | + Path::new(&dir).join("cap-pinned.obu"), | ||
| 557 | + &[7u8; 32768], | ||
| 558 | + ); | ||
| 559 | + } | ||
| 399 | } | 560 | } |
crates/ec-av1/src/msac.rsmodified+9 -9
| @@ -1133,16 +1133,16 @@ pub(crate) mod symtrace { | |||
| 1133 | let (buf, n) = &mut *b.borrow_mut(); | 1133 | let (buf, n) = &mut *b.borrow_mut(); |
| 1134 | if !buf.is_empty() { | 1134 | if !buf.is_empty() { |
| 1135 | // lane-av1dumploud: loud on a short write. `std::fs::write` | 1135 | // lane-av1dumploud: loud on a short write. `std::fs::write` |
| 1136 | - // returns a `Result` that this used to discard; the expected | 1136 | + // returned a `Result` this used to discard, and the check was |
| 1137 | - // length is exactly the buffer's own. | 1137 | + // hand-rolled against the buffer length only; lane-av1pinloud |
| 1138 | + // folded it into the shared writer so this site also gets the | ||
| 1139 | + // on-disk length check the dump path already had. | ||
| 1138 | let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 1140 | let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 1139 | - let (bytes, at) = (buf.as_bytes(), format!("{dir}/{side}-{seq:05}.txt")); | 1141 | + crate::dumpio::pin( |
| 1140 | - if let Err(e) = std::fs::write(&at, bytes) { | 1142 | + "EC_AV1_SYMTRACE", |
| 1141 | - panic!( | 1143 | + format!("{dir}/{side}-{seq:05}.txt"), |
| 1142 | - "ec-av1 dump FAILED [EC_AV1_SYMTRACE] {at}: wrote 0 of {} bytes: {e}", | 1144 | + buf.as_bytes(), |
| 1143 | - bytes.len() | 1145 | + ); |
| 1144 | - ); | ||
| 1145 | - } | ||
| 1146 | } | 1146 | } |
| 1147 | buf.clear(); | 1147 | buf.clear(); |
| 1148 | *n = 0; | 1148 | *n = 0; |
crates/ec-av1/src/stream.rsmodified+29 -18
| @@ -2214,7 +2214,11 @@ fn decode_frame( | |||
| 2214 | crate::dumpio::write_planes( | 2214 | crate::dumpio::write_planes( |
| 2215 | "EC_AV1_DECODE_ORDER_DUMP", | 2215 | "EC_AV1_DECODE_ORDER_DUMP", |
| 2216 | format!("{path}.f{decode_idx}"), | 2216 | format!("{path}.f{decode_idx}"), |
| 2217 | - &[&narrow(&picture.y), &narrow(&picture.u), &narrow(&picture.v)], | 2217 | + &[ |
| 2218 | + &narrow(&picture.y), | ||
| 2219 | + &narrow(&picture.u), | ||
| 2220 | + &narrow(&picture.v), | ||
| 2221 | + ], | ||
| 2218 | ); | 2222 | ); |
| 2219 | } | 2223 | } |
| 2220 | // lane-hidden r1: the frame exactly as it is about to be stored into | 2224 | // lane-hidden r1: the frame exactly as it is about to be stored into |
| @@ -2257,8 +2261,11 @@ fn decode_frame( | |||
| 2257 | // writer that builds the wrong buffer still gets caught. | 2261 | // writer that builds the wrong buffer still gets caught. |
| 2258 | let sample_width = if bit_depth == 8 { 1 } else { 2 }; | 2262 | let sample_width = if bit_depth == 8 { 1 } else { 2 }; |
| 2259 | let expected = (picture.y.len() + picture.u.len() + picture.v.len()) * sample_width; | 2263 | let expected = (picture.y.len() + picture.u.len() + picture.v.len()) * sample_width; |
| 2260 | - let mut f = | 2264 | + let mut f = crate::dumpio::LoudDump::create( |
| 2261 | - crate::dumpio::LoudDump::create("EC_AV1_FINAL_DUMP", format!("{prefix}.f{decode_idx}"), expected); | 2265 | + "EC_AV1_FINAL_DUMP", |
| 2266 | + format!("{prefix}.f{decode_idx}"), | ||
| 2267 | + expected, | ||
| 2268 | + ); | ||
| 2262 | for plane in [&picture.y, &picture.u, &picture.v] { | 2269 | for plane in [&picture.y, &picture.u, &picture.v] { |
| 2263 | if bit_depth == 8 { | 2270 | if bit_depth == 8 { |
| 2264 | f.write(&plane.iter().map(|&s| s as u8).collect::<Vec<u8>>()); | 2271 | f.write(&plane.iter().map(|&s| s as u8).collect::<Vec<u8>>()); |
| @@ -14188,7 +14195,7 @@ exit 0 | |||
| 14188 | assert_eq!(a.len(), b.len(), "{name}: frame {i} {plane} plane length"); | 14195 | assert_eq!(a.len(), b.len(), "{name}: frame {i} {plane} plane length"); |
| 14189 | if a != b { | 14196 | if a != b { |
| 14190 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); | 14197 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); |
| 14191 | - let _ = std::fs::write(&pin, &stream); | 14198 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 14192 | let at = a | 14199 | let at = a |
| 14193 | .iter() | 14200 | .iter() |
| 14194 | .zip(b.iter()) | 14201 | .zip(b.iter()) |
| @@ -18198,7 +18205,7 @@ exit 0 | |||
| 18198 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 18205 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 18199 | if got.y != want.y || got.u != want.u || got.v != want.v { | 18206 | if got.y != want.y || got.u != want.u || got.v != want.v { |
| 18200 | let pin = std::env::temp_dir().join("ec-av1-10bit-inter-gate-fail.obu"); | 18207 | let pin = std::env::temp_dir().join("ec-av1-10bit-inter-gate-fail.obu"); |
| 18201 | - let _ = std::fs::write(&pin, &stream); | 18208 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 18202 | let first = |a: &Vec<u16>, b: &Vec<u16>| { | 18209 | let first = |a: &Vec<u16>, b: &Vec<u16>| { |
| 18203 | a.iter() | 18210 | a.iter() |
| 18204 | .zip(b) | 18211 | .zip(b) |
| @@ -23167,7 +23174,7 @@ exit 0 | |||
| 23167 | Ok(frames) => frames, | 23174 | Ok(frames) => frames, |
| 23168 | Err(e) => { | 23175 | Err(e) => { |
| 23169 | let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); | 23176 | let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); |
| 23170 | - let _ = std::fs::write(&pin, &stream); | 23177 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 23171 | panic!( | 23178 | panic!( |
| 23172 | "{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", | 23179 | "{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", |
| 23173 | pin.display() | 23180 | pin.display() |
| @@ -23187,7 +23194,7 @@ exit 0 | |||
| 23187 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 23194 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 23188 | if got.y != want.y || got.u != want.u || got.v != want.v { | 23195 | if got.y != want.y || got.u != want.u || got.v != want.v { |
| 23189 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); | 23196 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); |
| 23190 | - let _ = std::fs::write(&pin, &stream); | 23197 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 23191 | panic!( | 23198 | panic!( |
| 23192 | "{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", | 23199 | "{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", |
| 23193 | pin.display() | 23200 | pin.display() |
| @@ -23586,7 +23593,7 @@ exit 0 | |||
| 23586 | } | 23593 | } |
| 23587 | Err(e) => { | 23594 | Err(e) => { |
| 23588 | let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); | 23595 | let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); |
| 23589 | - let _ = std::fs::write(&pin, &stream); | 23596 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 23590 | panic!( | 23597 | panic!( |
| 23591 | "{name}: decode_stream failed on a real aomenc stream (cq={cq} period={period}): {e} (pinned at {})", | 23598 | "{name}: decode_stream failed on a real aomenc stream (cq={cq} period={period}): {e} (pinned at {})", |
| 23592 | pin.display() | 23599 | pin.display() |
| @@ -23608,7 +23615,7 @@ exit 0 | |||
| 23608 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 23615 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 23609 | if got.y != want.y || got.u != want.u || got.v != want.v { | 23616 | if got.y != want.y || got.u != want.u || got.v != want.v { |
| 23610 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); | 23617 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); |
| 23611 | - let _ = std::fs::write(&pin, &stream); | 23618 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 23612 | panic!( | 23619 | panic!( |
| 23613 | "{name}: frame {i} mismatch vs ffmpeg (cq={cq} period={period}) -- stream pinned at {}", | 23620 | "{name}: frame {i} mismatch vs ffmpeg (cq={cq} period={period}) -- stream pinned at {}", |
| 23614 | pin.display() | 23621 | pin.display() |
| @@ -27901,7 +27908,7 @@ exit 0 | |||
| 27901 | "ec-av1-deblocking-gate-fail-s{}-cq{cq}.obu", | 27908 | "ec-av1-deblocking-gate-fail-s{}-cq{cq}.obu", |
| 27902 | 42 + round | 27909 | 42 + round |
| 27903 | )); | 27910 | )); |
| 27904 | - let _ = std::fs::write(&pin, &stream); | 27911 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 27905 | panic!( | 27912 | panic!( |
| 27906 | "frame {i} mismatch vs ffmpeg (seed {} cq {cq}, deblock fired: \ | 27913 | "frame {i} mismatch vs ffmpeg (seed {} cq {cq}, deblock fired: \ |
| 27907 | {counted}) -- stream pinned at {}", | 27914 | {counted}) -- stream pinned at {}", |
| @@ -28134,14 +28141,18 @@ exit 0 | |||
| 28134 | // The pin goes to `fixtures/`, which outlives the session: an | 28141 | // The pin goes to `fixtures/`, which outlives the session: an |
| 28135 | // earlier version wrote to a session scratchpad, so once tmpfs | 28142 | // earlier version wrote to a session scratchpad, so once tmpfs |
| 28136 | // reaped it a real mismatch aborted on the write instead of | 28143 | // reaped it a real mismatch aborted on the write instead of |
| 28137 | - // reporting itself. A failed write must not mask the assert | 28144 | + // reporting itself. A failed write must not mask the asserts |
| 28138 | - // below either, so it warns rather than panicking. | 28145 | + // below either, so it warns rather than panicking -- lane-av1pinloud |
| 28146 | + // routed it through `pin_reporting` rather than bare `fs::write`, | ||
| 28147 | + // so the warning now carries on-disk-vs-owed byte counts: a | ||
| 28148 | + // truncated pin was as silent here as anywhere else, and this | ||
| 28149 | + // is the one site where dying on the write is wrong. | ||
| 28139 | let sp = pin_dir(); | 28150 | let sp = pin_dir(); |
| 28140 | let stream_pin = sp.join(format!("cdfflake-stream-seed{seed}.bin")); | 28151 | let stream_pin = sp.join(format!("cdfflake-stream-seed{seed}.bin")); |
| 28141 | let ref_pin = sp.join(format!("cdfflake-ffmpeg-raw-seed{seed}.bin")); | 28152 | let ref_pin = sp.join(format!("cdfflake-ffmpeg-raw-seed{seed}.bin")); |
| 28142 | for (path, bytes) in [(&stream_pin, &stream), (&ref_pin, &ffmpeg_raw)] { | 28153 | for (path, bytes) in [(&stream_pin, &stream), (&ref_pin, &ffmpeg_raw)] { |
| 28143 | - if let Err(e) = std::fs::write(path, bytes) { | 28154 | + if let Err(line) = crate::dumpio::pin_reporting("EC_AV1_PIN", path, bytes) { |
| 28144 | - eprintln!("cdfflake: could not pin to {}: {e}", path.display()); | 28155 | + eprintln!("cdfflake: {line}"); |
| 28145 | } | 28156 | } |
| 28146 | } | 28157 | } |
| 28147 | eprintln!( | 28158 | eprintln!( |
| @@ -28893,9 +28904,9 @@ exit 0 | |||
| 28893 | if mismatched { | 28904 | if mismatched { |
| 28894 | let pin = | 28905 | let pin = |
| 28895 | std::env::temp_dir().join("ec-av1-reference-select-gate-fail.obu"); | 28906 | std::env::temp_dir().join("ec-av1-reference-select-gate-fail.obu"); |
| 28896 | - let _ = std::fs::write(&pin, &stream); | 28907 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 28897 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | 28908 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { |
| 28898 | - std::fs::write(&path, &stream).expect("writing pinned stream"); | 28909 | + crate::dumpio::pin("EC_AV1_GATE_DUMP", &path, &stream); |
| 28899 | eprintln!( | 28910 | eprintln!( |
| 28900 | "EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}" | 28911 | "EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}" |
| 28901 | ); | 28912 | ); |
| @@ -29103,9 +29114,9 @@ exit 0 | |||
| 29103 | .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | 29114 | .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); |
| 29104 | if mismatched { | 29115 | if mismatched { |
| 29105 | let pin = std::env::temp_dir().join("ec-av1-compound-refs-gate-fail.obu"); | 29116 | let pin = std::env::temp_dir().join("ec-av1-compound-refs-gate-fail.obu"); |
| 29106 | - let _ = std::fs::write(&pin, &stream); | 29117 | + crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); |
| 29107 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | 29118 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { |
| 29108 | - std::fs::write(&path, &stream).expect("writing pinned stream"); | 29119 | + crate::dumpio::pin("EC_AV1_GATE_DUMP", &path, &stream); |
| 29109 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | 29120 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
| 29110 | } | 29121 | } |
| 29111 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 29122 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |