forge
Explore
Log in

Don't you dare go Hollow

Merge testcut-p2-h265: testcut Phase 2 lane

Browse files at this commit

16051cc5b9fbfa40740b30ae17d0f944dc5772ffAhmet Kaan GümüşParent: 7947774078f96f
crates/ec-h265/tests/it/cu_syntax.rsmodified+4 -214
@@ -1,14 +1,9 @@
1-//! Syntax-only sweep of the JCT-VC conformance streams through the CU syntax1+//! CU syntax tests over the JCT-VC conformance streams: the P/B slice syntax with the
2-//! parser ([`ec_h265::dec::cu_syntax`]). Pixel decode is off; every slice of2+//! zero-motion stand-in (the sweep, pixel-pipeline and motion-determinism tests were removed by
3-//! every picture is parsed to `end_of_slice_segment_flag`. A slice is clean when3+//! testcut Phase 2).
4-//! that flag lands on the last CTB and nothing refuses or desyncs.
5-//!
6-//! The per-stream table goes to stdout. With `EC_H265_SYNTAX_TABLE` set, the same
7-//! table is also written there as TSV.
8 4
9 use ec_core::error::Error;5 use ec_core::error::Error;
10-use ec_h265::dec::{Decoder, NalOutcome};6+use ec_h265::dec::Decoder;
11-use std::collections::BTreeMap;
12 use std::path::{Path, PathBuf};7 use std::path::{Path, PathBuf};
13 8
14 /// The conformance streams: the first `.bin` or `.bit` bitstream of each directory9 /// The conformance streams: the first `.bin` or `.bit` bitstream of each directory
@@ -79,167 +74,6 @@ fn is_slice(nal: &[u8]) -> bool {
79 t <= 9 || (16..=21).contains(&t)74 t <= 9 || (16..=21).contains(&t)
80 }75 }
81 76
82-#[derive(Default)]
83-struct Row {
84- slices: usize,
85- clean: usize,
86- refused: BTreeMap<String, usize>,
87- desync: usize,
88- desync_first: String,
89- other: usize,
90- /// Parameter sets refused, by name (a slice then fails with "never received").
91- param_refused: BTreeMap<String, usize>,
92-}
93-
94-fn sweep(path: &Path) -> Row {
95- let data = std::fs::read(path).expect("read bitstream");
96- let mut dec = Decoder::new();
97- dec.set_pixel_decode(false);
98- dec.set_syntax_check(true);
99- let mut row = Row::default();
100- for nal in nal_units(&data) {
101- let slice = is_slice(nal);
102- match dec.push_nal(nal) {
103- Ok(NalOutcome::Slice) if slice => {
104- row.slices += 1;
105- row.clean += 1;
106- }
107- Ok(_) => {}
108- Err(err) => {
109- if !slice {
110- if let Error::Unsupported { what, .. } = err {
111- *row.param_refused.entry(what).or_default() += 1;
112- }
113- continue;
114- }
115- row.slices += 1;
116- match err {
117- Error::Unsupported { what, .. } => {
118- *row.refused.entry(what).or_default() += 1;
119- }
120- // A slice whose parameter set was refused by name: not a parse failure.
121- Error::Corrupt { context } if context.contains("never received") => {
122- *row.refused
123- .entry("parameter set refused (see above)".to_string())
124- .or_default() += 1;
125- }
126- Error::Corrupt { context } => {
127- row.desync += 1;
128- if row.desync_first.is_empty() {
129- row.desync_first = context;
130- }
131- }
132- other => {
133- row.other += 1;
134- if row.desync_first.is_empty() {
135- row.desync_first = other.to_string();
136- }
137- }
138- }
139- }
140- }
141- }
142- row
143-}
144-
145-#[test]
146-fn cu_syntax_sweep_over_conformance_streams() {
147- let streams = streams();
148- if streams.is_empty() {
149- eprintln!("cu_syntax: no conformance streams found, skipping");
150- return;
151- }
152- let mut table = String::from("stream\tslices\tclean\trefused\tdesync\tother\tnote\n");
153- let (mut total_slices, mut total_clean, mut streams_clean, mut streams_all) = (0, 0, 0, 0);
154- for path in &streams {
155- let name = path
156- .file_stem()
157- .and_then(|s| s.to_str())
158- .unwrap_or("?")
159- .to_string();
160- let row = sweep(path);
161- let refused: usize = row.refused.values().sum();
162- let refused_note: Vec<String> = row
163- .refused
164- .iter()
165- .map(|(what, n)| format!("{what} x{n}"))
166- .collect();
167- let mut parts = refused_note;
168- parts.extend(
169- row.param_refused
170- .iter()
171- .map(|(what, n)| format!("{what} x{n} (parameter set)")),
172- );
173- let mut note = parts.join("; ");
174- if !row.desync_first.is_empty() {
175- if !note.is_empty() {
176- note.push_str("; ");
177- }
178- note.push_str(&row.desync_first);
179- }
180- table.push_str(&format!(
181- "{name}\t{}\t{}\t{refused}\t{}\t{}\t{note}\n",
182- row.slices, row.clean, row.desync, row.other
183- ));
184- total_slices += row.slices;
185- total_clean += row.clean;
186- streams_all += 1;
187- if row.slices > 0 && row.clean == row.slices {
188- streams_clean += 1;
189- }
190- }
191- print!("{table}");
192- println!(
193- "cu_syntax: {streams_clean}/{streams_all} streams parse every slice clean; {total_clean}/{total_slices} slices clean"
194- );
195- if let Ok(path) = std::env::var("EC_H265_SYNTAX_TABLE") {
196- std::fs::write(path, &table).expect("write syntax table");
197- }
198-}
199-
200-/// The pixel pipeline over the same streams: pixel decode on, so intra slices go
201-/// through `decode_i_slice` and P/B slices through the placeholder inter path.
202-/// Prints one line per stream with the first error, if any. Samples are not
203-/// compared; this checks that the pipeline runs.
204-#[test]
205-fn pixel_pipeline_runs_over_conformance_streams() {
206- let streams = streams();
207- if streams.is_empty() {
208- eprintln!("pixel pipeline: no conformance streams found, skipping");
209- return;
210- }
211- let mut ok_streams = 0;
212- for path in &streams {
213- let name = path
214- .file_stem()
215- .and_then(|s| s.to_str())
216- .unwrap_or("?")
217- .to_string();
218- let data = std::fs::read(path).expect("read bitstream");
219- let mut dec = Decoder::new();
220- let mut first_err = String::new();
221- for nal in nal_units(&data) {
222- if let Err(err) = dec.push_nal(nal) {
223- first_err = match err {
224- Error::Unsupported { what, .. } => format!("refused: {what}"),
225- other => other.to_string(),
226- };
227- break;
228- }
229- }
230- if first_err.is_empty() && dec.flush().is_ok() {
231- ok_streams += 1;
232- println!("pixel\t{name}\tok");
233- } else {
234- println!("pixel\t{name}\t{first_err}");
235- }
236- }
237- println!(
238- "pixel pipeline: {ok_streams}/{} streams decode without error",
239- streams.len()
240- );
241-}
242-
243 /// The P/B slice syntax ([`ec_h265::dec::cu_syntax::parse_slice`] with the zero-motion77 /// The P/B slice syntax ([`ec_h265::dec::cu_syntax::parse_slice`] with the zero-motion
244 /// stand-in, no DPB to derive motion from) over every P and B slice segment of every78 /// stand-in, no DPB to derive motion from) over every P and B slice segment of every
245 /// stream. Pixel decode is off so the decoder only keeps parameter sets. Refusals are79 /// stream. Pixel decode is off so the decoder only keeps parameter sets. Refusals are
@@ -303,47 +137,3 @@ fn inter_placeholder_runs_over_pb_slices() {
303 "inter syntax: {decoded} P/B slices parsed, {refused} refused by name, of {pb_slices} first-slice P/B segments"137 "inter syntax: {decoded} P/B slices parsed, {refused} refused by name, of {pb_slices} first-slice P/B segments"
304 );138 );
305 }139 }
306-
307-/// The motion derivation (merge, AMVP, temporal) runs through the syntax-only decode
308-/// of every stream. Two decodes of the same stream must give the same motion field
309-/// hash, and the derivation must not fail on any slice that parses cleanly.
310-#[test]
311-fn motion_derivation_is_deterministic_over_conformance_streams() {
312- let streams = streams();
313- if streams.is_empty() {
314- eprintln!("motion determinism: no conformance streams found, skipping");
315- return;
316- }
317- fn run(path: &Path) -> (u64, usize) {
318- let data = std::fs::read(path).expect("read bitstream");
319- let mut dec = Decoder::new();
320- dec.set_pixel_decode(false);
321- dec.set_syntax_check(true);
322- let mut failures = 0usize;
323- for nal in nal_units(&data) {
324- match dec.push_nal(nal) {
325- Ok(_) | Err(Error::Unsupported { .. }) => {}
326- // A slice whose parameter set was refused by name (see the sweep).
327- Err(Error::Corrupt { context }) if context.contains("never received") => {}
328- Err(_) => failures += 1,
329- }
330- }
331- let _ = dec.flush();
332- (dec.motion_checksum(), failures)
333- }
334- let (mut streams_run, mut total_failures) = (0usize, 0usize);
335- for path in &streams {
336- let (first, failures) = run(path);
337- let (second, _) = run(path);
338- assert_eq!(
339- first,
340- second,
341- "{}: motion field differs between runs",
342- path.display()
343- );
344- total_failures += failures;
345- streams_run += 1;
346- }
347- println!("motion determinism: {streams_run} streams, {total_failures} slice failures");
348- assert_eq!(total_failures, 0, "slices failed while deriving motion");
349-}
lanes/testcut/p2-h265.mdadded+36 -0
@@ -0,0 +1,36 @@
1+# testcut Phase 2: ec-h265 lane (testcut-p2-h265)
2+
3+Status: DONE (second attempt, host b, lanes `testcut-p2-h265-s1`, `-s2`). Deleted 3 tests, about 317 s of release runtime saved (per rest.tsv times: 143.0 + 54.7 + 119.2). ffmpeg_decodes_bit_exactly_at_every_shape was restored after the recheck below.
4+
5+## Method and why the first attempt was invalid
6+The earlier "kills" were timeouts: mutation runs used the debug profile, so the unmutated pixel run took 915 s against a 429 s timeout. This run uses `--release` everywhere, builds each mutant first (`--no-run`, separate build timeout), and sets the test timeout to 2.5 x the measured unmutated baseline of the same command on the same host (`run1.sh`, `fast.sh`, `mutrun.py`). Mutants are applied by index from `mutants.json`, 10 seeded (seed 2026) mutants per candidate from U(T) functions (noisy: functions T covers). A kill counts only if the test failed (rc=100, tests ran); timeouts do not count. Fast stage: `--profile fast --release`, fail-fast; unmutated fast baseline was 168 passed / 14 skipped, 0 failures, so nothing had to be excluded. Fixtures: `EC_REQUIRE_FIXTURES=1` everywhere; baselines passed with the test started.
7+
8+Validity checks: baseline logs show `PASS` for exactly the one test; SURVIVED rows have `rc=0 ran=1`; KILLED rows have `rc=100`. A parser bug (nextest prints `N/M tests run` on fail-fast failures, read as `ran=0` and NORUN) was found and fixed in `mutrun.py`; the fast stage was rerun after the fix. Leaked test processes from timed-out hang mutants (nextest children escape the killpg) raised b's load during the later stages; this can only turn kills into timeouts, never survivors into kills, and the affected rows are treated as not killed. They were killed by PID afterwards.
9+
10+## Protocol table
11+| crate | test | seconds | class | \|U(T)\| | mutants tried | \|S\| | \|KT\| | \|K\| | \|K'\| | decision |
12+|---|---|---|---|---|---|---|---|---|---|---|
13+| ec-h265 | pixel_pipeline_runs_over_conformance_streams | 142.99 | pseudo (prints only) | 223 | 10 | 10 | 0 | - | - | DELETED (kills nothing; baseline 48 s, timeout 125 s) |
14+| ec-h265 | cu_syntax_sweep_over_conformance_streams | 54.75 | pseudo (prints table only) | 171 | 10 | 9 | 1 (wpp.rs:494:27 `-` to `/`) | 0 | 0 | DELETED (the one kill is also killed by the fast suite) |
15+| ec-h265 | motion_derivation_is_deterministic_over_conformance_streams | 119.18 | candidate | 148 | 10 | 9 | 1 | 0 | 0 | DELETED (fast suite kills the T-kill) |
16+| ec-h265 | ffmpeg_decodes_bit_exactly_at_every_shape | 47.80 | candidate | 57 | 10 | 5 | 5 (2 failing, 3 hang-timeouts; hangs reconfirmed on a quiet host, load 0.9) | 1 (ctu.rs:429:13 `+` to `-` in code_quadtree: T hangs, fast suite also hangs, no real failure) | not run | KEEP (K'=1 unresolved; the other 4 T-kills are real fast-suite failures) |
17+| ec-h265 | noisy_near_black_lands_within_five_percent | 41.17 | candidate | 84 | 10 | 3 | 7 | 1 (ctu.rs:534:29 `+` to `-` in save_meta: T fails, fast suite hangs past 1200 s) | not run | KEEP (the only fast-suite outcome is a hang, not a failure; K' step not run) |
18+| ec-h265 | conformance_pictures_match_the_sei_hash | 85.08 | protected | | | | | | | protected |
19+| ec-h265 | rext_conformance_pictures_match_the_sei_hash | 83.30 | protected | | | | | | | protected |
20+| ec-h265 | conformance_output_order_matches_ffprobe | 133.71 | protected | | | | | | | protected |
21+| ec-h265 | speedup_curve | 114.86 | protected (perf) | | | | | | | protected |
22+| ec-h265 | ctb_32_is_the_faster_tree_at_1080p | 165.46 | protected (perf) | | | | | | | protected |
23+| ec-h265 | intra_1080p_beats_the_incumbent_on_twelve_threads | 451.04 | protected (perf) | | | | | | | protected |
24+
25+Release baselines measured on b: pixel 48 s, cu_syntax 21 s, noisy 39 s, motion 40 s, ffmpeg 23 s (the rest.tsv times are from a different run mix). Evidence is a 10-mutant sample per candidate, as the orchestrator allowed; it is thin for motion and cu_syntax (1 T-kill each).
26+
27+## Summary
28+1. Tests deleted: pixel_pipeline_runs_over_conformance_streams, cu_syntax_sweep_over_conformance_streams, motion_derivation_is_deterministic_over_conformance_streams (helpers `Row`, `sweep` and unused imports removed).
29+2. Seconds saved: about 317 s (rest.tsv times).
30+3. Kept with evidence: noisy_near_black_lands_within_five_percent (K=1, hang-only fast outcome) and ffmpeg_decodes_bit_exactly_at_every_shape (K'=1, hang-only). Protected: 6 tests.
31+4. Gate on b: `EC_REQUIRE_FIXTURES=1 cargo test --release -p ec-h265` all binaries ok (96 + 76 + 3 passed, 0 failed); `cargo clippy --release -p ec-h265 --tests -D warnings` clean; `#![forbid(unsafe_code)]` present in lib.rs.
32+5. `inter_placeholder_runs_over_pb_slices` was not heavy and is kept.
33+Tools: `lanes/testcut/p2h265-tools/{run1.sh,fast.sh,recheck.sh,gate.sh,mutrun.py}`. Per-mutant rows: `lanes/testcut/p2h265-evidence/res-*.tsv`.
34+
35+Note: samples were 10 mutants per candidate. Evidence for motion_derivation and cu_syntax_sweep is thin (1 T-kill each, both also killed by the fast suite).
36+Recheck (lane -s2, quiet host, load 0.9, T baseline 22 s, timeout 63 s): all 3 ffmpeg hang mutants still hang in T alone (real kills under the lane rules). Fast profile: residual.rs:609 and residual.rs:430 fail with rc=100 (killed); ctu.rs:429 hangs past 2.5 x the 54 s fast baseline (and past 1200 s earlier), so it is not killed by the fast suite. The test was restored byte-for-byte from before the deletion (conformance.rs), so the gate result above for the remaining code still applies.
lanes/testcut/p2h265-evidence/res-B1-cu_syntax_sweep_over_conformance_streams.tsvadded+10 -0
@@ -0,0 +1,10 @@
1+crates/ec-h265/src/dec/cu_syntax/wpp.rs:112:50: replace + with - in Board::prefill SURVIVED rc=0 ran=1 timeout=False
2+crates/ec-h265/src/dec/cu_syntax/wpp.rs:494:27: replace - with / in parse_segment KILLED rc=100 ran=1 timeout=False
3+crates/ec-h265/src/dec/rowfilter.rs:52:28: replace >= with < in RowFilter::advance SURVIVED rc=0 ran=1 timeout=False
4+crates/ec-h265/src/dec/rowfilter.rs:57:46: replace * with + in RowFilter::advance SURVIVED rc=0 ran=1 timeout=False
5+crates/ec-h265/src/dec/cu_syntax/wpp.rs:110:41: replace * with / in Board::prefill SURVIVED rc=0 ran=1 timeout=False
6+crates/ec-h265/src/dec/cu_syntax/wpp.rs:199:23: replace >> with << in Board::leave SURVIVED rc=0 ran=1 timeout=False
7+crates/ec-h265/src/dec/shared.rs:173:34: replace >> with << in SharedPic::publish_rows SURVIVED rc=0 ran=1 timeout=False
8+crates/ec-h265/src/dec/merge.rs:62:33: delete - in derive_merge SURVIVED rc=0 ran=1 timeout=False
9+crates/ec-h265/src/dec/shared.rs:175:77: replace * with / in SharedPic::publish_rows SURVIVED rc=0 ran=1 timeout=False
10+crates/ec-h265/src/dec/rowfilter.rs:91:26: replace + with - in RowFilter::sao_row SURVIVED rc=0 ran=1 timeout=False
lanes/testcut/p2h265-evidence/res-B1-ffmpeg_decodes_bit_exactly_at_every_shape.tsvadded+10 -0
@@ -0,0 +1,10 @@
1+crates/ec-h265/src/ctu.rs:1536:9: replace CtuEncoder<'a>::transform_luma_ts_rd -> (f64, bool) with (1.0, true) SURVIVED rc=0 ran=1 timeout=False
2+crates/ec-h265/src/deblock.rs:138:25: replace >> with << in luma_segment SURVIVED rc=0 ran=1 timeout=False
3+crates/ec-h265/src/intra.rs:400:43: replace + with * in predict_dc SURVIVED rc=0 ran=1 timeout=False
4+crates/ec-h265/src/intra.rs:437:30: replace * with / in predict_angular KILLED rc=100 ran=1 timeout=False
5+crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header KILLED rc=-1 ran=0 timeout=True
6+crates/ec-h265/src/ctu.rs:1429:23: delete - in CtuEncoder<'a>::choose_luma_mode SURVIVED rc=0 ran=1 timeout=False
7+crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True
8+crates/ec-h265/src/residual.rs:270:43: replace + with * in estimate_residual_bits SURVIVED rc=0 ran=1 timeout=False
9+crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq KILLED rc=-1 ran=0 timeout=True
10+crates/ec-h265/src/intra.rs:73:66: replace == with != in Availability::is_empty KILLED rc=100 ran=1 timeout=False
lanes/testcut/p2h265-evidence/res-B1-motion_derivation_is_deterministic_over_conformance_streams.tsvadded+10 -0
@@ -0,0 +1,10 @@
1+crates/ec-h265/src/dec/cu_syntax/wpp.rs:112:50: replace + with - in Board::prefill SURVIVED rc=0 ran=1 timeout=False
2+crates/ec-h265/src/dec/cu_syntax/wpp.rs:494:27: replace - with / in parse_segment KILLED rc=100 ran=1 timeout=False
3+crates/ec-h265/src/dec/rowfilter.rs:113:55: replace * with + in RowFilter::sao_row SURVIVED rc=0 ran=1 timeout=False
4+crates/ec-h265/src/dec/rowfilter.rs:54:56: replace + with * in RowFilter::advance SURVIVED rc=0 ran=1 timeout=False
5+crates/ec-h265/src/dec/cu_syntax/wpp.rs:110:41: replace * with / in Board::prefill SURVIVED rc=0 ran=1 timeout=False
6+crates/ec-h265/src/dec/cu_syntax/wpp.rs:199:23: replace >> with << in Board::leave SURVIVED rc=0 ran=1 timeout=False
7+crates/ec-h265/src/dec/runner.rs:128:9: replace Checksum::wait -> Option<u64> with None SURVIVED rc=0 ran=1 timeout=False
8+crates/ec-h265/src/dec/merge.rs:62:33: delete - in derive_merge SURVIVED rc=0 ran=1 timeout=False
9+crates/ec-h265/src/dec/shared.rs:175:26: replace * with + in SharedPic::publish_rows SURVIVED rc=0 ran=1 timeout=False
10+crates/ec-h265/src/dec/rowfilter.rs:89:29: replace >> with << in RowFilter::sao_row SURVIVED rc=0 ran=1 timeout=False
lanes/testcut/p2h265-evidence/res-B1-noisy_near_black_lands_within_five_percent.tsvadded+10 -0
@@ -0,0 +1,10 @@
1+crates/ec-h265/src/ctu.rs:534:29: replace + with - in CtuEncoder<'a>::save_meta KILLED rc=100 ran=1 timeout=False
2+crates/ec-h265/src/dec/pic.rs:330:9: replace PicState::available -> bool with true KILLED rc=100 ran=1 timeout=False
3+crates/ec-h265/src/enc_p.rs:666:74: replace > with < in PCoder<'a>::write_split SURVIVED rc=0 ran=1 timeout=False
4+crates/ec-h265/src/enc_p.rs:820:24: replace << with >> in PCoder<'a>::analyse KILLED rc=100 ran=1 timeout=False
5+crates/ec-h265/src/residual.rs:609:42: replace + with * in residual_header KILLED rc=100 ran=1 timeout=False
6+crates/ec-h265/src/ctu.rs:416:50: replace < with == in CtuEncoder<'a>::code_quadtree KILLED rc=100 ran=1 timeout=False
7+crates/ec-h265/src/dec/deblock.rs:253:59: replace + with - in luma_segment SURVIVED rc=0 ran=1 timeout=False
8+crates/ec-h265/src/intra.rs:460:49: replace & with ^ in predict_angular KILLED rc=100 ran=1 timeout=False
9+crates/ec-h265/src/residual.rs:112:19: replace += with *= in encode_remaining SURVIVED rc=0 ran=1 timeout=False
10+crates/ec-h265/src/encoder.rs:818:67: replace / with * in Encoder::code_picture_planes KILLED rc=100 ran=1 timeout=False
lanes/testcut/p2h265-evidence/res-B1-pixel_pipeline_runs_over_conformance_streams.tsvadded+10 -0
@@ -0,0 +1,10 @@
1+crates/ec-h265/src/dec/cu_syntax.rs:424:62: replace != with == in parse_slice_into SURVIVED rc=0 ran=1 timeout=False
2+crates/ec-h265/src/dec/deblock.rs:224:49: replace + with - in luma_segment SURVIVED rc=0 ran=1 timeout=False
3+crates/ec-h265/src/dec/deblock.rs:376:25: replace - with / in chroma_pass SURVIVED rc=0 ran=1 timeout=False
4+crates/ec-h265/src/dec/deblock.rs:394:84: replace >> with << in chroma_pass SURVIVED rc=0 ran=1 timeout=False
5+crates/ec-h265/src/dec/sao.rs:166:56: replace << with >> in filter_ctb_rows SURVIVED rc=0 ran=1 timeout=False
6+crates/ec-h265/src/dec/cu_syntax.rs:412:28: replace || with && in parse_slice_into SURVIVED rc=0 ran=1 timeout=False
7+crates/ec-h265/src/dec/cu_syntax/wpp.rs:627:39: replace << with >> in parse_segment SURVIVED rc=0 ran=1 timeout=False
8+crates/ec-h265/src/dec/picjob.rs:163:35: replace + with * in PicJob::run_slice SURVIVED rc=0 ran=1 timeout=False
9+crates/ec-h265/src/dec/sao.rs:125:25: replace + with - in filter_ctb_rows SURVIVED rc=0 ran=1 timeout=False
10+crates/ec-h265/src/dec/merge.rs:38:32: replace > with == in derive_merge SURVIVED rc=0 ran=1 timeout=False
lanes/testcut/p2h265-evidence/res-F-cu_syntax_sweep_over_conformance_streams.tsvadded+1 -0
@@ -0,0 +1 @@
1+crates/ec-h265/src/dec/cu_syntax/wpp.rs:494:27: replace - with / in parse_segment KILLED rc=100 ran=132 timeout=False
lanes/testcut/p2h265-evidence/res-F-ffmpeg_decodes_bit_exactly_at_every_shape.tsvadded+5 -0
@@ -0,0 +1,5 @@
1+crates/ec-h265/src/intra.rs:437:30: replace * with / in predict_angular KILLED rc=100 ran=75 timeout=False
2+crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header KILLED rc=100 ran=80 timeout=False
3+crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True
4+crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq KILLED rc=100 ran=86 timeout=False
5+crates/ec-h265/src/intra.rs:73:66: replace == with != in Availability::is_empty KILLED rc=100 ran=78 timeout=False
lanes/testcut/p2h265-evidence/res-F-motion_derivation_is_deterministic_over_conformance_streams.tsvadded+1 -0
@@ -0,0 +1 @@
1+crates/ec-h265/src/dec/cu_syntax/wpp.rs:494:27: replace - with / in parse_segment KILLED rc=100 ran=132 timeout=False
lanes/testcut/p2h265-evidence/res-F-noisy_near_black_lands_within_five_percent.tsvadded+7 -0
@@ -0,0 +1,7 @@
1+crates/ec-h265/src/ctu.rs:534:29: replace + with - in CtuEncoder<'a>::save_meta KILLED rc=-1 ran=0 timeout=True
2+crates/ec-h265/src/dec/pic.rs:330:9: replace PicState::available -> bool with true KILLED rc=100 ran=113 timeout=False
3+crates/ec-h265/src/enc_p.rs:820:24: replace << with >> in PCoder<'a>::analyse KILLED rc=100 ran=134 timeout=False
4+crates/ec-h265/src/residual.rs:609:42: replace + with * in residual_header KILLED rc=100 ran=80 timeout=False
5+crates/ec-h265/src/ctu.rs:416:50: replace < with == in CtuEncoder<'a>::code_quadtree KILLED rc=100 ran=99 timeout=False
6+crates/ec-h265/src/intra.rs:460:49: replace & with ^ in predict_angular KILLED rc=100 ran=75 timeout=False
7+crates/ec-h265/src/encoder.rs:818:67: replace / with * in Encoder::code_picture_planes KILLED rc=100 ran=97 timeout=False
lanes/testcut/p2h265-evidence/res-R2-F.tsvadded+3 -0
@@ -0,0 +1,3 @@
1+crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header KILLED rc=100 ran=81 timeout=False
2+crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True
3+crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq KILLED rc=100 ran=86 timeout=False
lanes/testcut/p2h265-evidence/res-R2-T.tsvadded+3 -0
@@ -0,0 +1,3 @@
1+crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header KILLED rc=-1 ran=0 timeout=True
2+crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True
3+crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq KILLED rc=-1 ran=0 timeout=True
lanes/testcut/p2h265-evidence/res-rc-f-T.tsvadded+1 -0
@@ -0,0 +1 @@
1+crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True
lanes/testcut/p2h265-evidence/res-rc-f-fast.tsvadded+1 -0
@@ -0,0 +1 @@
1+crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree KILLED rc=-1 ran=0 timeout=True
lanes/testcut/p2h265-evidence/res-rc-n-fast.tsvadded+1 -0
@@ -0,0 +1 @@
1+crates/ec-h265/src/ctu.rs:534:29: replace + with - in CtuEncoder<'a>::save_meta KILLED rc=-1 ran=0 timeout=True
lanes/testcut/p2h265-tools/analyze-all.shadded+9 -0
@@ -0,0 +1,9 @@
1+#!/usr/bin/env bash
2+set -uo pipefail
3+OUT=$HOME/lanes/testcut-p2-h265-c1/out
4+TOOLS=$PWD/lanes/testcut/p2h265-tools
5+NAMES="pixel_pipeline_runs_over_conformance_streams motion_derivation_is_deterministic_over_conformance_streams cu_syntax_sweep_over_conformance_streams ffmpeg_decodes_bit_exactly_at_every_shape noisy_near_black_lands_within_five_percent"
6+python3 "$TOOLS/analyze.py" "$OUT" $NAMES
7+cargo mutants -p ec-h265 --list --json > "$OUT/mutants.json" 2> "$OUT/mutants.list.err"
8+echo "mutants listed: $(python3 -c 'import json,sys;print(len(json.load(open(sys.argv[1]))))' "$OUT/mutants.json")"
9+for t in $NAMES; do python3 "$TOOLS/sample.py" "$OUT" "$t" 60; done
lanes/testcut/p2h265-tools/analyze.pyadded+27 -0
@@ -0,0 +1,27 @@
1+import json, sys, collections
2+out, names = sys.argv[1], sys.argv[2:]
3+def load(n):
4+ return json.load(open(f"{out}/{n}.json"))["data"][0]
5+def regions(data):
6+ s = {}
7+ for fn in data["functions"]:
8+ for r in fn["regions"]:
9+ fname = fn["filenames"][r[5]]
10+ key = (fn["name"], fname, r[0], r[1], r[2], r[3], r[7])
11+ s[key] = max(s.get(key, 0), r[4])
12+ return s
13+fast = load("fast")
14+fr = regions(fast)
15+fast_cov = {k for k, v in fr.items() if v > 0}
16+res = {}
17+for n in names:
18+ d = load(n)
19+ r = regions(d)
20+ cov = {k for k, v in r.items() if v > 0}
21+ u = cov - fast_cov
22+ fns = collections.Counter()
23+ for k in u:
24+ fi = k[1].find("ec-h265/"); fns[(k[1][fi + 8:] if fi >= 0 else None, k[0])] += 1
25+ res[n] = {"covered": len(cov), "U": len(u), "U_functions": [[f, fn, c] for (f, fn), c in fns.items() if f]}
26+ print(n, "covered", len(cov), "U", len(u), "funcs", len(fns))
27+json.dump({"fast_regions": len(fast_cov), "per_test": res}, open(f"{out}/coverage-summary.json", "w"))
lanes/testcut/p2h265-tools/bc_all.shadded+33 -0
@@ -0,0 +1,33 @@
1+#!/usr/bin/env bash
2+# Run B (T only) and run C (remaining heavy tests) per candidate, in decreasing runtime order.
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+OUT=$HOME/lanes/testcut-p2-h265-c1/out
6+TOOLS=$PWD/lanes/testcut/p2h265-tools
7+ALLHEAVY="pixel_pipeline_runs_over_conformance_streams motion_derivation_is_deterministic_over_conformance_streams cu_syntax_sweep_over_conformance_streams ffmpeg_decodes_bit_exactly_at_every_shape noisy_near_black_lands_within_five_percent conformance_pictures_match_the_sei_hash rext_conformance_pictures_match_the_sei_hash conformance_output_order_matches_ffprobe speedup_curve ctb_32_is_the_faster_tree_at_1080p intra_1080p_beats_the_incumbent_on_twelve_threads"
8+CANDS="pixel_pipeline_runs_over_conformance_streams motion_derivation_is_deterministic_over_conformance_streams cu_syntax_sweep_over_conformance_streams ffmpeg_decodes_bit_exactly_at_every_shape noisy_near_black_lands_within_five_percent"
9+PSEUDO=" pixel_pipeline_runs_over_conformance_streams cu_syntax_sweep_over_conformance_streams "
10+DELETED=""
11+expr() { local out=""; for n in "$@"; do out="${out:+$out | }test(/(^|::)$n\$/)"; done; echo "$out"; }
12+for T in $CANDS; do
13+ python3 -c 'import json,sys; sm=set(json.load(open(sys.argv[1]))); S=set(l.rstrip("\n") for l in open(sys.argv[2]) if l.strip()); print("\n".join(sorted(sm & S)))' "$OUT/sample-$T.json" "$OUT/A.S.txt" > "$OUT/$T.SA.txt"
14+ SN=$(wc -l < "$OUT/$T.SA.txt")
15+ echo "== $T S=$SN"
16+ if [ "$SN" -eq 0 ]; then echo "DECIDE $T K=0 S=0 -> delete"; DELETED="$DELETED $T"; continue; fi
17+ RES=$(python3 -c 'import re,sys; print("|".join(re.escape(l.rstrip("\n")) for l in open(sys.argv[1]) if l.strip()))' "$OUT/$T.SA.txt")
18+ cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$RES" --cargo-test-arg=-E --cargo-test-arg="$(expr $T)" -o "$OUT/$T.B" > "$OUT/$T.B.log" 2>&1
19+ python3 "$TOOLS/outcomes.py" "$OUT/$T.B/mutants.out/outcomes.json" killed > "$OUT/$T.K.txt"
20+ KN=$(wc -l < "$OUT/$T.K.txt")
21+ echo "$T K=$KN"
22+ if [ "$KN" -eq 0 ]; then echo "DECIDE $T K=0 -> delete"; DELETED="$DELETED $T"; continue; fi
23+ if [[ "$PSEUDO" == *" $T "* ]]; then echo "DECIDE $T pseudo weak-oracle kills $KN -> keep"; continue; fi
24+ REM=""; for h in $ALLHEAVY; do case " $DELETED $T " in *" $h "*) ;; *) REM="$REM $h";; esac; done
25+ KRE=$(python3 -c 'import re,sys; print("|".join(re.escape(l.rstrip("\n")) for l in open(sys.argv[1]) if l.strip()))' "$OUT/$T.K.txt")
26+ cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$KRE" --cargo-test-arg=-E --cargo-test-arg="$(expr $REM)" -o "$OUT/$T.C" > "$OUT/$T.C.log" 2>&1
27+ python3 "$TOOLS/outcomes.py" "$OUT/$T.C/mutants.out/outcomes.json" killed > "$OUT/$T.Kc.txt"
28+ comm -23 <(sort "$OUT/$T.K.txt") <(sort "$OUT/$T.Kc.txt") > "$OUT/$T.Kp.txt"
29+ KP=$(wc -l < "$OUT/$T.Kp.txt")
30+ echo "$T K'=$KP"
31+ if [ "$KP" -eq 0 ]; then echo "DECIDE $T K'=0 -> delete"; DELETED="$DELETED $T"; else echo "DECIDE $T K'=$KP -> keep"; fi
32+done
33+echo "DELETED:$DELETED"
lanes/testcut/p2h265-tools/cov.shadded+26 -0
@@ -0,0 +1,26 @@
1+#!/usr/bin/env bash
2+# Phase 2 coverage pass for ec-h265 (runs on the server inside the synced tree).
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+OUT=$HOME/lanes/testcut-p2-h265-c1/out
6+mkdir -p "$OUT"
7+PROF=${CARGO_TARGET_DIR:-$PWD/target}/llvm-cov-target
8+run_cov() {
9+ local name=$1; shift
10+ cargo llvm-cov clean --profraw-only > /dev/null 2>&1
11+ find "$PROF" -name '*.profraw' -delete 2>/dev/null
12+ cargo llvm-cov nextest --release --no-fail-fast -p ec-h265 --no-report "$@" > "$OUT/$name.run.log" 2>&1
13+ echo "$name nextest exit $?"
14+ PD=$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata
15+ for f in $(find "$PROF" -name '*.profraw' 2>/dev/null); do
16+ if ! "$PD" show "$f" > /dev/null 2>&1; then echo "$name: dropping corrupt $f"; rm -f "$f"; fi
17+ done
18+ cargo llvm-cov report --release --json --output-path "$OUT/$name.json" > "$OUT/$name.rep.log" 2>&1
19+ echo "$name report exit $?"
20+}
21+cargo llvm-cov clean --workspace > /dev/null 2>&1
22+run_cov fast --profile fast
23+for t in pixel_pipeline_runs_over_conformance_streams motion_derivation_is_deterministic_over_conformance_streams cu_syntax_sweep_over_conformance_streams ffmpeg_decodes_bit_exactly_at_every_shape noisy_near_black_lands_within_five_percent; do
24+ run_cov "$t" -E "test(/(^|::)$t\$/)"
25+done
26+grep -h -E "PASS|FAIL|Summary" "$OUT"/*.run.log | tail -40
lanes/testcut/p2h265-tools/dbg.pyadded+33 -0
@@ -0,0 +1,33 @@
1+import json, os, sys
2+sys.argv = ["x", os.path.expanduser("~/lanes/testcut-p2-h265-c1/out"), "pixel_pipeline_runs_over_conformance_streams", "1"]
3+src = open(os.path.join(os.getcwd(), "lanes/testcut/p2h265-tools/sample.py")).read().split("cands = []")[0]
4+exec(src)
5+muts = json.load(open(f"{out}/mutants.json"))
6+nf = sum(1 for m in muts if tail(m["file"]) in {k[0] for k in fast})
7+print("mutants", len(muts), "file-matched", nf, "fast funcs", len(fast), "sample files", list({k[0] for k in fast})[:3], "mut files", list({tail(m["file"]) for m in muts})[:3])
8+found = inT = 0
9+for m in muts:
10+ f = tail(m["file"]); line = m["span"]["start"]["line"]
11+ hits = [fn for k, fn in fast.items() if k[0] == f and fn["lo"] <= line <= fn["hi"]]
12+ if hits:
13+ found += 1
14+ b = min(hits, key=lambda fn: fn["hi"] - fn["lo"])
15+ t = T.get((b["file"], b["name"]))
16+ if t and t["covered_regions"]:
17+ inT += 1
18+print("found", found, "inT", inT, "Tfuncs", len(T), "sample T keys", list(T)[:2])
19+print("T funcs with covered", sum(1 for f in T.values() if f["covered_regions"]), "fast hits>0", sum(1 for f in fast.values() if f["hits"]>0))
20+import itertools
21+print("sample covered T:", [ (k[1][:60], len(v["covered_regions"])) for k,v in itertools.islice(((k,v) for k,v in T.items() if v["covered_regions"]),3)])
22+cnt = 0
23+for m in muts[:4000]:
24+ f = tail(m["file"]); line = m["span"]["start"]["line"]
25+ hits = [fn for k, fn in fast.items() if k[0] == f and fn["lo"] <= line <= fn["hi"]]
26+ if hits:
27+ b = min(hits, key=lambda fn: fn["hi"] - fn["lo"])
28+ t = T.get((b["file"], b["name"]))
29+ if cnt < 3:
30+ print("MUT", f, line, "fn", b["name"][-40:], "inT", t is not None, "covered", len(t["covered_regions"]) if t else None, "fast hits", b["hits"])
31+ cnt += 1
32+ if cnt >= 3: break
33+print("Tcovered files", sorted({k[0] for k,v in T.items() if v["covered_regions"]})[:8])
lanes/testcut/p2h265-tools/fast.shadded+25 -0
@@ -0,0 +1,25 @@
1+#!/usr/bin/env bash
2+# Step 2: KT mutants through the fast profile (release). usage: fast.sh T ... (skips T with empty KT)
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+TOOLS=$PWD/lanes/testcut/p2h265-tools
6+OUT=$(dirname "$PWD")/out
7+cargo nextest run --release -p ec-h265 --profile fast --no-run > "$OUT/fastbuild.log" 2>&1 || { echo fast build failed; exit 1; }
8+S=$(date +%s)
9+cargo nextest run --release -p ec-h265 --profile fast --no-fail-fast > "$OUT/fastbase.log" 2>&1
10+echo "fast baseline rc=$? $(( $(date +%s) - S ))s"
11+SECS=$(( $(date +%s) - S ))
12+# tests failing unmutated are excluded (fixture/personal-media tests)
13+grep -E "^\s+(FAIL|TIMEOUT|SIGKILL|SIGSEGV|SIGABRT)" "$OUT/fastbase.log" | sed -E 's/^.*\] +(\([0-9]+\/[0-9]+\) +)?//' | awk '{print $1" "$2}' | sort -u > "$OUT/fast-excluded.txt"
14+echo "excluded:"; cat "$OUT/fast-excluded.txt"
15+EX=""
16+while read -r bin name; do [ -n "$name" ] && EX="$EX and not test(=$name)"; done < "$OUT/fast-excluded.txt"
17+TO=$(( (SECS * 5 + 1) / 2 + 5 ))
18+for T in "$@"; do
19+ [ -s "$OUT/KT-$T.txt" ] && ! grep -q baseline_failed "$OUT/KT-$T.txt" || { echo "$T: KT empty"; continue; }
20+ python3 -c "import json,sys;json.dump([l.rstrip('\n') for l in open(sys.argv[1]) if l.strip()],open(sys.argv[2],'w'))" "$OUT/KT-$T.txt" "$OUT/KT-$T.json"
21+ FAILFAST=1 python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/KT-$T.json" "F-$T" "$TO" "all()$EX" --profile fast > "$OUT/F-$T.log" 2>&1
22+ awk -F'\t' '$2=="SURVIVED"{print $1}' "$OUT/res-F-$T.tsv" > "$OUT/K-$T.txt"
23+ echo "$T fast statuses: $(cut -f2 "$OUT/res-F-$T.tsv" | sort | uniq -c | tr '\n' ' ') K=$(wc -l < "$OUT/K-$T.txt")"
24+done
25+echo FAST_DONE
lanes/testcut/p2h265-tools/gate.shadded+5 -0
@@ -0,0 +1,5 @@
1+#!/usr/bin/env bash
2+export EC_REQUIRE_FIXTURES=1
3+cargo clippy --release -p ec-h265 --tests -- -D warnings 2>&1 | tail -15; echo "clippy rc=${PIPESTATUS[0]}"
4+cargo test --release -p ec-h265 2>&1 | grep -E "^test result|FAILED|failed|panicked|^error" | head -30; echo "test rc=${PIPESTATUS[0]}"
5+echo GATE_DONE
lanes/testcut/p2h265-tools/mut.shadded+34 -0
@@ -0,0 +1,34 @@
1+#!/usr/bin/env bash
2+# usage: mut.sh TEST OTHERS_EXPR (run from the synced tree; OTHERS_EXPR = nextest -E for remaining heavy tests, or empty)
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+OUT=$HOME/lanes/testcut-p2-h265-c1/out
6+T=$1; OTHERS=${2:-}
7+TOOLS=$PWD/lanes/testcut/p2h265-tools
8+TF="test(/(^|::)$T\$/)"
9+RE=$(python3 -c 'import json,re,sys; print("|".join(re.escape(n) for n in json.load(open(sys.argv[1]))))' "$OUT/sample-$T.json")
10+[ -n "$RE" ] || { echo "$T: empty sample"; exit 0; }
11+COMMON=(cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$RE")
12+echo "== $T run A (fast suite) $(date +%T)"
13+"${COMMON[@]}" --cargo-test-arg=--profile --cargo-test-arg=fast -o "$OUT/$T.A" > "$OUT/$T.A.log" 2>&1
14+echo "A exit $?"
15+python3 "$TOOLS/outcomes.py" "$OUT/$T.A/mutants.out/outcomes.json" missed > "$OUT/$T.S.txt"
16+SN=$(wc -l < "$OUT/$T.S.txt")
17+echo "S=$SN survivors of fast suite"
18+[ "$SN" -eq 0 ] && { echo "$T: no survivors"; exit 0; }
19+RES=$(python3 -c 'import re,sys; print("|".join(re.escape(l.rstrip("\n")) for l in open(sys.argv[1]) if l.strip()))' "$OUT/$T.S.txt")
20+echo "== $T run B (T only) $(date +%T)"
21+cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$RES" --cargo-test-arg=-E --cargo-test-arg="$TF" -o "$OUT/$T.B" > "$OUT/$T.B.log" 2>&1
22+echo "B exit $?"
23+python3 "$TOOLS/outcomes.py" "$OUT/$T.B/mutants.out/outcomes.json" killed > "$OUT/$T.K.txt"
24+KN=$(wc -l < "$OUT/$T.K.txt")
25+echo "K=$KN killed by T among S"
26+[ "$KN" -eq 0 ] && { echo "$T: K empty"; exit 0; }
27+KRE=$(python3 -c 'import re,sys; print("|".join(re.escape(l.rstrip("\n")) for l in open(sys.argv[1]) if l.strip()))' "$OUT/$T.K.txt")
28+[ -n "$OTHERS" ] || { echo "$T: no other heavy tests"; exit 0; }
29+echo "== $T run C (other heavy tests) $(date +%T)"
30+cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$KRE" --cargo-test-arg=-E --cargo-test-arg="$OTHERS" -o "$OUT/$T.C" > "$OUT/$T.C.log" 2>&1
31+echo "C exit $?"
32+python3 "$TOOLS/outcomes.py" "$OUT/$T.C/mutants.out/outcomes.json" killed > "$OUT/$T.Kc.txt"
33+echo "K'=$(comm -23 <(sort "$OUT/$T.K.txt") <(sort "$OUT/$T.Kc.txt" 2>/dev/null) | wc -l) (see $T.Kp.txt)"; comm -23 <(sort "$OUT/$T.K.txt") <(sort "$OUT/$T.Kc.txt" 2>/dev/null) > "$OUT/$T.Kp.txt"
34+echo "$T done $(date +%T)"
lanes/testcut/p2h265-tools/mutrun.pyadded+123 -0
@@ -0,0 +1,123 @@
1+# usage: mutrun.py OUT NAMES_JSON TAG TIMEOUT_SECS FILTER_EXPR [--profile fast]
2+# Applies each named mutant's own diff (from OUT/mutants.json) to the lane tree, runs
3+# `cargo nextest run -p ec-h265 -E FILTER_EXPR`, restores the file, and records one row per mutant:
4+# name <TAB> status <TAB> summary
5+# status: KILLED (test failure or timeout), SURVIVED (all pass), UNVIABLE (compile error), NORUN (no test ran).
6+# The tree is the lane's synced tree (cwd); only the one mutated file is touched, and it is restored.
7+import json, os, subprocess, sys, re
8+out, names_file, tag, timeout = sys.argv[1], sys.argv[2], sys.argv[3], int(sys.argv[4])
9+expr = sys.argv[5]
10+profile = sys.argv[7] if len(sys.argv) > 7 and sys.argv[6] == "--profile" else None
11+names = json.load(open(names_file))
12+muts = {m["name"]: m for m in json.load(open(f"{out}/mutants.json"))}
13+
14+def parse(diff):
15+ lines = diff.split("\n")
16+ fname = lines[0][4:].strip()
17+ hunks = []
18+ i = 1
19+ while i < len(lines):
20+ m = re.match(r"@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", lines[i])
21+ if not m:
22+ i += 1
23+ continue
24+ start = int(m.group(1))
25+ body = []
26+ i += 1
27+ while i < len(lines) and not lines[i].startswith("@@"):
28+ if lines[i][:1] in (" ", "-", "+"):
29+ body.append((lines[i][:1], lines[i][1:]))
30+ i += 1
31+ hunks.append((start, body))
32+ return fname, hunks
33+
34+def apply(orig, hunks):
35+ res, cur = [], 0
36+ for start, body in hunks:
37+ pos = start - 1
38+ res.extend(orig[cur:pos])
39+ cur = pos
40+ for op, text in body:
41+ if op in (" ", "-"):
42+ if cur >= len(orig) or orig[cur] != text:
43+ raise ValueError(f"context mismatch at line {cur + 1}")
44+ if op == " ":
45+ res.append(text)
46+ cur += 1
47+ else:
48+ res.append(text)
49+ res.extend(orig[cur:])
50+ return res
51+
52+def sh(cmd, tmo):
53+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
54+ start_new_session=True)
55+ try:
56+ output, _ = p.communicate(timeout=tmo)
57+ return p.returncode, output, False
58+ except subprocess.TimeoutExpired:
59+ os.killpg(p.pid, 9)
60+ output, _ = p.communicate()
61+ return -1, output or "", True
62+
63+BUILD_TO = int(os.environ.get("BUILD_TO", "2400"))
64+
65+def run_once():
66+ # release profile; build first (own generous timeout), then run with the measured-baseline timeout
67+ cmd = ["cargo", "nextest", "run", "--release", "-p", "ec-h265", "--no-fail-fast", "-E", expr]
68+ if os.environ.get("FAILFAST"):
69+ cmd.remove("--no-fail-fast")
70+ if profile:
71+ cmd[-2:-2] = ["--profile", profile]
72+ rc, out, to = sh([c for c in cmd if c != "--no-fail-fast"] + ["--no-run"], BUILD_TO)
73+ if to or rc != 0:
74+ return rc, out, "BUILDFAIL"
75+ return sh(cmd, timeout)
76+
77+rows = []
78+for name in names:
79+ m = muts.get(name)
80+ if m is None:
81+ rows.append((name, "NORUN", "name not in mutants.json"))
82+ continue
83+ fname, hunks = parse(m["diff"])
84+ raw = open(fname, "rb").read()
85+ text = raw.decode()
86+ orig = text.split("\n")
87+ try:
88+ new = apply(orig, hunks)
89+ except ValueError as e:
90+ rows.append((name, "NORUN", f"apply failed: {e}"))
91+ continue
92+ try:
93+ open(fname, "w").write("\n".join(new))
94+ rc, output, timed_out = run_once()
95+ timed_out = timed_out
96+ finally:
97+ open(fname, "wb").write(raw)
98+ summary = re.findall(r"Summary \[[^\]]*\] (\d+)(?:/\d+)? tests? run", output)
99+ ran = int(summary[-1]) if summary else 0
100+ if timed_out == "BUILDFAIL":
101+ status = "UNVIABLE"
102+ elif timed_out:
103+ # A timeout is kill evidence only if the test run had started (build time alone is not).
104+ status = "KILLED" if re.search(r"Starting \d+ tests?", output) else "TIMEOUT_NOSTART"
105+ elif rc != 0 and re.search(r"EC_REQUIRE_FIXTURES|fixtures? (missing|not found)", output):
106+ # A fixture-missing failure is not a kill.
107+ status = "FIXTURE_FAIL"
108+ elif "could not compile" in output or "error[E" in output:
109+ status = "UNVIABLE"
110+ elif rc == 0 and ran > 0:
111+ status = "SURVIVED"
112+ elif rc != 0 and ran > 0:
113+ status = "KILLED"
114+ else:
115+ status = "NORUN"
116+ err = next((l for l in output.splitlines() if "error[" in l or l.startswith("error")), "") if status == "UNVIABLE" else ""
117+ rows.append((name, status, f"rc={rc} ran={ran} timeout={timed_out} {err}"))
118+ print(status, name[:90], f"rc={rc} ran={ran}", flush=True)
119+
120+with open(f"{out}/res-{tag}.tsv", "w") as f:
121+ for r in rows:
122+ f.write("\t".join(r) + "\n")
123+print("summary", {s: sum(1 for r in rows if r[1] == s) for s in ("KILLED", "SURVIVED", "UNVIABLE", "NORUN")})
lanes/testcut/p2h265-tools/outcomes.pyadded+13 -0
@@ -0,0 +1,13 @@
1+# usage: outcomes.py OUTCOMES_JSON SUMMARY_KIND (kind: missed | killed) -> prints mutant names
2+import json, sys
3+data = json.load(open(sys.argv[1]))
4+kind = sys.argv[2]
5+want = {"missed": {"MissedMutant"}, "killed": {"CaughtMutant", "Timeout"}}[kind]
6+rows = data["outcomes"] if isinstance(data, dict) else data
7+for o in rows:
8+ sc = o.get("scenario")
9+ if not isinstance(sc, dict) or "Mutant" not in sc:
10+ continue
11+ if o.get("summary") in want:
12+ m = sc["Mutant"]
13+ print(m.get("name", json.dumps(m)))
lanes/testcut/p2h265-tools/recheck.shadded+14 -0
@@ -0,0 +1,14 @@
1+#!/usr/bin/env bash
2+# Recheck the timeout-only rows with long timeouts. Runs from synced tree.
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+TOOLS=$PWD/lanes/testcut/p2h265-tools
6+OUT=$(dirname "$PWD")/out
7+EXN="$(awk '{print " and not test(=" $2 ")"}' "$OUT/fast-excluded.txt" | tr -d '\n')"
8+N="crates/ec-h265/src/ctu.rs:534:29: replace + with - in CtuEncoder<'a>::save_meta"
9+F="crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree"
10+python3 -c "import json,sys;json.dump([sys.argv[1]],open(sys.argv[3],'w'));json.dump([sys.argv[2]],open(sys.argv[4],'w'))" "$N" "$F" "$OUT/rc-n.json" "$OUT/rc-f.json"
11+FAILFAST=1 python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/rc-n.json" rc-n-fast 1200 "all()$EXN" --profile fast
12+python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/rc-f.json" rc-f-T 600 "test(/(^|::)ffmpeg_decodes_bit_exactly_at_every_shape\$/)"
13+FAILFAST=1 python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/rc-f.json" rc-f-fast 1200 "all()$EXN" --profile fast
14+echo RECHECK_DONE
lanes/testcut/p2h265-tools/recheck2.shadded+25 -0
@@ -0,0 +1,25 @@
1+#!/usr/bin/env bash
2+# Recheck the 3 ffmpeg T-timeout mutants on a quiet host: T alone (2.5x measured baseline), then fast profile.
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+TOOLS=$PWD/lanes/testcut/p2h265-tools
6+OUT=$(dirname "$PWD")/out
7+echo "load: $(cat /proc/loadavg)"
8+F="test(/(^|::)ffmpeg_decodes_bit_exactly_at_every_shape\$/)"
9+cargo nextest run --release -p ec-h265 -E "$F" --no-run >/dev/null 2>&1
10+S=$(date +%s); cargo nextest run --release -p ec-h265 -E "$F" > "$OUT/b2.log" 2>&1; echo "T baseline rc=$? $(( $(date +%s)-S ))s"
11+cat > "$OUT/names.json" <<'J'
12+["crates/ec-h265/src/residual.rs:609:42: replace + with - in residual_header","crates/ec-h265/src/ctu.rs:429:13: replace + with - in CtuEncoder<'a>::code_quadtree","crates/ec-h265/src/residual.rs:430:64: replace >> with << in rdoq"]
13+J
14+python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/names.json" R2-T 63 "$F"
15+python3 - <<'P'
16+import json,os
17+o=os.environ.get("OUT")
18+P
19+awk -F'\t' '$2=="KILLED"{print $1}' "$OUT/res-R2-T.tsv" > "$OUT/k2.txt"
20+python3 -c "import json,sys;json.dump([l.rstrip('\n') for l in open(sys.argv[1]) if l.strip()],open(sys.argv[2],'w'))" "$OUT/k2.txt" "$OUT/k2.json"
21+cargo nextest run --release -p ec-h265 --profile fast --no-run >/dev/null 2>&1
22+S=$(date +%s); cargo nextest run --release -p ec-h265 --profile fast --no-fail-fast > "$OUT/fb2.log" 2>&1; SECS=$(( $(date +%s)-S )); echo "fast baseline rc=$? ${SECS}s"
23+FAILFAST=1 python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/k2.json" R2-F $(( SECS*5/2+5 )) "all()" --profile fast
24+cut -f1,2,3 "$OUT"/res-R2-*.tsv | cut -c1-200
25+echo R2_DONE
lanes/testcut/p2h265-tools/resample.shadded+5 -0
@@ -0,0 +1,5 @@
1+#!/usr/bin/env bash
2+set -uo pipefail
3+OUT=$HOME/lanes/testcut-p2-h265-c1/out
4+TOOLS=$PWD/lanes/testcut/p2h265-tools
5+for t in pixel_pipeline_runs_over_conformance_streams motion_derivation_is_deterministic_over_conformance_streams cu_syntax_sweep_over_conformance_streams ffmpeg_decodes_bit_exactly_at_every_shape noisy_near_black_lands_within_five_percent; do python3 "$TOOLS/sample.py" "$OUT" "$t" 60; done
lanes/testcut/p2h265-tools/run1.shadded+33 -0
@@ -0,0 +1,33 @@
1+#!/usr/bin/env bash
2+# Step 1 (T only), one chain, RELEASE profile. usage: run1.sh T ... (run from the synced tree; OUT = <lane>/out)
3+# Per candidate: build, measured unmutated baseline of T (wall seconds of the run), then SAMPLE_N (default 10)
4+# seeded mutants (sample2.py) each applied in place (mutrun.py), built, and run against T only with
5+# timeout = 2.5 x measured baseline. Writes KT-<T>.txt, S1-<T>.txt, res-B1-<T>.tsv, base-<T>.secs.
6+set -uo pipefail
7+export EC_REQUIRE_FIXTURES=1
8+TOOLS=$PWD/lanes/testcut/p2h265-tools
9+OUT=$(dirname "$PWD")/out
10+SEED=2026
11+N=${SAMPLE_N:-10}
12+for T in "$@"; do
13+ F="test(/(^|::)$T\$/)"
14+ echo "== $T build $(date +%T)"
15+ cargo nextest run --release -p ec-h265 -E "$F" --no-run > "$OUT/build-$T.log" 2>&1 || { echo "$T build failed"; continue; }
16+ S=$(date +%s)
17+ cargo nextest run --release -p ec-h265 --no-fail-fast -E "$F" > "$OUT/base-$T.log" 2>&1
18+ BRC=$?; E=$(date +%s); SECS=$((E - S))
19+ echo "$SECS" > "$OUT/base-$T.secs"
20+ if [ "$BRC" -ne 0 ] || ! grep -qE "Starting [0-9]+ tests?" "$OUT/base-$T.log"; then
21+ echo "$T baseline_failed rc=$BRC"; echo "baseline_failed" > "$OUT/KT-$T.txt"; : > "$OUT/S1-$T.txt"; continue
22+ fi
23+ TO=$(( (SECS * 5 + 1) / 2 + 5 ))
24+ echo "baseline ${SECS}s timeout ${TO}s $(date +%T)"
25+ python3 "$TOOLS/sample2.py" "$OUT" "$T" "$N" "$SEED" || { echo "$T sample failed"; continue; }
26+ python3 "$TOOLS/mutrun.py" "$OUT" "$OUT/s-$T.json" "B1-$T" "$TO" "$F" > "$OUT/B1-$T.log" 2>&1
27+ echo "exit $? $(date +%T)"
28+ awk -F'\t' '$2=="KILLED"{print $1}' "$OUT/res-B1-$T.tsv" > "$OUT/KT-$T.txt"
29+ awk -F'\t' '$2=="SURVIVED"{print $1}' "$OUT/res-B1-$T.tsv" > "$OUT/S1-$T.txt"
30+ echo "statuses: $(cut -f2 "$OUT/res-B1-$T.tsv" | sort | uniq -c | tr '\n' ' ')"
31+ echo "KT=$(wc -l < "$OUT/KT-$T.txt") S1=$(wc -l < "$OUT/S1-$T.txt")"
32+done
33+echo CHAIN_DONE
lanes/testcut/p2h265-tools/runA.shadded+19 -0
@@ -0,0 +1,19 @@
1+#!/usr/bin/env bash
2+# Shared run A: fast suite vs union of all candidate samples. Writes $OUT/A.S.txt (survivors).
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+OUT=$HOME/lanes/testcut-p2-h265-c1/out
6+TOOLS=$PWD/lanes/testcut/p2h265-tools
7+python3 -c 'import json,glob
8+u=[]
9+for f in sorted(glob.glob("'$OUT'/sample-*.json")):
10+ for n in json.load(open(f)):
11+ if n not in u: u.append(n)
12+json.dump(u, open("'$OUT'/union.json","w")); print("union", len(u))'
13+RE=$(python3 -c 'import json,re,sys; print("|".join(re.escape(n) for n in json.load(open(sys.argv[1]))))' "$OUT/union.json")
14+cargo mutants --help 2>&1 | grep -E "^ +--(release|test-tool|cargo-test-arg|in-place|baseline)" | head -6
15+cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$RE" --cargo-test-arg=--profile --cargo-test-arg=fast -o "$OUT/A" > "$OUT/A.log" 2>&1
16+echo "A exit $?"
17+python3 "$TOOLS/outcomes.py" "$OUT/A/mutants.out/outcomes.json" missed > "$OUT/A.S.txt"
18+echo "S=$(wc -l < "$OUT/A.S.txt")"
19+python3 -c 'import json,collections; print(collections.Counter(o.get("summary") for o in json.load(open("'$OUT'/A/mutants.out/outcomes.json"))["outcomes"]))' 2>/dev/null
lanes/testcut/p2h265-tools/sample.pyadded+61 -0
@@ -0,0 +1,61 @@
1+# usage: sample.py OUT TEST MAXN -> writes OUT/sample-TEST.json (names in priority order)
2+import json, sys, collections
3+out, test, maxn = sys.argv[1], sys.argv[2], int(sys.argv[3])
4+def tail(p):
5+ i = p.find("ec-h265/")
6+ return p[i + len("ec-h265/"):] if i >= 0 else None
7+def load(n):
8+ return json.load(open(f"{out}/{n}.json"))["data"][0]
9+def funcs(data):
10+ res = [] # (file, name, lo, hi, fast_hits_or_covered_hits, uncov_hits)
11+ for fn in data["functions"]:
12+ fl = [tail(fn["filenames"][r[5]]) for r in fn["regions"][:1]]
13+ if fl[0] is None:
14+ continue
15+ lo = min(r[0] for r in fn["regions"]); hi = max(r[2] for r in fn["regions"])
16+ res.append({"file": fl[0], "name": fn["name"], "lo": lo, "hi": hi,
17+ "hits": sum(r[4] for r in fn["regions"]),
18+ "covered_regions": {(r[0], r[1], r[2], r[3], r[7]) for r in fn["regions"] if r[4] > 0}})
19+ return res
20+def merged(lst):
21+ d = {}
22+ for f in lst:
23+ k = (f["file"], f["name"])
24+ if k not in d:
25+ d[k] = dict(f)
26+ continue
27+ m = d[k]
28+ m["hits"] += f["hits"]
29+ m["lo"] = min(m["lo"], f["lo"]); m["hi"] = max(m["hi"], f["hi"])
30+ m["covered_regions"] = m["covered_regions"] | f["covered_regions"]
31+ return d
32+fast = merged(funcs(load("fast")))
33+T = merged(funcs(load(test)))
34+cov = json.load(open(f"{out}/coverage-summary.json"))["per_test"][test]
35+ufuncs = {(x[0], x[1]) for x in cov["U_functions"]}
36+muts = json.load(open(f"{out}/mutants.json"))
37+cands = []
38+for m in muts:
39+ f = tail(m["file"]) if "ec-h265/" in m["file"] else m["file"]
40+ if f is None:
41+ continue
42+ line = m["span"]["start"]["line"]
43+ best = None
44+ for key, fn in fast.items():
45+ if key[0] != f or not (fn["lo"] <= line <= fn["hi"]):
46+ continue
47+ t = T.get(key)
48+ if t is None or not t["covered_regions"]:
49+ continue
50+ if best is None or (fn["hi"] - fn["lo"]) < (best["hi"] - best["lo"]):
51+ best = fn
52+ if best is None:
53+ continue
54+ key = (best["file"], best["name"])
55+ t = T.get(key)
56+ prio = 0 if key in ufuncs else 1
57+ cands.append((prio, fast[key]["hits"], m["name"]))
58+cands.sort()
59+names = [c[2] for c in cands[:maxn]]
60+json.dump(names, open(f"{out}/sample-{test}.json", "w"))
61+print(test, "eligible", len(cands), "sampled", len(names), "U-funcs-prio", sum(1 for c in cands[:maxn] if c[0] == 0))
lanes/testcut/p2h265-tools/sample2.pyadded+66 -0
@@ -0,0 +1,66 @@
1+# usage: sample2.py OUT TEST N SEED -> OUT/s-TEST.json
2+# Seeded sample of mutants whose containing fast-suite function is in U(TEST) (the functions TEST
3+# covers that the fast suite does not). Writes the mutant names; prints eligible/sampled counts.
4+import json, random, sys, collections
5+out, test, n, seed = sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4])
6+
7+def tail(p):
8+ i = p.find("ec-h265/")
9+ return p[i + 8:] if i >= 0 else None
10+
11+def load(name):
12+ return json.load(open(f"{out}/{name}.json"))["data"][0]
13+
14+def funcs(data):
15+ res = {}
16+ for fn in data["functions"]:
17+ if not fn["regions"]:
18+ continue
19+ fl = tail(fn["filenames"][fn["regions"][0][5]])
20+ if fl is None:
21+ continue
22+ lo = min(r[0] for r in fn["regions"])
23+ hi = max(r[2] for r in fn["regions"])
24+ key = (fl, fn["name"])
25+ d = res.setdefault(key, {"lo": lo, "hi": hi, "cov": False})
26+ d["lo"] = min(d["lo"], lo)
27+ d["hi"] = max(d["hi"], hi)
28+ d["cov"] = d["cov"] or any(r[4] > 0 for r in fn["regions"])
29+ return res
30+
31+fast = funcs(load("fast"))
32+T = funcs(load(test))
33+U = {(x[0], x[1]) for x in json.load(open(f"{out}/coverage-summary.json"))["per_test"][test]["U_functions"]}
34+by_file = collections.defaultdict(list)
35+for key in fast:
36+ by_file[key[0]].append(key)
37+
38+elig = []
39+covered = []
40+for m in json.load(open(f"{out}/mutants.json")):
41+ f = tail(m["file"]) if "ec-h265/" in m["file"] else m["file"]
42+ line = m["span"]["start"]["line"]
43+ best = None
44+ for key in by_file.get(f, []):
45+ fn = fast[key]
46+ if not T.get(key, {}).get("cov"):
47+ continue
48+ if fn["lo"] <= line <= fn["hi"]:
49+ if best is None or (fn["hi"] - fn["lo"]) < (best[1]["hi"] - best[1]["lo"]):
50+ best = (key, fn)
51+ if best is None:
52+ continue
53+ key = best[0]
54+ if key in U and T.get(key, {}).get("cov"):
55+ elig.append(m["name"])
56+ elif T.get(key, {}).get("cov"):
57+ covered.append(m["name"])
58+
59+elig = sorted(set(elig))
60+covered = sorted(set(covered) - set(elig))
61+# Fallback when U(T) holds no source functions (e.g. only test-file functions): mutants in functions
62+# T covers, which the protocol's step 3 allows.
63+pool, label = (elig, "U") if elig else (covered, "covered-fallback")
64+picked = random.Random(seed).sample(pool, min(n, len(pool)))
65+json.dump(picked, open(f"{out}/s-{test}.json", "w"))
66+print(test, label, len(pool), "sampled", len(picked), "seed", seed)
lanes/testcut/p2h265-tools/smoke.shadded+12 -0
@@ -0,0 +1,12 @@
1+#!/usr/bin/env bash
2+# Smoke: two mutants from the union sample through the fast suite, to time one mutant and check the runner.
3+set -uo pipefail
4+export EC_REQUIRE_FIXTURES=1
5+OUT=$HOME/lanes/testcut-p2-h265-c1/out
6+mkdir -p "$OUT"
7+python3 -c 'import json,sys; print("\n".join(json.load(open(sys.argv[1]))[:2]))' "$OUT/sample-pixel_pipeline_runs_over_conformance_streams.json" > "$OUT/smoke.names"
8+RE=$(python3 -c 'import re,sys; print("|".join(re.escape(l.rstrip("\n")) for l in open(sys.argv[1]) if l.strip()))' "$OUT/smoke.names")
9+date +%T
10+cargo mutants -p ec-h265 --test-tool nextest --baseline skip --timeout-multiplier 3 --re "$RE" --cargo-test-arg=--profile --cargo-test-arg=fast -o "$OUT/smoke" > "$OUT/smoke.log" 2>&1
11+echo "exit $?"; date +%T
12+tail -5 "$OUT/smoke.log"