forge
Explore
Log in

Don't you dare go Hollow

Merge testcut-p2-h264: testcut Phase 2 lane

Browse files at this commit

794777458532874a4c7b6aa47c178731b130e6f7Ahmet Kaan GümüşParent: 6bdd141e9b9397
crates/ec-h264/tests/conformance.rsmodified+0 -138
@@ -782,45 +782,6 @@ const ENTROPY_MODES: [(&str, &[&str]); 2] = [
782 ("cabac", &["-profile:v", "main", "-coder", "ac"]),782 ("cabac", &["-profile:v", "main", "-coder", "ac"]),
783 ];783 ];
784 784
785-/// Every quantisation parameter, bit-exact against ffmpeg, under both entropy
786-/// coders.
787-///
788-/// The deblocking filter's alpha, beta and tC0 tables (8-16 and 8-17) are
789-/// indexed by QP; the conformance vectors touch only a few of their 52 rows,
790-/// and a whole wrong column there passes the vectors (it did, once). One
791-/// all-intra picture per QP covers every row. Under CABAC the same sweep walks
792-/// the context initialisation of clause 9.3.1.1 across all 52 SliceQPY values,
793-/// which the fixed-QP conformance vectors barely touch.
794-#[test]
795-fn every_quantiser_matches_ffmpeg() {
796- if !have_ffmpeg() {
797- eprintln!("SKIP: ffmpeg not on PATH");
798- return;
799- }
800- let dir = scratch("qp-sweep");
801- let mut failures = Vec::new();
802- for (mode, profile) in ENTROPY_MODES {
803- let mut checked = 0usize;
804- for qp in 1..=51u32 {
805- let mut extra = profile.to_vec();
806- let qp_string = qp.to_string();
807- extra.extend(["-qp", &qp_string]);
808- match round_trip(&dir, &format!("{mode}-q{qp}"), "176x144", &extra) {
809- Ok(0) => checked += 1,
810- Ok(n) => failures.push(format!("{mode} qp {qp}: {n} bytes differ")),
811- Err(e) => failures.push(e),
812- }
813- }
814- assert!(
815- checked >= 40,
816- "too few {mode} quantisers exercised: {checked}"
817- );
818- eprintln!("{mode}: {checked} quantisers bit-exact against ffmpeg");
819- }
820- let _ = std::fs::remove_dir_all(&dir);
821- assert!(failures.is_empty(), "{failures:#?}");
822-}
823-
824 /// Geometry and slice structure: cropping, odd sizes, multiple slices, the785 /// Geometry and slice structure: cropping, odd sizes, multiple slices, the
825 /// loop filter off and a chroma QP offset — what a real camera or encoder786 /// loop filter off and a chroma QP offset — what a real camera or encoder
826 /// produces, none of which the QCIF single-slice vectors cover.787 /// produces, none of which the QCIF single-slice vectors cover.
@@ -1393,55 +1354,6 @@ fn a_frame_num_gap_keeps_decoding() {
1393 eprintln!("frame_num gap: {frames} frames decoded after dropping one picture");1354 eprintln!("frame_num gap: {frames} frames decoded after dropping one picture");
1394 }1355 }
1395 1356
1396-/// Every quantisation parameter again, this time over a GOP with motion.
1397-///
1398-/// The intra sweep above walks the alpha, beta and tC0 rows the bS 3 and 4
1399-/// edges use. Boundary strengths 1 and 2 exist only between inter macroblocks,
1400-/// so their tC0 columns (Table 8-17) had no oracle at all until now — and both
1401-/// were wrong when this landed. One P/B GOP per quantiser covers every row of
1402-/// both columns, and under CABAC it also walks the cabac_init_idc columns
1403-/// across all 52 SliceQPY values.
1404-#[test]
1405-fn every_quantiser_with_motion_matches_ffmpeg() {
1406- if !have_ffmpeg() {
1407- eprintln!("SKIP: ffmpeg not on PATH");
1408- return;
1409- }
1410- let dir = scratch("qp-motion");
1411- let mut failures = Vec::new();
1412- for coder in ["ac", "0"] {
1413- let mut checked = 0usize;
1414- for qp in 1..=51u32 {
1415- let qp_string = qp.to_string();
1416- let extra = vec![
1417- "-profile:v",
1418- "main",
1419- "-coder",
1420- coder,
1421- "-qp",
1422- &qp_string,
1423- "-x264-params",
1424- "bframes=2:b-adapt=0:ref=2",
1425- ];
1426- let tag = format!("{coder}-q{qp}");
1427- match x264_encode_gop(&dir, &tag, "176x144", 8, &extra) {
1428- Some(stream) => match compare_sequence(&stream) {
1429- Ok(_) => checked += 1,
1430- Err(e) => failures.push(format!("{tag}: {e}")),
1431- },
1432- None => failures.push(format!("{tag}: ffmpeg cannot encode")),
1433- }
1434- }
1435- assert!(
1436- checked >= 40,
1437- "too few {coder} quantisers exercised: {checked}"
1438- );
1439- eprintln!("{coder}: {checked} quantisers bit-exact over a GOP with motion");
1440- }
1441- let _ = std::fs::remove_dir_all(&dir);
1442- assert!(failures.is_empty(), "{failures:#?}");
1443-}
1444-
1445 /// Geometry and slice structure, over a GOP rather than one picture: cropping,1357 /// Geometry and slice structure, over a GOP rather than one picture: cropping,
1446 /// odd sizes, multiple slices per picture and the loop filter off, all with1358 /// odd sizes, multiple slices per picture and the loop filter off, all with
1447 /// inter prediction and reordering active.1359 /// inter prediction and reordering active.
@@ -2155,56 +2067,6 @@ fn pps_enables_8x8(stream: &Path) -> bool {
2155 false2067 false
2156 }2068 }
2157 2069
2158-/// The High-profile 8x8 transform, which every real-world encoder turns on by
2159-/// default: transform_size_8x8_flag, Intra_8x8 prediction with its reference
2160-/// filter (8.3.2), the 8x8 residual under both entropy coders and the 8x8
2161-/// inverse transform of 8.5.13.
2162-///
2163-/// The quantiser sweep matters twice over here: the 8x8 dequant ladder of
2164-/// 8.5.13.1 has its own rounding branch at QP 36, and under CABAC the whole
2165-/// ctxIdx 402..435 initialisation is a function of SliceQPY.
2166-#[test]
2167-fn high_profile_8x8_matches_ffmpeg() {
2168- if !have_ffmpeg() {
2169- eprintln!("SKIP: ffmpeg not on PATH");
2170- return;
2171- }
2172- let dir = scratch("high8x8");
2173- let mut failures = Vec::new();
2174- // High profile with the 8x8 transform forced on, in both entropy coders.
2175- let modes: [(&str, &[&str]); 2] = [
2176- ("cabac", &["-profile:v", "high", "-coder", "ac"]),
2177- ("cavlc", &["-profile:v", "high", "-coder", "0"]),
2178- ];
2179- for (mode, profile) in modes {
2180- let mut checked = 0usize;
2181- for qp in 1..=51u32 {
2182- let mut extra = profile.to_vec();
2183- let qp_string = qp.to_string();
2184- extra.extend(["-qp", &qp_string, "-x264-params", "8x8dct=1:i8x8=1"]);
2185- let tag = format!("i8-{mode}-q{qp}");
2186- match round_trip(&dir, &tag, "176x144", &extra) {
2187- Ok(0) => {
2188- assert!(
2189- pps_enables_8x8(&dir.join(format!("{tag}.264"))),
2190- "{tag}: encoder did not enable the 8x8 transform"
2191- );
2192- checked += 1;
2193- }
2194- Ok(n) => failures.push(format!("intra {mode} qp {qp}: {n} bytes differ")),
2195- Err(e) => failures.push(e),
2196- }
2197- }
2198- assert!(
2199- checked >= 40,
2200- "too few {mode} quantisers exercised: {checked}"
2201- );
2202- eprintln!("8x8 intra {mode}: {checked} quantisers bit-exact against ffmpeg");
2203- }
2204- let _ = std::fs::remove_dir_all(&dir);
2205- assert!(failures.is_empty(), "{failures:#?}");
2206-}
2207-
2208 /// The same transform in inter macroblocks: P and B partitions carry the flag2070 /// The same transform in inter macroblocks: P and B partitions carry the flag
2209 /// only when no 8x8 is split further (7.3.5), the residual rides the inter2071 /// only when no 8x8 is split further (7.3.5), the residual rides the inter
2210 /// scaling list, and the deblocker must leave the internal 4-sample edges of an2072 /// scaling list, and the deblocker must leave the internal 4-sample edges of an
crates/ec-h264/tests/it/high444.rsmodified+0 -5
@@ -450,11 +450,6 @@ fn x264_hi444_8bit() {
450 sweep("4:4:4 8-bit", &all("yuv444p", "", false, 1));450 sweep("4:4:4 8-bit", &all("yuv444p", "", false, 1));
451 }451 }
452 452
453-#[test]
454-fn x264_hi444_10bit() {
455- sweep("4:4:4 10-bit", &all("yuv444p10le", "", false, 1));
456-}
457-
458 #[test]453 #[test]
459 fn x264_hi444_mbaff() {454 fn x264_hi444_mbaff() {
460 let mut cases = all("yuv444p", "mbaff-", true, 2);455 let mut cases = all("yuv444p", "mbaff-", true, 2);
lanes/testcut/p2-h264.mdadded+47 -0
@@ -0,0 +1,47 @@
1+# testcut Phase 2: ec-h264 lane report
2+
3+Branch testcut-p2-h264. Driver: lanes/testcut/p2h264/driver.py. Valid evidence: r4 run
4+(lane testcut-p2-h264-r4, host a, log /tmp/claude-1000/testcut-p2-h264.r4.log, EXIT 0).
5+
6+Evidence history: the r1 run (its driver had no `--gitignore false`, ran with `--baseline skip`,
7+and copied the tree without the ignored fixtures) and the r2 and r3 runs are INVALID. Under them
8+every mutant was "caught" by a fixture panic, not a real assertion. r4 uses the default baseline
9+and `--gitignore false`, and its sanity lines show `fixture_errors=0` for every run.
10+
11+Excluded from every mutation run: `encode::real_library_frames_encode_and_decode_exactly`. It needs
12+the user's personal 720p H.264 media, which no server has, so it fails even unmutated with
13+EC_REQUIRE_FIXTURES=1. The exclusion is a filter on the mutation test set only; the gate below does
14+not exclude it.
15+
16+Sample cap: 30 mutants per candidate. Timeouts are not kills in the fast-suite runs.
17+
18+## Protocol table (r4)
19+
20+| crate | test | seconds | class | |U(T)| | mutants tried | |S| | |K| | |K'| | decision |
21+|---|---|---|---|---|---|---|---|---|---|
22+| ec-h264 | every_quantiser_with_motion_matches_ffmpeg | 70.9 | candidate | 0 | 30 | 7 | 0 | 0 | delete |
23+| ec-h264 | every_quantiser_matches_ffmpeg | 70.3 | candidate | 0 | 27 | 6 | 0 | 0 | delete |
24+| ec-h264 | high_profile_8x8_matches_ffmpeg | 56.8 | candidate | 0 | 27 | 5 | 0 | 0 | delete |
25+| ec-h264 | x264_hi444_10bit | 24.2 | candidate | 17 | 30 | 9 | 4 | 0 | delete |
26+| ec-h264 | corrupt_streams_never_panic | 24.2 | pseudo | 91 | 30 | 19 | 4 | 0 | keep (weak oracle, kills 4) |
27+| ec-h264 | x264_hi444_8bit | 23.0 | candidate | 17 | 30 | 10 | 4 | 4 | keep (K'=4, e.g. crates/ec-h264/src/decoder.rs:4502:21 delete match arm 1 in deblock_picture) |
28+| ec-h264 | truncated_and_corrupted_conformance_streams_never_panic | 20.9 | pseudo | 69 | 30 | 19 | 4 | 0 | keep (weak oracle, kills 4) |
29+| ec-h264 | jvt_hi444_vectors_bit_exact | 464.6 | protected | - | - | - | - | - | keep (protected: conformance vectors) |
30+
31+Survivor counts (|S|) and the kill set |K| come from the MUTSTAT lines in the r4 log. For the
32+four deleted tests |K| is 0 except x264_hi444_10bit (K=4: four survivors of the fast suite that
33+the 10-bit test kills; K'=0, so the other remaining heavy tests also kill all four). The never_panic pseudo-tests kill 4 mutants each that the fast suite misses,
34+and they are the only corrupt-input robustness tests in the crate, so they are kept.
35+
36+## Summary
37+
38+1. Tests deleted: 4 (every_quantiser_with_motion_matches_ffmpeg, every_quantiser_matches_ffmpeg,
39+ high_profile_8x8_matches_ffmpeg, x264_hi444_10bit). Helpers left unused: none (clippy clean).
40+2. Seconds saved: 222.2 (70.9 + 70.3 + 56.8 + 24.2).
41+3. Kept with evidence: x264_hi444_8bit (K'=4), corrupt_streams_never_panic and
42+ truncated_and_corrupted_conformance_streams_never_panic (weak oracle, kills 4 each), and
43+ jvt_hi444_vectors_bit_exact (protected).
44+4. Gate: EC_REQUIRE_FIXTURES=1 cargo test --release -p ec-h264 on host a; see the gate note below.
45+5. Excluded from mutation runs only: encode::real_library_frames_encode_and_decode_exactly
46+ (needs personal media). The fast-profile filter in .config/nextest.toml still names the deleted
47+ tests; harmless, not regenerated.
lanes/testcut/p2h264/driver.pyadded+313 -0
@@ -0,0 +1,313 @@
1+#!/usr/bin/env python3
2+"""Phase 2 evidence driver for ec-h264 (runs on a server inside the lane tree).
3+
4+Stages (argv[1]):
5+ cov coverage of fast suite and each candidate; prints U(T) sizes
6+ run full pipeline: coverage, sampling, S/K/K' kill runs, decisions
7+
8+Output that matters goes to stdout as lines starting with 'RESULT\t'.
9+Scratch (cargo-mutants trees) goes under $TMPDIR, which is not synced.
10+"""
11+import json, os, re, shutil, subprocess, sys, glob
12+
13+CRATE = "ec-h264"
14+ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
15+TMP = os.environ.get("TMPDIR", "/tmp")
16+WORK = os.path.join(TMP, "p2h264")
17+N_SAMPLE = int(os.environ.get("N_SAMPLE", "30"))
18+ENV = dict(os.environ, EC_REQUIRE_FIXTURES="1")
19+TARGET = os.environ.get("CARGO_TARGET_DIR", os.path.join(ROOT, "target"))
20+
21+# (test, runtime s, class). Order = decreasing runtime, as the protocol requires.
22+CANDS = [
23+ ("every_quantiser_with_motion_matches_ffmpeg", 70.90, "candidate"),
24+ ("every_quantiser_matches_ffmpeg", 70.34, "candidate"),
25+ ("high_profile_8x8_matches_ffmpeg", 56.82, "candidate"),
26+ ("x264_hi444_10bit", 24.18, "candidate"),
27+ ("corrupt_streams_never_panic", 24.24, "pseudo"),
28+ ("x264_hi444_8bit", 23.01, "candidate"),
29+ ("truncated_and_corrupted_conformance_streams_never_panic", 20.88, "pseudo"),
30+]
31+PROTECTED = {"jvt_hi444_vectors_bit_exact": 464.6}
32+EXCLUDE_ALWAYS = "encode::real_library_frames_encode_and_decode_exactly"
33+
34+
35+def sel(name):
36+ return "test(/(^|::)%s$/)" % name
37+
38+
39+def sh(args, log):
40+ os.makedirs(WORK, exist_ok=True)
41+ with open(os.path.join(WORK, log), "w") as f:
42+ r = subprocess.run(args, cwd=ROOT, env=ENV, stdout=f, stderr=subprocess.STDOUT)
43+ print("STEP %s rc=%d" % (log, r.returncode), flush=True)
44+ return r.returncode
45+
46+
47+def clear_profraw():
48+ for p in glob.glob(os.path.join(TARGET, "llvm-cov-target", "*.profraw")):
49+ os.remove(p)
50+
51+
52+VALID = {}
53+FAST_CACHE = {}
54+LAST_BAD = 0
55+LAST_RC = 0
56+
57+
58+def prune_bad_profraw(files):
59+ sysroot = subprocess.run(["rustc", "--print", "sysroot"], capture_output=True, text=True).stdout.strip()
60+ prof = os.path.join(sysroot, "lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata")
61+ n = 0
62+ for f in files:
63+ r = subprocess.run([prof, "show", f], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
64+ if r.returncode != 0:
65+ os.remove(f)
66+ n += 1
67+ print("PRUNED bad profraw: %d" % n, flush=True)
68+ return n
69+
70+
71+def tail_log(log, n=40):
72+ p = os.path.join(WORK, log)
73+ if os.path.exists(p):
74+ with open(p, errors="replace") as f:
75+ lines = f.readlines()[-n:]
76+ print("LOG-TAIL %s\n%s" % (log, "".join(lines)), flush=True)
77+
78+
79+def cov_report(out_json, extra_args):
80+ """Run instrumented tests (profraw kept fresh), then dump JSON.
81+
82+ --no-fail-fast: wall-clock tripwires can fail under instrumentation; the
83+ profraw is still written, so a nonzero run exit is only reported.
84+ """
85+ subprocess.run(["cargo", "llvm-cov", "clean", "--profraw-only"], cwd=ROOT, env=ENV,
86+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
87+ clear_profraw()
88+ base = os.path.basename(out_json)
89+ rc_run = sh(["cargo", "llvm-cov", "nextest", "--release", "-p", CRATE, "--no-report",
90+ "--no-fail-fast"] + extra_args, base + ".run.log")
91+ files = sorted(glob.glob(os.path.join(TARGET, "llvm-cov-target", "*.profraw")))
92+ global LAST_BAD
93+ LAST_BAD = prune_bad_profraw(files)
94+ files = sorted(glob.glob(os.path.join(TARGET, "llvm-cov-target", "*.profraw")))
95+ print("PROFRAW %s n=%d sizes=%s" % (base, len(files),
96+ [os.path.getsize(f) for f in files][:20]), flush=True)
97+ rc_rep = sh(["cargo", "llvm-cov", "report", "--release", "--json", "--output-path", out_json],
98+ base + ".rep.log")
99+ if rc_rep != 0 or not os.path.exists(out_json):
100+ print("FAIL coverage report for %s (run rc=%d, report rc=%d)" % (base, rc_run, rc_rep),
101+ flush=True)
102+ tail_log(base + ".run.log")
103+ tail_log(base + ".rep.log")
104+ sys.exit(3)
105+ global LAST_RC
106+ LAST_RC = rc_run
107+ if rc_run != 0:
108+ print("NOTE coverage run for %s exited %d (test failures, profraw kept)" % (base, rc_run),
109+ flush=True)
110+ with open(out_json) as f:
111+ return json.load(f)
112+
113+
114+def regions(report):
115+ """key (file, l1, c1, l2, c2) -> (max count, function name), code regions only."""
116+ out = {}
117+ for fn in report["data"][0]["functions"]:
118+ for r in fn["regions"]:
119+ l1, c1, l2, c2, cnt, fid, _exp, kind = r[:8]
120+ if kind != 0:
121+ continue
122+ fname = fn["filenames"][fid]
123+ if "/crates/%s/src/" % CRATE not in fname:
124+ continue
125+ rel = fname[fname.index("crates/"):]
126+ key = (rel, l1, c1, l2, c2)
127+ prev = out.get(key)
128+ if prev is None or cnt > prev[0]:
129+ out[key] = (cnt, fn["name"])
130+ return out
131+
132+
133+def innermost(regs, rel, line):
134+ best = None
135+ for key, (cnt, _f) in regs.items():
136+ if key[0] != rel or not (key[1] <= line <= key[3]):
137+ continue
138+ span = (key[3] - key[1], key[4] - key[2] if key[1] == key[3] else 0)
139+ if best is None or span < best[0]:
140+ best = (span, key, cnt)
141+ return best
142+
143+
144+def mutants_list():
145+ txt = subprocess.run(["cargo", "mutants", "-p", CRATE, "--list"], cwd=ROOT, env=ENV,
146+ capture_output=True, text=True).stdout
147+ out = []
148+ for line in txt.splitlines():
149+ m = re.match(r"^(crates/%s/src/[^:]+):(\d+):(\d+): " % CRATE, line)
150+ if m:
151+ out.append((line.strip(), m.group(1), int(m.group(2))))
152+ return out
153+
154+
155+def mutate(outdir, names, extra_test_args, timeout_is_kill):
156+ """Return (caught, not_killed) name sets for the given mutants.
157+
158+ The unmutated baseline runs in the scratch copy (default baseline). If it
159+ fails, cargo-mutants exits 4 and we stop without deciding anything.
160+ `--gitignore false` copies the ignored `fixtures` symlink into the scratch tree.
161+ Timeouts count as kills only when timeout_is_kill (the candidate's own run).
162+ """
163+ if not names:
164+ return set(), set()
165+ if os.path.isdir(outdir):
166+ assert outdir.startswith(WORK + os.sep), outdir
167+ shutil.rmtree(outdir)
168+ os.makedirs(outdir, exist_ok=True)
169+ tag = os.path.basename(outdir)
170+ args = ["cargo", "mutants", "-p", CRATE, "--test-tool", "nextest",
171+ "--timeout-multiplier", "3", "-j", "1", "--copy-vcs", "true",
172+ "--gitignore", "false", "-o", outdir]
173+ for n in names:
174+ args += ["--re", re.escape(n)]
175+ # Needs the user's personal media, which no server has: excluded from every mutation run.
176+ excl = "not test(=%s)" % EXCLUDE_ALWAYS
177+ extra = list(extra_test_args)
178+ if "-E" in extra:
179+ i = extra.index("-E") + 1
180+ extra[i] = "(%s) and %s" % (extra[i], excl)
181+ else:
182+ extra += ["-E", excl]
183+ for a in extra:
184+ args += ["--cargo-test-arg=" + a]
185+ rc = sh(args, tag + ".log")
186+ if rc == 4:
187+ print("RESULT\tbaseline_failed\t%s" % tag, flush=True)
188+ sys.exit(4)
189+ base = glob.glob(os.path.join(outdir, "**", "mutants.out"), recursive=True)
190+ if not base:
191+ print("RESULT\tmutate_no_output\t%s\trc=%d" % (tag, rc), flush=True)
192+ sys.exit(5)
193+ d = base[0]
194+
195+ def read(name):
196+ p = os.path.join(d, name)
197+ return set(l.strip() for l in open(p)) if os.path.exists(p) else set()
198+
199+ caught = read("caught.txt")
200+ timeouts = read("timeout.txt")
201+ missed = read("missed.txt")
202+ if timeout_is_kill:
203+ caught |= timeouts
204+ else:
205+ missed |= timeouts
206+ print("MUTSTAT %s caught=%d missed=%d timeout=%d unviable=%d asked=%d rc=%d" % (
207+ tag, len(caught), len(missed), len(timeouts), len(read("unviable.txt")), len(names), rc), flush=True)
208+ # Sanity: fixture/runner errors must not be what kills a mutant.
209+ logs = glob.glob(os.path.join(d, "log", "*.log"))
210+ bad = [p for p in logs if "lists no" in open(p, errors="replace").read()]
211+ print("SANITY %s logs=%d fixture_errors=%d" % (tag, len(logs), len(bad)), flush=True)
212+ for p in logs:
213+ hits = [l.rstrip() for l in open(p, errors="replace") if "panicked at" in l]
214+ if hits:
215+ print("SANITY %s sample_log=%s" % (tag, p), flush=True)
216+ for h in hits[:3]:
217+ print("SANITY " + h[:200], flush=True)
218+ break
219+ return caught, missed
220+
221+
222+def run_cov(cands_to_check):
223+ fast = cov_report(os.path.join(WORK, "fast.json"),
224+ ["--profile", "fast"])
225+ fast_r = regions(fast)
226+ per = {}
227+ for name, _s, _c in cands_to_check:
228+ rep = cov_report(os.path.join(WORK, name + ".json"), ["-E", sel(name)])
229+ tr = regions(rep)
230+ VALID[name] = (LAST_BAD == 0 and LAST_RC == 0)
231+ print("RESULT\tvalid\t%s\t%s\tbad_profraw=%d\trc=%d" % (name, VALID[name], LAST_BAD, LAST_RC), flush=True)
232+ U = [k for k, (c, _f) in tr.items() if c > 0 and fast_r.get(k, (0,))[0] == 0]
233+ per[name] = (tr, U)
234+ funcs = sorted({tr[k][1] for k in U})
235+ print("RESULT\tcov\t%s\tU=%d\tfuncs=%s" % (name, len(U), ";".join(funcs)[:400]), flush=True)
236+ return fast_r, per
237+
238+
239+def main():
240+ stage = sys.argv[1] if len(sys.argv) > 1 else "run"
241+ os.makedirs(WORK, exist_ok=True)
242+ if stage == "cov":
243+ run_cov(CANDS)
244+ return
245+ # full pipeline; start from a clean instrumented tree (as the ec-aac lane does)
246+ subprocess.run(["cargo", "llvm-cov", "clean", "--workspace"], cwd=ROOT, env=ENV,
247+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
248+ fast_r, per = run_cov(CANDS)
249+ muts = mutants_list()
250+ print("RESULT\tmutants_listed\t%d" % len(muts), flush=True)
251+ deleted = set()
252+ heavy_all = [n for n, _s, _c in CANDS] + list(PROTECTED)
253+ for name, secs, cls in CANDS:
254+ remaining = [h for h in heavy_all if h not in deleted and h != name]
255+ tr, U = per[name]
256+ if not VALID.get(name):
257+ print("RESULT\tdecision\t%s\t%s\tsecs=%.1f\tU=%d\ttried=0\tS=0\tK=0\tKp=0\tkeep (no valid evidence)\tex=" % (
258+ CRATE, name, secs, len(U)), flush=True)
259+ continue
260+ # mutants inside code T executes
261+ eligible = []
262+ for line_txt, rel, line in muts:
263+ hit = innermost(tr, rel, line)
264+ if hit is None or hit[2] == 0:
265+ continue
266+ fh = innermost(fast_r, rel, line)
267+ fast_hit = fh[2] if fh else 0
268+ in_u = hit[1] in U
269+ eligible.append((0 if in_u else 1, fast_hit, line_txt))
270+ eligible.sort()
271+ sample = [e[2] for e in eligible[:N_SAMPLE]]
272+ tag = name[:24]
273+ # S: survivors of the fast suite
274+ new = [m for m in sample if m not in FAST_CACHE]
275+ fc, fm = mutate(os.path.join(WORK, "fast-" + tag), new, ["--profile", "fast"], False)
276+ print("SANITY\t%s\tmissed=%d\tcaught=%d" % (name, len(fm), len(fc)), flush=True)
277+ for m in fc:
278+ FAST_CACHE[m] = True
279+ for m in fm:
280+ FAST_CACHE[m] = False
281+ viable = [m for m in sample if m in FAST_CACHE]
282+ if not viable:
283+ print("RESULT\tdecision\t%s\t%s\tsecs=%.1f\tU=%d\ttried=%d\tS=0\tK=0\tKp=0\tkeep (no valid evidence: 0 viable mutants)\tex=" % (
284+ CRATE, name, secs, len(U), len(sample)), flush=True)
285+ continue
286+ S = sorted(m for m in viable if not FAST_CACHE[m])
287+ # K: survivors of fast that T kills
288+ tc, tm = mutate(os.path.join(WORK, "t-" + tag), S,
289+ ["-E", sel(name)], True)
290+ K = sorted(set(S) - tm)
291+ # K': K mutants that no other remaining heavy test kills
292+ if K and remaining:
293+ expr = " | ".join(sel(h) for h in remaining)
294+ kc, km = mutate(os.path.join(WORK, "k-" + tag), K, ["-E", expr], False)
295+ Kp = sorted(set(K) - kc)
296+ else:
297+ Kp = list(K)
298+ if cls == "pseudo":
299+ decision = "delete" if not K else "keep (weak oracle, kills %d)" % len(K)
300+ else:
301+ decision = "delete" if not Kp else "keep"
302+ if decision == "delete" and not PROTECTED.get(name):
303+ deleted.add(name)
304+ tried = len(viable)
305+ ex = Kp[0] if Kp else (K[0] if K and cls == "pseudo" else "")
306+ print("RESULT\tdecision\t%s\t%s\tsecs=%.1f\tU=%d\ttried=%d\tS=%d\tK=%d\tKp=%d\t%s\tex=%s" % (
307+ CRATE, name, secs, len(U), tried, len(S), len(K), len(Kp), decision,
308+ ex), flush=True)
309+ print("RESULT\tdeleted\t%s" % ",".join(sorted(deleted)), flush=True)
310+
311+
312+if __name__ == "__main__":
313+ main()
lanes/testcut/p2h264/probe.shadded+10 -0
@@ -0,0 +1,10 @@
1+set -u
2+cd "$HOME/lanes/testcut-p2-h264/edith_codecs" 2>/dev/null || { echo "no lane tree"; exit 1; }
3+export PATH="$HOME/.cargo/bin:$PATH"
4+echo "host=$(hostname)"
5+command -v cargo-nextest ffmpeg python3 >/dev/null 2>&1 && echo TOOLS_OK
6+cargo nextest --version | head -1
7+cargo llvm-cov clean --help | grep -i profraw
8+cargo nextest run --help | grep -E -- "--filter-expr|-E," | head -2
9+cargo mutants -p ec-h264 --list 2>/dev/null | head -3
10+cargo mutants -p ec-h264 --list 2>/dev/null | wc -l