ec-av1 r2: label the pin site TEST_PIN, correct the pin/pin_reporting doc split, amend the sweep rows
Browse files at this commit2d08a6d2eae8b5be2c700dcfd74330410e325e9eParent: 4dcc8443 changed files +72 -47
- crates/ec-av1/src/dumpio.rs +25 -18
- crates/ec-av1/src/stream.rs +10 -10
- lanes/av1pinloud.report.md +37 -19
crates/ec-av1/src/dumpio.rsmodified+25 -18
| @@ -215,8 +215,9 @@ fn failure_line(site: &str, path: &Path, got: usize, expected: Option<usize>, wh | ||
| 215 | 215 | ) |
| 216 | 216 | } |
| 217 | 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. | |
| 218 | +/// Write `bytes` to `path` as a FATAL pin: [`pin`] IS a wrapper -- three | |
| 219 | +/// [`LoudDump`] calls (`create`/`write`/`finish`), so it inherits the flush and | |
| 220 | +/// the flush-then-stat ordering for free. | |
| 220 | 221 | /// |
| 221 | 222 | /// lane-av1pinloud: the test-pin sites in `stream.rs` wrote with |
| 222 | 223 | /// `let _ = std::fs::write(..)` and then named the path in the panic that |
| @@ -230,11 +231,20 @@ pub fn pin(site: &str, path: impl AsRef<Path>, bytes: &[u8]) { | ||
| 230 | 231 | d.finish(); |
| 231 | 232 | } |
| 232 | 233 | |
| 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. | |
| 234 | +/// [`pin`]'s NON-FATAL twin, for a site that must not die on a failed pin -- a | |
| 235 | +/// gate whose real failure is the assert that comes after the pin attempt, and | |
| 236 | +/// whose comment says so. | |
| 237 | +/// | |
| 238 | +/// This one RE-IMPLEMENTS the check rather than wrapping [`LoudDump`], whose | |
| 239 | +/// failure channel is `panic!`: it cannot report instead of dying. So it does | |
| 240 | +/// `fs::write` + `metadata` itself. Only the failure LINE is shared, via | |
| 241 | +/// [`failure_line`] -- the ordering (flush-then-stat) and the | |
| 242 | +/// write-error-handling are not shared with [`LoudDump`], and a reader must not | |
| 243 | +/// assume they are. | |
| 244 | +/// | |
| 245 | +/// Non-fatal, but not silent: a shortfall comes back as the very same failure | |
| 246 | +/// line [`pin`] would have panicked with, expected-vs-on-disk counts included, | |
| 247 | +/// for the caller to print as a warning. | |
| 238 | 248 | pub fn pin_reporting(site: &str, path: impl AsRef<Path>, bytes: &[u8]) -> Result<(), String> { |
| 239 | 249 | let path = path.as_ref(); |
| 240 | 250 | let expected = bytes.len(); |
| @@ -467,7 +477,7 @@ mod tests { | ||
| 467 | 477 | #[test] |
| 468 | 478 | fn pin_success_path_is_byte_identical() { |
| 469 | 479 | let p = scratch("pin-ok"); |
| 470 | - pin("EC_AV1_PIN", &p, b"stream bytes"); | |
| 480 | + pin("TEST_PIN", &p, b"stream bytes"); | |
| 471 | 481 | assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); |
| 472 | 482 | let _ = std::fs::remove_file(&p); |
| 473 | 483 | } |
| @@ -475,9 +485,9 @@ mod tests { | ||
| 475 | 485 | #[test] |
| 476 | 486 | #[cfg(unix)] |
| 477 | 487 | fn pin_to_a_full_device_is_loud() { |
| 478 | - let msg = caught(|| pin("EC_AV1_PIN", "/dev/full", b"stream bytes")); | |
| 488 | + let msg = caught(|| pin("TEST_PIN", "/dev/full", b"stream bytes")); | |
| 479 | 489 | assert!( |
| 480 | - msg.starts_with("ec-av1 dump FAILED [EC_AV1_PIN] /dev/full: wrote "), | |
| 490 | + msg.starts_with("ec-av1 dump FAILED [TEST_PIN] /dev/full: wrote "), | |
| 481 | 491 | "{msg}" |
| 482 | 492 | ); |
| 483 | 493 | assert!(msg.contains("No space left on device"), "{msg}"); |
| @@ -490,14 +500,14 @@ mod tests { | ||
| 490 | 500 | #[test] |
| 491 | 501 | #[cfg(unix)] |
| 492 | 502 | fn pin_reporting_is_loud_but_not_fatal() { |
| 493 | - let line = pin_reporting("EC_AV1_PIN", "/dev/full", b"stream bytes").unwrap_err(); | |
| 503 | + let line = pin_reporting("TEST_PIN", "/dev/full", b"stream bytes").unwrap_err(); | |
| 494 | 504 | assert!( |
| 495 | - line.contains("ec-av1 dump FAILED [EC_AV1_PIN] /dev/full"), | |
| 505 | + line.contains("ec-av1 dump FAILED [TEST_PIN] /dev/full"), | |
| 496 | 506 | "{line}" |
| 497 | 507 | ); |
| 498 | 508 | assert!(line.contains(" of 12 bytes"), "{line}"); |
| 499 | 509 | let p = scratch("pin-reporting-ok"); |
| 500 | - pin_reporting("EC_AV1_PIN", &p, b"stream bytes").expect("a healthy pin reports nothing"); | |
| 510 | + pin_reporting("TEST_PIN", &p, b"stream bytes").expect("a healthy pin reports nothing"); | |
| 501 | 511 | assert_eq!(std::fs::read(&p).unwrap(), b"stream bytes"); |
| 502 | 512 | let _ = std::fs::remove_file(&p); |
| 503 | 513 | } |
| @@ -525,10 +535,7 @@ mod tests { | ||
| 525 | 535 | .expect("spawning the capped child"); |
| 526 | 536 | let stderr = String::from_utf8_lossy(&out.stderr); |
| 527 | 537 | 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 | - ); | |
| 538 | + assert!(stderr.contains("ec-av1 dump FAILED [TEST_PIN]"), "{stderr}"); | |
| 532 | 539 | assert!(stderr.contains("File too large"), "{stderr}"); |
| 533 | 540 | let frag = std::fs::metadata(dir.join("cap-pinned.obu")).unwrap().len(); |
| 534 | 541 | assert!( |
| @@ -552,7 +559,7 @@ mod tests { | ||
| 552 | 559 | // `ulimit -f 8` is 8 KiB, so 4x that is guaranteed to run PAST the cap |
| 553 | 560 | // (a write of exactly the cap size succeeds) and land a fragment. |
| 554 | 561 | pin( |
| 555 | - "EC_AV1_PIN", | |
| 562 | + "TEST_PIN", | |
| 556 | 563 | Path::new(&dir).join("cap-pinned.obu"), |
| 557 | 564 | &[7u8; 32768], |
| 558 | 565 | ); |
crates/ec-av1/src/stream.rsmodified+10 -10
| @@ -14195,7 +14195,7 @@ exit 0 | ||
| 14195 | 14195 | assert_eq!(a.len(), b.len(), "{name}: frame {i} {plane} plane length"); |
| 14196 | 14196 | if a != b { |
| 14197 | 14197 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); |
| 14198 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 14198 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 14199 | 14199 | let at = a |
| 14200 | 14200 | .iter() |
| 14201 | 14201 | .zip(b.iter()) |
| @@ -18205,7 +18205,7 @@ exit 0 | ||
| 18205 | 18205 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 18206 | 18206 | if got.y != want.y || got.u != want.u || got.v != want.v { |
| 18207 | 18207 | let pin = std::env::temp_dir().join("ec-av1-10bit-inter-gate-fail.obu"); |
| 18208 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 18208 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 18209 | 18209 | let first = |a: &Vec<u16>, b: &Vec<u16>| { |
| 18210 | 18210 | a.iter() |
| 18211 | 18211 | .zip(b) |
| @@ -23174,7 +23174,7 @@ exit 0 | ||
| 23174 | 23174 | Ok(frames) => frames, |
| 23175 | 23175 | Err(e) => { |
| 23176 | 23176 | let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); |
| 23177 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 23177 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 23178 | 23178 | panic!( |
| 23179 | 23179 | "{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", |
| 23180 | 23180 | pin.display() |
| @@ -23194,7 +23194,7 @@ exit 0 | ||
| 23194 | 23194 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 23195 | 23195 | if got.y != want.y || got.u != want.u || got.v != want.v { |
| 23196 | 23196 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); |
| 23197 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 23197 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 23198 | 23198 | panic!( |
| 23199 | 23199 | "{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", |
| 23200 | 23200 | pin.display() |
| @@ -23593,7 +23593,7 @@ exit 0 | ||
| 23593 | 23593 | } |
| 23594 | 23594 | Err(e) => { |
| 23595 | 23595 | let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); |
| 23596 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 23596 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 23597 | 23597 | panic!( |
| 23598 | 23598 | "{name}: decode_stream failed on a real aomenc stream (cq={cq} period={period}): {e} (pinned at {})", |
| 23599 | 23599 | pin.display() |
| @@ -23615,7 +23615,7 @@ exit 0 | ||
| 23615 | 23615 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 23616 | 23616 | if got.y != want.y || got.u != want.u || got.v != want.v { |
| 23617 | 23617 | let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); |
| 23618 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 23618 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 23619 | 23619 | panic!( |
| 23620 | 23620 | "{name}: frame {i} mismatch vs ffmpeg (cq={cq} period={period}) -- stream pinned at {}", |
| 23621 | 23621 | pin.display() |
| @@ -27908,7 +27908,7 @@ exit 0 | ||
| 27908 | 27908 | "ec-av1-deblocking-gate-fail-s{}-cq{cq}.obu", |
| 27909 | 27909 | 42 + round |
| 27910 | 27910 | )); |
| 27911 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 27911 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 27912 | 27912 | panic!( |
| 27913 | 27913 | "frame {i} mismatch vs ffmpeg (seed {} cq {cq}, deblock fired: \ |
| 27914 | 27914 | {counted}) -- stream pinned at {}", |
| @@ -28151,7 +28151,7 @@ exit 0 | ||
| 28151 | 28151 | let stream_pin = sp.join(format!("cdfflake-stream-seed{seed}.bin")); |
| 28152 | 28152 | let ref_pin = sp.join(format!("cdfflake-ffmpeg-raw-seed{seed}.bin")); |
| 28153 | 28153 | for (path, bytes) in [(&stream_pin, &stream), (&ref_pin, &ffmpeg_raw)] { |
| 28154 | - if let Err(line) = crate::dumpio::pin_reporting("EC_AV1_PIN", path, bytes) { | |
| 28154 | + if let Err(line) = crate::dumpio::pin_reporting("TEST_PIN", path, bytes) { | |
| 28155 | 28155 | eprintln!("cdfflake: {line}"); |
| 28156 | 28156 | } |
| 28157 | 28157 | } |
| @@ -28904,7 +28904,7 @@ exit 0 | ||
| 28904 | 28904 | if mismatched { |
| 28905 | 28905 | let pin = |
| 28906 | 28906 | std::env::temp_dir().join("ec-av1-reference-select-gate-fail.obu"); |
| 28907 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 28907 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 28908 | 28908 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { |
| 28909 | 28909 | crate::dumpio::pin("EC_AV1_GATE_DUMP", &path, &stream); |
| 28910 | 28910 | eprintln!( |
| @@ -29114,7 +29114,7 @@ exit 0 | ||
| 29114 | 29114 | .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); |
| 29115 | 29115 | if mismatched { |
| 29116 | 29116 | let pin = std::env::temp_dir().join("ec-av1-compound-refs-gate-fail.obu"); |
| 29117 | - crate::dumpio::pin("EC_AV1_PIN", &pin, &stream); | |
| 29117 | + crate::dumpio::pin("TEST_PIN", &pin, &stream); | |
| 29118 | 29118 | if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { |
| 29119 | 29119 | crate::dumpio::pin("EC_AV1_GATE_DUMP", &path, &stream); |
| 29120 | 29120 | eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); |
lanes/av1pinloud.report.mdmodified+37 -19
| @@ -22,8 +22,8 @@ length. | ||
| 22 | 22 | |
| 23 | 23 | ## Change |
| 24 | 24 | |
| 25 | -`crates/ec-av1/src/dumpio.rs` gains two wrappers over the existing `LoudDump`, plus a | |
| 26 | -`failure_line` helper so the fatal and reporting shapes cannot drift: | |
| 25 | +`crates/ec-av1/src/dumpio.rs` gains two pin helpers plus a `failure_line` helper so the | |
| 26 | +fatal and reporting message shapes cannot drift: | |
| 27 | 27 | |
| 28 | 28 | - `pin(site, path, bytes)` — fatal. Same shape as `write_planes` for a single blob: |
| 29 | 29 | create, `write_all`, then stat the file and compare against `bytes.len()`. |
| @@ -31,32 +31,49 @@ length. | ||
| 31 | 31 | truncate-then-write. |
| 32 | 32 | - `pin_reporting(site, path, bytes) -> Result<(), String>` — non-fatal, not silent. |
| 33 | 33 | Returns the **same** failure line `pin` would have panicked with |
| 34 | - (`ec-av1 dump FAILED [EC_AV1_PIN] <path>: wrote N of M bytes: <why>`). | |
| 34 | + (`ec-av1 dump FAILED [TEST_PIN] <path>: wrote N of M bytes: <why>`). | |
| 35 | 35 | |
| 36 | -All nine pin sites now call `pin("EC_AV1_PIN", ...)`; both `EC_AV1_GATE_DUMP` writes | |
| 37 | -call `pin("EC_AV1_GATE_DUMP", ...)` (previously `fs::write(...).expect(...)`, loud on a | |
| 38 | -write error but blind to a short file on disk). | |
| 36 | +These are NOT both wrappers over `LoudDump`, and the difference is load-bearing: | |
| 37 | + | |
| 38 | +- `pin` **is** a wrapper — three `LoudDump` calls (`create`/`write`/`finish`), so it | |
| 39 | + inherits the flush and the flush-then-stat ordering for free. | |
| 40 | +- `pin_reporting` **re-implements** the check with `fs::write` + `metadata`, because | |
| 41 | + `LoudDump`'s failure channel is `panic!` and this site must not die. Only the failure | |
| 42 | + *line* is shared (via `failure_line`); the ordering is not. | |
| 43 | + | |
| 44 | +All nine pin sites now call `pin("TEST_PIN", ...)`; both `EC_AV1_GATE_DUMP` writes call | |
| 45 | +`pin("EC_AV1_GATE_DUMP", ...)` (previously `fs::write(...).expect(...)`, loud on a write | |
| 46 | +error but blind to a short file on disk). | |
| 39 | 47 | |
| 40 | 48 | One more in-crate site of the same shape: `msac.rs:1140` (`EC_AV1_SYMTRACE` flush) had a |
| 41 | 49 | hand-rolled panic that compared the buffer length but never stat'ed the file. Folded |
| 42 | 50 | into `pin` so it gets the on-disk check. |
| 43 | 51 | |
| 52 | +### Site label | |
| 53 | + | |
| 54 | +The label is **`TEST_PIN`**, deliberately outside the `EC_AV1_*` env-var namespace: no | |
| 55 | +env var of that name exists (a real `EC_AV1_PIN` env var does — the scratch replay | |
| 56 | +helper's — and reusing that name would have pointed a triager at the wrong thing), and | |
| 57 | +every other failure-line label in this module names the env var that triggers the write. | |
| 58 | +`EC_AV1_GATE_DUMP` and `EC_AV1_SYMTRACE` keep their real env-var names because they *are* | |
| 59 | +real env vars. | |
| 60 | + | |
| 44 | 61 | ### `stream.rs:28143` — the warns-by-design site: decision |
| 45 | 62 | |
| 46 | 63 | Routed through `pin_reporting`, keeping it non-fatal. The two shapes differ for a |
| 47 | 64 | stated reason, not by accident: |
| 48 | 65 | |
| 49 | 66 | - the nine sites run **inside the arm that is already panicking** — the pin exists to |
| 50 | - feed that panic, so dying on a short pin replaces a message with a strictly better | |
| 51 | - one (same panic, plus the byte counts). | |
| 67 | + feed that panic, so dying on a short pin replaces a message with a strictly better one | |
| 68 | + (same panic, plus the byte counts). | |
| 52 | 69 | - 28143's real failure is the `assert_eq!` three lines below (luma/U/V vs ffmpeg). |
| 53 | 70 | Panicking on the write would **mask that assert** with an unrelated filesystem |
| 54 | 71 | error — the exact failure its comment refuses. So it must not be fatal. |
| 55 | 72 | |
| 56 | -What changed is what it *prints*: the old `could not pin to {path}: {e}` warning | |
| 57 | -became `cdfflake: ec-av1 dump FAILED [EC_AV1_PIN] {path}: wrote N of M bytes: {why}` — | |
| 58 | -same severity (a warning, then the asserts run), now carrying expected-vs-on-disk | |
| 59 | -counts. A truncated pin there was previously indistinguishable from a good one. | |
| 73 | +What changed is what it *prints*: the old `could not pin to {path}: {e}` warning became | |
| 74 | +`cdfflake: ec-av1 dump FAILED [TEST_PIN] {path}: wrote N of M bytes: {why}` — same | |
| 75 | +severity (a warning, then the asserts run), now carrying expected-vs-on-disk counts. A | |
| 76 | +truncated pin there was previously indistinguishable from a good one. | |
| 60 | 77 | |
| 61 | 78 | ## Proof |
| 62 | 79 | |
| @@ -67,7 +84,7 @@ counts, not carrying on. | ||
| 67 | 84 | ``` |
| 68 | 85 | $ EC_AV1_PINLOUD_CHILD=/tmp/pincap2 bash -c 'ulimit -f 8; trap "" XFSZ; exec "$0" "$@"' \ |
| 69 | 86 | <testbin> --exact dumpio::tests::pin_child_under_cap --nocapture |
| 70 | -ec-av1 dump FAILED [EC_AV1_PIN] /tmp/pincap2/cap-pinned.obu: wrote 8192 of 32768 bytes: | |
| 87 | +ec-av1 dump FAILED [TEST_PIN] /tmp/pincap2/cap-pinned.obu: wrote 8192 of 32768 bytes: | |
| 71 | 88 | write failed with 0 bytes confirmed in hand: File too large (os error 27) |
| 72 | 89 | test dumpio::tests::pin_child_under_cap ... FAILED |
| 73 | 90 | $ ls -l /tmp/pincap2 |
| @@ -100,13 +117,14 @@ every `ec-*` crate: | ||
| 100 | 117 | |---|---|---| |
| 101 | 118 | | `ec-vorbis/tests/oracle.rs:1447,1452` | `let _ = fs::write` of sweep tables into `lanes/*.txt` | **Reported, not fixed.** Not the same shape: the path is not printed in a failure message, the file is a human-read report rather than a replay artefact, and the asserts that follow (`rows > 0`, `failures.is_empty()`) do not depend on it. Sibling lane material. | |
| 102 | 119 | | `ec-ac3/examples/ac3dec.rs:89,96` | `let _ = out.write_all(..)` to raw stdout of an example decoder | **Reported, not fixed.** No path is named; a short write there is the encoder of a raw file a downstream `cmp` measures. Different class (unverified output, not a mis-pointed replay path). | |
| 103 | -| `ec-h264/tests/encode.rs:475,1068`, `ec-h265/tests/encode.rs:289,341` | `std::fs::write(..).ok()?` feeding an `ffmpeg` subprocess | **Reported, not fixed.** `.ok()?` propagates the failure as `None` — the test helper bails rather than decoding a truncated file, so there is no silent-truncation path to close. | | |
| 120 | +| `ec-h264/tests/encode.rs:475,1068`, `ec-h265/tests/encode.rs:289,341` | `std::fs::write(..).ok()?` feeding an `ffmpeg` subprocess | **Reported, NOT fixed — half-open.** The `Err` path IS closed: `.ok()?` propagates the failure as `None` and the helper bails instead of running ffmpeg on a fragment. The `Ok`-but-short path is NOT closed: `fs::write` returning `Ok` does not guarantee the on-disk length — exactly the gap `LoudDump::finish()` exists to close — and these sites have no equivalent, the file going straight to ffmpeg as decoder input. Same mis-pointed-artefact family, one hop removed. A following lane should route these four through a loud writer; those crates have no shared helper yet, so the fix is per-crate. | | |
| 104 | 121 | |
| 105 | -No sibling site has the "discard the error, then hand the reader that exact path" | |
| 106 | -shape. Fixed only `ec-av1`. | |
| 122 | +Two of the sibling shapes are open in the weaker sense above; none of the sibling sites | |
| 123 | +has the "discard the error, then hand the reader that exact path" shape. Fixed only | |
| 124 | +`ec-av1` (plus its own msac site). | |
| 107 | 125 | |
| 108 | 126 | ## Notes for the reviewer |
| 109 | 127 | |
| 110 | -- Success path is byte-identical; the only behavioural delta is that a short pin is | |
| 111 | - now fatal (9 sites + 2 gate dumps + the symtrace flush) or loud-with-counts (28143). | |
| 112 | -- The `EC_AV1_PIN` site label is a new failure-line prefix; grep it when triaging. | |
| \ No newline at end of file | ||
| 128 | +- Success path is byte-identical; the only behavioural delta is that a short pin is now | |
| 129 | + fatal (9 sites + 2 gate dumps + the symtrace flush) or loud-with-counts (28143). | |
| 130 | +- Grep `TEST_PIN` (not `EC_AV1_PIN`) when triaging a short-pin failure line. | |
| \ No newline at end of file |