forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust375.4 MiBa7e1d4cTahinli2 months ago3424 commits

gate_coverage.rs1025 lines, 48.7 KiBHistoryRawDownload
1//! A guard over the real-aomenc gates' own encoder recipes.
2//!
3//! Every gate in [`crate::stream`] that runs a real `aomenc` picks its coding
4//! tools with `--enable-*=0/1` flags, and a flag left off the command line
5//! takes aomenc's default. That default is `1` for essentially every tool in
6//! [`TOOL_UNIVERSE`] on a non-realtime build -- `default_extra_cfg` in
7//! `av1/av1_cx_iface.c` is all-ones across the seq-level tool fields, and this
8//! oracle is built with `CONFIG_REALTIME_ONLY 0`. But a `1` default is NOT
9//! the same as the tool reaching the stream, and the rest of this file's
10//! "defaulted means unknown" rule rests on that gap: palette and intrabc are
11//! gated on CONTENT (`encoder.c:2079` derives `allow_screen_content_tools`
12//! from block counts, and `seq_force_screen_content_tools` is left at the
13//! adaptive `SELECT_SCREEN_CONTENT_TOOLS`), and `speed_features.c` masks
14//! several tools OFF again per `--cpu-used`. A `1` default proves the encoder
15//! was ALLOWED the tool, never that any block used it.
16//!
17//! With that default in place it is possible -- and it happened -- for a
18//! coding tool to be switched *off in every single gate*, so that no real
19//! stream in this repository ever exercised it and a corner-cut in the
20//! decoder survived twenty gates unnoticed: `reconstruct`'s
21//! `smooth_neighbor` was hardcoded `false`, wrong whenever a directional
22//! block neighbours a smooth-mode one, and invisible because all twenty
23//! gates passed `--enable-smooth-intra=0` (lane-chroma r1, 2026-08-30).
24//!
25//! The test below re-derives that set from the gate source and pins it. A tool
26//! that is switched off in every gate and on in none is *provably never
27//! exercised* by a real stream, and belongs on [`NEVER_EXERCISED`] with a
28//! reason. Landing the decode support for one means enabling it in that
29//! feature's gate, which shrinks the derived set and fails this test until the
30//! list is updated -- the point being that the shrink is noticed.
31
32// TILING is deliberately NOT in this derivation (lane-tiles r11): the check
33// keys on `--enable-<tool>=0/1`, and `--tile-columns=<log2>` has no such
34// shape -- a `--tile-columns=` presence check would also read `=0` (one tile)
35// as coverage, which is the opposite of what it would claim. It needs no
36// entry either: measured 2026-09-29 (lane-av1distwtd r2), 19 of the 146
37// census-selected gate bodies spell `--tile-columns`/`--tile-rows` with a
38// nonzero log2 -- 9 assert the parsed `tile_info` in the same body and 10
39// more delegate to a shared helper that asserts it -- and
40// `run_multi_tile_gate` covers a 2D grid with the coding tools ON at both
41// bit depths.
42
43/// aomenc coding tools that no real-`aomenc` gate is proven to exercise:
44/// switched off in every gate that names them, and on in none.
45///
46/// A gate that simply leaves the flag off its command line does NOT close the
47/// hole. aomenc's default for these is content-dependent -- palette and
48/// intrabc only come on for screen content -- so "defaulted" means "unknown",
49/// not "exercised", and treating it as coverage would retire the entry
50/// without a single stream proving the decoder ever saw the tool. Only an
51/// explicit `--enable-<tool>=1` in a gate that then asserts the feature fired
52/// closes one.
53///
54/// Each entry is `(flag, why)`. Removing an entry is how a lane records that
55/// its tool is now covered by a real stream.
56#[cfg(test)]
57const NEVER_EXERCISED: &[(&str, &str)] = &[
58 // `enable-intrabc` LEFT this list on 2026-09-02 (lane-kf900 r6). The
59 // premise it carried -- "every real stream's intrabc block sits under
60 // TX_MODE_SELECT" -- was false: with `--enable-tx-size-search=0` aomenc
61 // codes intrabc blocks under TX_MODE_LARGEST, and
62 // `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips`
63 // spells `--enable-intrabc=1` and decodes three such 8-bit streams whole-
64 // frame pixel-exact against ffmpeg, with the block counter asserted > 0.
65 // Re-verified 2026-09-17 (lane-av1-intrabc) at main f715d70c: 185 rect
66 // `use_intrabc` symbols read, and 5 blocks took the DV path -- 4 of them
67 // DECODED whole-frame pixel-exact across 4 arms (7 frames compared, 0
68 // mismatches). The fifth is the testsrc2 rectangle-strip arm, which reads
69 // the symbol and then refuses by name (the `intrabc_hits` bump happens on
70 // the READ), so "5 blocks decoded" would overcount: 4 decoded + 1 refused,
71 // exactly the single `refused == 1` the gate asserts.
72];
73
74/// The `--enable-*` tools this decoder cares about, whether or not any gate
75/// names one. A flag no gate mentions is *defaulted*, i.e. unknown, and by the
76/// rule above unknown is not coverage -- so the universe is fixed here rather
77/// than derived from the gate source, which would silently shrink to whatever
78/// the gates happen to spell.
79#[cfg(test)]
80const TOOL_UNIVERSE: &[&str] = &[
81 "enable-1to4-partitions",
82 "enable-ab-partitions",
83 "enable-angle-delta",
84 "enable-cdef",
85 "enable-cfl-intra",
86 "enable-dist-wtd-comp",
87 "enable-dual-filter",
88 "enable-filter-intra",
89 "enable-flip-idtx",
90 "enable-global-motion",
91 "enable-interintra-comp",
92 "enable-intra-edge-filter",
93 "enable-intrabc",
94 "enable-masked-comp",
95 "enable-obmc",
96 "enable-order-hint",
97 "enable-paeth-intra",
98 "enable-palette",
99 "enable-rect-partitions",
100 "enable-rect-tx",
101 "enable-ref-frame-mvs",
102 "enable-restoration",
103 "enable-smooth-intra",
104 "enable-superres",
105 "enable-tx64",
106 "enable-warped-motion",
107];
108
109/// How a non-boolean aomenc knob reads as "the tool is on".
110#[cfg(test)]
111#[derive(Clone, Copy, PartialEq)]
112enum On {
113 /// Any non-zero value enables the tool (`--tile-columns=1`, `--loopfilter-control=1`).
114 NonZero,
115 /// The tool's search only runs at or below this speed (`--cpu-used`).
116 AtMost(u32),
117}
118
119/// Coding tools aomenc drives through a spelling [`TOOL_UNIVERSE`] does not
120/// cover, listed with their aomenc default.
121///
122/// lane-covbd's derivation read `--enable-*` flags only, so a tool a gate pins
123/// off through another spelling was invisible: every gate that named
124/// `--enable-tx-size-search` passed `--enable-tx-size-search=0` when this was
125/// written, and the real-stream PANIC hiding behind that pin was found by
126/// lane-ab16, not by this guard. `--loopfilter-control=0`,
127/// `--tile-columns=0` and a `--cpu-used` high enough to switch a search off are
128/// the same shape.
129///
130/// The "all 49" count is GONE as of 2026-09-29 (lane-av1distwtd r2) and is
131/// deliberately not replaced by a number: the tool is no longer pinned off
132/// tree-wide, so any count would be a snapshot that rots the same way.
133/// Measured on this tree for the record: 113 of the 146 selected gate bodies
134/// name it, 88 pass `=0`, 15 pass `=1`, and 9 build the value into a
135/// `format!` variable the census cannot see -- so the historical claim no
136/// longer holds in EITHER direction, and the `enable-tx-size-search` entry
137/// below is a live question, not a settled one.
138///
139/// Each entry is `(tool, spellings, aomenc default, what counts as on)`. The
140/// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a
141/// default of `1` does not prove the encoder picked the tool for any stream, so
142/// only a gate that spells an on-value at that bit depth retires an entry.
143 // lane-av1distwtd r3: `enable-tx-size-search` is the one DEFAULT_ON_TOOLS
144 // entry the r2 audit could NOT settle, and the reason is a THIRD detector
145 // limit rather than a coverage fact. After the r3 call-resolving fix, 113
146 // of the 230 selected gates name it: 88 pass `=0`, 15 pass `=1`, and 9
147 // build the value into a `format!`/`String` variable that neither
148 // `flags_in` nor `settings_in` can see, because both scan for a literal
149 // `"--flag=value"` inside one segment.
150 //
151 // WHAT WOULD SETTLE IT, for whoever takes it next -- the method, not a
152 // guess: extend `flags_in`/`settings_in` to resolve a local binding, the
153 // same way `gate_bodies` now resolves calls. Concretely, when a segment
154 // contains `let <name> = format!("--enable-tx-size-search={tx_search}")`
155 // (or a `String::from`/`to_string` of the same shape), record the
156 // TEMPLATE and bind the variable's value at each use site. Re-count, and
157 // only then decide whether the tool is a live hole. Until that exists the
158 // count above is a floor, not a measurement: 9 gates are unclassified in
159 // an unknown direction, and an unknown direction is exactly the failure
160 // mode this file exists to prevent.
161#[cfg(test)]
162const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
163 (
164 "enable-tx-size-search",
165 &["enable-tx-size-search"],
166 "1",
167 On::NonZero,
168 ),
169 (
170 "enable-directional-intra",
171 &["enable-directional-intra"],
172 "1",
173 On::NonZero,
174 ),
175 (
176 "enable-smooth-interintra",
177 &["enable-smooth-interintra"],
178 "1",
179 On::NonZero,
180 ),
181 (
182 "enable-interintra-wedge",
183 &["enable-interintra-wedge"],
184 "1",
185 On::NonZero,
186 ),
187 (
188 "enable-diff-wtd-comp",
189 &["enable-diff-wtd-comp"],
190 "1",
191 On::NonZero,
192 ),
193 (
194 "enable-onesided-comp",
195 &["enable-onesided-comp"],
196 "1",
197 On::NonZero,
198 ),
199 ("enable-fwd-kf", &["enable-fwd-kf"], "0", On::NonZero),
200 ("deblocking", &["loopfilter-control"], "1", On::NonZero),
201 (
202 "multi-tile",
203 &["tile-columns", "tile-rows"],
204 "0",
205 On::NonZero,
206 ),
207 ("intrabc-search", &["cpu-used"], "0", On::AtMost(2)),
208];
209
210/// Non-`--enable-*` spellings that drive a [`TOOL_UNIVERSE`] tool.
211///
212/// `--superres-mode=1` is how every superres gate switches superres on;
213/// without this map they read as an `enable-superres` hole while a real stream
214/// exercises the tool (lane-covbd deferred exactly this). The count was "all
215/// three" until 2026-09-29 (lane-av1distwtd r2), which measured SIX gates
216/// spelling a nonzero `--superres-mode` (5 among the 146 census-selected
217/// bodies, plus `a_superres_census_over_six_real_streams_...`). No count is
218/// given here for the same reason as `enable-tx-size-search` above: it rots.
219/// Worth noting the alias is the ONLY positive evidence for superres, and
220/// those gates do assert arrival -- `superres_hits` / `predict_scaled_hits`
221/// are read in five of them -- so this one is a healthy alias, not a
222/// spelling-only one.
223#[cfg(test)]
224const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")];
225
226/// Coverage is per (tool x bit depth), not per tool.
227///
228/// lane-hbdinter found two 10-bit-only defects (SGR box sums unscaled, Wiener
229/// clamp pinned at the 8-bit bound) that survived the "10-bit bit-exact"
230/// milestone because every 10-bit gate passed `--enable-restoration=0`:
231/// `enable-restoration` is positively exercised -- at 8 bits only. A tool the
232/// 8-bit gates cover says nothing about the high-bit-depth path through the
233/// same code, so the two lists below are pinned separately.
234///
235/// Each entry is `(flag, why)`. A gate that passes `--enable-<tool>=1` at that
236/// depth retires the entry, and this test fails until it is deleted.
237#[cfg(test)]
238const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
239 // `enable-cfl-intra` LEFT both lists on 2026-09-02 (lane-reelckf r1): the
240 // sb128 skipped-CfL / 1:4-chroma gate passes `--enable-cfl-intra=1` at 8
241 // AND 10 bits and pixel-compares both arms.
242 // `enable-dist-wtd-comp` LEFT this list on 2026-09-29 (lane-av1distwtd).
243 // The entry's stated reason was WRONG: the distance-weighted compound
244 // combine is not unimplemented -- `compound::dist_wtd_comp_weight_assign`
245 // (lane-av1comp) and `mc::combine_compound`'s weighted path have been in
246 // the tree for a long time. What was missing was a stream CARRYING the
247 // tool, and `a_distance_weighted_compound_stream_decodes_pixel_exact`
248 // (stream.rs) now supplies one: it spells `--enable-dist-wtd-comp=1` and
249 // asserts the PARSED sequence header carries `enable_jnt_comp == true`
250 // (and `false` from the same recipe with `=0`, so the bit is proven to
251 // move with the flag), that `dist_wtd_comp_hits() > 0` -- the
252 // `compound_idx == 0` arm, the only branch whose blend weights are not the
253 // constant (8, 8) -- and pixel-compares every frame against the oracle.
254 // The existing lane-cwarp compound-warp gates already SPELLED `=1` and
255 // the census still read this entry as open, so the hole was a missing
256 // witness, not a missing flag.
257 // `enable-dual-filter` LEFT this list on 2026-09-29 (lane-av1distwtd r3),
258 // paid by a DETECTOR fix rather than by a new gate. The r2 audit found
259 // this entry's reason false on both halves. It is spelled -- as `=0`, by
260 // `real_aomenc_1to4_streams_...` and
261 // `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_...` -- so
262 // "never spelled" was wrong; and a stream IS proven to carry the tool,
263 // because `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
264 // spells `--enable-dual-filter=1` and hard-asserts
265 // `decode::dual_filter_diff_hits()` moved, the differing-direction arrival
266 // assert (`resolve_interp_filter` in decode.rs). That gate builds its
267 // stream through `inter_sb_none_gate`, so it spells none of the three
268 // tokens `gate_bodies()` used to filter on and was INVISIBLE to the
269 // census; r3 made `gate_bodies()` resolve calls as well as spellings, and
270 // `the_detector_sees_the_gates_the_spelling_filter_missed` pins that.
271 // Supporting measurement: with the flag left off the command line the
272 // parsed sequence header already carries `enable_dual_filter = true`
273 // (6855 B), while `--enable-dual-filter=0` parses false and encodes
274 // different bytes (6874 B) -- so the gates pinning it `=0` were removing
275 // the tool and the ones leaving it defaulted carry it.
276 //
277 // `enable-flip-idtx` LEFT this list the same day, also by detector fix.
278 // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
279 // spells `=1` and hard-asserts `compared_class1 > 0` ("--enable-flip-idtx=1
280 // never produced a V_DCT/H_DCT transform on a compared attempt"). Its
281 // recipe is parameterised on `ten_bit` and names BOTH fixture formats, so
282 // `is_ten_bit` filed the whole body 10-bit-ONLY and the 8-bit bucket
283 // never saw it -- the lane-defon/reelckf blind spot through a THIRD
284 // spelling, which r3 taught `covers_both_depths` to recognise as the
285 // pair-of-formats marker. Measured run of that gate: 12 pixel-exact
286 // decodes, 6 of them 8-bit, 219 rect coefficient TUs of which 10 carry a
287 // 1D tx class.
288 // `enable-global-motion` LEFT this list on 2026-09-25 (lane-av1gwarp12 r2):
289 // `a_real_affine_global_motion_stream_decodes_pixel_exact` loops
290 // `for depth in [8u32, 10u32]` passing `--enable-global-motion=1` and
291 // pixel-compares both depths, so the 8-bit hole has been closed since
292 // lane-gmaffine r1 -- the entry survived because no suite ran a tree
293 // containing both the gate and this test until the ROTZOOM suite.
294 // The 12-bit ROTZOOM gate rides the high-depth bucket via `encode_12bit(`
295 // in `is_ten_bit`, so it plays no part in this retirement.
296 // `enable-rect-tx` -- reason RE-VERIFIED 2026-09-29 (lane-av1distwtd
297 // r2), both halves still TRUE, and the second half is now PROVEN rather
298 // than asserted. (1) "never spelled": measured across all 146
299 // census-selected gate bodies, zero spell `--enable-rect-tx` at either
300 // depth -- the only `--enable-*` tool in [`TOOL_UNIVERSE`] with no
301 // spelling anywhere. (2) "reach the decoder only through partition
302 // shape": aom 3.13.3 has no sequence-header bit for it. `enable_rect_tx`
303 // is an `AV1E_SET_ENABLE_RECT_TX` encoder-search control
304 // (`av1_cx_iface.c:2125`, copied to `txfm_cfg->enable_rect_tx` at
305 // `av1_cx_iface.c:1483`) and is read ONLY inside `tx_search.c`
306 // (lines 2568/2662/2686/2710/2956); `bitstream.c` writes no such bit, and
307 // this crate's `SequenceHeader` (`ec-av1-syntax/src/sequence.rs`) has no
308 // such field. The decoder's own gate is `is_rect_tx_allowed`, derived
309 // from partition shape -- exactly what this reason says. A gate can
310 // therefore never prove this tool by naming the flag, only by proving a
311 // rect transform unit fired (`rect_partition_hits` /
312 // `rect_coeff_tu_hits`, which lane-rect1d's gate does assert).
313 // `enable-rect-tx` LEFT this list on 2026-09-29 (merge wave 2,
314 // lane-av1toolgates). Both halves of the reason recorded above still hold
315 // as statements about the FLAG, and the second is exactly why the closing
316 // evidence is a parsed shape and not a spelling: `enable_rect_tx` has no
317 // sequence-header bit, so a decoder path can never be proven by naming the
318 // flag -- only by proving a rect transform unit fired.
319 // `a_real_aomenc_8bit_stream_with_a_rect_transform_decodes_pixel_exact`
320 // (and its 10-bit twin) now spell `--enable-rect-tx=1` in their OWN test
321 // bodies -- inline on purpose, because a helper-owned recipe collapses
322 // both gates into one helper segment that `is_ten_bit` files 10-bit, and
323 // the 8-bit hole would stay open -- and prove the tool on the PARSED
324 // shape: `rect_partition_hits()` and `rect_coeff_tu_hits()` are both
325 // asserted > 0 over arms that decoded AND pixel-compared, and each
326 // counter is mutation-proven red on its own message.
327 // Census on the merged tree (`print_never_exercised_per_bit_depth`):
328 // 255 real-aomenc gate bodies, NEVER_EXERCISED derived EMPTY at 8 bits
329 // and at 10 bits -- 0 of 26 tools -- so this list is empty on the same
330 // evidence, not by deletion of a claim.
331];
332
333#[cfg(test)]
334const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
335 // lane-cwarp's 10-bit compound-global-warp gate closed `enable-global-motion`
336 // and `enable-dist-wtd-comp` at 10 bits without deleting their entries here,
337 // so this list was already stale (and this test already red) at main 9c35ecc;
338 // lane-tiles r11's multi-tile 10-bit gates then closed `enable-ab-partitions`,
339 // `enable-rect-partitions` and `enable-restoration` at 10 bits. All five
340 // deleted together.
341
342 // The "Only 4 of the 45 real-aomenc gates encode at 10 bits" sentence that
343 // stood here is STALE (lane-av1distwtd r2, 2026-09-29), and understated
344 // the high-depth bucket by more than an order of magnitude. Measured
345 // against this tree with `gate_bodies()`' own filter: 146 selected gate
346 // bodies, of which 83 are classified 10-bit-or-higher by `is_ten_bit`.
347 // The historical point stands -- those gates pin the pixel filters and
348 // the intra tool set off far more often than not -- but the counts a
349 // reader would check them against no longer exist.
350 // Every entry the 8-bit list carries is a hole here too. lane-hbdgates r1
351 // closed six of the seven 8-bit-only entries with real 10-bit gates
352 // paeth-intra, intra-edge-filter, rect-partitions, ab-partitions); its
353 // seventh, the 10-bit LR gate, was `#[ignore]`d on that branch and passes
354 // un-ignored on main, which carries the fix.
355 // `enable-restoration` LEFT this list on 2026-09-01: lane-hbdinter's
356 // 10-bit inter gate passes `--enable-restoration=1` and asserts a real
357 // Wiener/SGR unit fired, which is what caught the two defects (SGR box
358 // sums never brought back to the 8-bit scale, Wiener clamp at the wrong
359 // bound). `enable-dist-wtd-comp` and `enable-global-motion` left it the
360 // same day for the same reason: lane-cwarp's 10-bit compound global-warp
361 // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02:
362 // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both
363 // orientations and coded strips inside pixel-exact attempts.
364 // `enable-dual-filter` -- reason CORRECTED 2026-09-29 (lane-av1distwtd
365 // r3), and this entry STAYS while its 8-bit twin was retired. That is the
366 // honest outcome, not an oversight: after the r3 detector fix the 8-bit
367 // bucket sees the tool exercised and the 10-bit bucket still does not.
368 // The only `=1` witness is
369 // `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
370 // and it calls `inter_sb_none_gate(NAME, false, ...)` -- `false` is the
371 // `ten_bit` parameter, so that gate builds an 8-bit stream only. Its
372 // sibling `a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact`
373 // passes `true`, and the 8x8-leaf pair likewise, but none of those spells
374 // `--enable-dual-filter=1`. So: exercised at 8 bits (arrival assert
375 // `dual_filter_diff_hits()` moved, `resolve_interp_filter` in decode.rs),
376 // NOT exercised at 10 bits. Retiring this entry needs a 10-bit arm of that
377 // gate -- pass `true` to `inter_sb_none_gate` and assert the differing-
378 // direction counter still moves there.
379 //
380 // The two numbers in the `enable-flip-idtx` retirement below were
381 // RE-MEASURED 2026-09-29 (lane-av1distwtd r2) by running the gate, and
382 // both still hold exactly: "pixel-compares six 10-bit decodes" (the run
383 // reports 12 pixel-exact decodes, 6 of them 10-bit) and "10 of its rect
384 // coefficient TUs carry a 1D tx class" (219 rect coefficient TUs on
385 // compared attempts, 10 of them 1D). The gate also hard-asserts
386 // `compared_class1 > 0`, so its "passes =1 at both depths" is backed by an
387 // arrival assert, not just a spelling.
388 // `enable-dual-filter` LEFT this list on 2026-09-29 (merge wave 2,
389 // lane-av1dualfilter10), by exactly the 10-bit arm the note above names.
390 // `a_real_aomenc_10bit_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
391 // spells `--enable-dual-filter=1` in its own body and hard-asserts the
392 // arrival counter `decode::dual_filter_diff_hits()` moved at 10 BITS, so
393 // the entry is closed at the depth it was held open at, not by a spelling
394 // alone.
395 // `enable-flip-idtx` LEFT this list on 2026-09-02 (lane-rect1d r1):
396 // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
397 // passes `=1` at both depths and pixel-compares six 10-bit decodes, so the
398 // flip/identity/1D transform types are proven to reach a real 10-bit stream
399 // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a
400 // 1D tx class).
401 // `enable-intrabc` LEFT this 10-bit list on 2026-09-02 (lane-kf900 r6).
402 // The entry it first rested on was a flag spelling -- the palette gate's
403 // `smptebars-screen-txs-cq40/cq55` arms pass `--enable-intrabc=1` -- and
404 // lane-av1-intrabc MEASURED that those arms decode ZERO intrabc blocks at
405 // both depths, so they retired the entry without a stream carrying the
406 // tool (class `tool-disabled-in-every-gate`, the same defect this list
407 // exists for). The closing evidence is now
408 // `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact`: its sb128
409 // screen recipes run at 10 bits and hard-assert a decoded intrabc block
410 // per depth (4-6 per arm), every frame pixel-compared against ffmpeg's own
411 // 10-bit decode.
412 // `enable-rect-tx` LEFT this list on 2026-09-29 (merge wave 2,
413 // lane-av1toolgates), together with its 8-bit twin, by
414 // `a_real_aomenc_10bit_stream_with_a_rect_transform_decodes_pixel_exact`:
415 // the depth is spelled in the test's OWN body, which is what files it in
416 // the 10-bit bucket, and the witness is the parsed shape
417 // (`rect_partition_hits()` / `rect_coeff_tu_hits()` > 0 over arms that
418 // decoded AND pixel-compared). See the 8-bit list for why the flag alone
419 // could never have been the evidence.
420];
421
422/// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.
423///
424/// Each entry is `(tool, why)`; the reason states whether the tool is pinned
425/// OFF in every gate that names it (a hard hole -- no stream can carry it) or
426/// merely defaulted (unknown, and unknown is not coverage).
427#[cfg(test)]
428const NEVER_ON_8BIT: &[(&str, &str)] = &[];
429
430/// [`DEFAULT_ON_TOOLS`] entries no 10-bit gate spells on, with the reason.
431#[cfg(test)]
432const NEVER_ON_10BIT: &[(&str, &str)] = &[];
433
434#[cfg(test)]
435mod tests {
436 use super::{
437 On, ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_10BIT,
438 NEVER_EXERCISED_8BIT, NEVER_ON_10BIT, NEVER_ON_8BIT, TOOL_UNIVERSE,
439 };
440 use std::collections::{BTreeMap, BTreeSet};
441
442 /// Whether `body` contains a call to the `fn` named `name`.
443 ///
444 /// The name must not be the tail of a longer identifier, or
445 /// `inter_sb_none_gate` would "call" `sb_none_gate`.
446 fn calls_fn(body: &str, name: &str) -> bool {
447 let ident = |b: u8| b.is_ascii_alphanumeric() || b == b'_';
448 let mut at = 0usize;
449 while let Some(rel) = body[at..].find(name) {
450 let start = at + rel;
451 let end = start + name.len();
452 let starts_clean = start == 0 || !ident(body.as_bytes()[start - 1]);
453 if starts_clean && body[end..].starts_with('(') {
454 return true;
455 }
456 at = end;
457 }
458 false
459 }
460
461 /// Every `fn` defined in `stream.rs`'s test module, as `(name, body)`.
462 ///
463 /// The census reasons about whole `#[`-segments (see [`gate_bodies`]) but
464 /// has to know which segment DEFINES or CALLS an encoder-driving `fn`, and
465 /// the only way to answer that is to name the units.
466 fn fn_units(src: &'static str) -> Vec<(&'static str, &'static str)> {
467 const OPEN: &str = "\n fn ";
468 let mut units = Vec::new();
469 let mut at = 0usize;
470 while let Some(rel) = src[at..].find(OPEN) {
471 let head = at + rel + OPEN.len();
472 let Some(paren) = src[head..].find('(') else {
473 break;
474 };
475 let close = src[head..]
476 .find("\n }\n")
477 .map_or(src.len(), |e| head + e);
478 units.push((&src[head..head + paren], &src[head..close]));
479 at = close.max(head + paren + 1);
480 }
481 units
482 }
483
484 /// Names of every `fn` in `stream.rs` that drives the real `aomenc`,
485 /// DIRECTLY (it mentions `aomenc_path()`) or by DELEGATING to one.
486 ///
487 /// lane-av1distwtd r3: the transitive closure is the whole point. A gate
488 /// that hands its recipe to a shared helper (`inter_sb_none_gate` and
489 /// friends) never spells `--passes=1` itself, so the old token filter
490 /// dropped it -- 165 of 311 segments, 6 of which spell `--enable-X=1`.
491 /// That is not a coverage fact, it is a segmentation fact, and it is what
492 /// kept `enable-dual-filter` on the never-exercised lists while a named
493 /// gate exercised the tool and hard-asserted the arrival.
494 fn encoder_fns(src: &'static str) -> BTreeSet<&'static str> {
495 let units = fn_units(src);
496 let mut enc: BTreeSet<&'static str> = units
497 .iter()
498 .filter(|(_, body)| body.contains("aomenc_path()"))
499 .map(|(name, _)| *name)
500 .collect();
501 // Fixpoint: `inter_sb_none_gate` is an encoder fn because it names
502 // `aomenc_path()`; the `#[test]` that only CALLS it is a gate too.
503 loop {
504 let mut grew = false;
505 for (name, body) in &units {
506 if enc.contains(name) {
507 continue;
508 }
509 if enc.iter().any(|e| calls_fn(body, e)) {
510 enc.insert(name);
511 grew = true;
512 }
513 }
514 if !grew {
515 return enc;
516 }
517 }
518 }
519
520 /// The token spellings the filter used before it resolved calls. Kept as a
521 /// floor: a gate is still recognised by these even if the call graph
522 /// misses it, so the fix can only ever ADD gates, never lose one.
523 fn legacy_gate_tokens(body: &str) -> bool {
524 body.contains("\"--passes=1\"")
525 || body.contains("ten_bit_tool_gate(")
526 || body.contains("encode_10bit_gradients")
527 }
528
529 /// Bodies of the real-aomenc gates: a `fn` body that drives the real
530 /// `aomenc`, however it gets there. Split on the attribute that opens a
531 /// test.
532 ///
533 /// lane-av1distwtd r3: a segment qualifies if it spells one of the
534 /// [`legacy_gate_tokens`] OR names an encoder `fn` -- either by defining
535 /// one (it mentions `aomenc_path()`) or by calling one. Recognition by
536 /// CALL is what a helper-delegating gate needs: its flags live in the
537 /// helper it calls, and it is invisible to a spelling-only filter.
538 fn gate_bodies() -> Vec<&'static str> {
539 let src = include_str!("stream.rs");
540 let enc = encoder_fns(src);
541 let gates: Vec<&str> = src
542 .split("\n #[")
543 // lane-hbdgates r1: an `#[ignore]`d gate exercises nothing, so it
544 // must not close a hole. Its body is the segment that opens with
545 // the ignore attribute.
546 .filter(|body| !body.starts_with("ignore"))
547 // lane-av1distwtd r3: a segment qualifies by what it SPELLS
548 // (`legacy_gate_tokens`) or by what it CALLS. `calls_fn` is
549 // deliberately the weak half of an OR, so the fix can only add
550 // gates -- it can never stop recognising one the old filter did.
551 .filter(|body| {
552 legacy_gate_tokens(body)
553 || body.contains("aomenc_path()")
554 || enc.iter().any(|e| calls_fn(body, e))
555 })
556 .collect();
557 assert!(
558 gates.len() >= 20,
559 "expected the real-aomenc gates, found {}",
560 gates.len()
561 );
562 gates
563 }
564
565 /// `--enable-<flag>=<value>` settings spelled inside one gate body.
566 fn flags_in(gate: &str) -> BTreeMap<String, char> {
567 let mut here = BTreeMap::new();
568 for (i, _) in gate.match_indices("\"--enable-") {
569 let rest = &gate[i + 3..];
570 let Some(end) = rest.find('"') else { continue };
571 let Some((flag, value)) = rest[..end].split_once('=') else {
572 continue;
573 };
574 let Some(value) = value.chars().next() else {
575 continue;
576 };
577 here.insert(flag.to_owned(), value);
578 }
579 here
580 }
581
582 /// Every `--flag=value` spelled inside one gate body, values kept whole
583 /// (`--cpu-used=4`, `--tile-columns=2`), not just their first character.
584 fn settings_in(gate: &str) -> BTreeMap<String, String> {
585 let mut here = BTreeMap::new();
586 for (i, _) in gate.match_indices("\"--") {
587 let rest = &gate[i + 3..];
588 let Some(end) = rest.find('"') else { continue };
589 let Some((flag, value)) = rest[..end].split_once('=') else {
590 continue;
591 };
592 here.insert(flag.to_owned(), value.to_owned());
593 }
594 here
595 }
596
597 /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off.
598 fn default_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
599 let here = settings_in(gate);
600 let mut state = None;
601 for spelling in spellings {
602 let Some(value) = here.get(*spelling) else {
603 continue;
604 };
605 let Ok(value) = value.parse::<u32>() else {
606 continue;
607 };
608 let is_on = match on {
609 On::NonZero => value != 0,
610 On::AtMost(limit) => value <= limit,
611 };
612 // Any spelling that says "on" wins: --tile-columns=0 --tile-rows=1
613 // is a multi-tile stream.
614 state = Some(state.unwrap_or(false) || is_on);
615 }
616 state
617 }
618
619 /// `--enable-*` settings per real-aomenc gate, derived from the gate
620 /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.
621 fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {
622 let gates = gate_bodies();
623
624 let mut per_tool: BTreeMap<String, (usize, usize, usize)> = BTreeMap::new();
625 let mut names: BTreeSet<String> = BTreeSet::new();
626 let mut seen: Vec<BTreeMap<String, char>> = Vec::new();
627 for gate in &gates {
628 let here = flags_in(gate);
629 names.extend(here.keys().cloned());
630 seen.push(here);
631 }
632 for name in names {
633 let off = seen.iter().filter(|g| g.get(&name) == Some(&'0')).count();
634 let on = seen.iter().filter(|g| g.get(&name) == Some(&'1')).count();
635 per_tool.insert(name, (off, on, gates.len() - off - on));
636 }
637 (gates.len(), per_tool)
638 }
639
640 #[test]
641 fn every_gate_disabling_a_tool_is_a_listed_coverage_hole() {
642 let (gate_count, per_tool) = tool_settings();
643 // A hole OPENS when every gate names the flag and every one of them
644 // says 0 -- then no real stream can exercise the tool.
645 let derived: BTreeSet<&str> = per_tool
646 .iter()
647 .filter(|&(_, &(off, on, defaulted))| off == gate_count && on == 0 && defaulted == 0)
648 .map(|(name, _)| name.as_str())
649 .collect();
650 // A hole CLOSES only on positive evidence: some gate passes `=1`.
651 // A gate that merely leaves the flag off its command line proves
652 // nothing -- aomenc's default for palette and intrabc is content-
653 // dependent -- so "defaulted" must not retire an entry, or a listing
654 // would disappear the moment an unrelated gate is added.
655 let exercised: BTreeSet<&str> = per_tool
656 .iter()
657 .filter(|&(_, &(_, on, _))| on > 0)
658 .map(|(name, _)| name.as_str())
659 .collect();
660 let listed: BTreeSet<&str> = NEVER_EXERCISED.iter().map(|&(flag, _)| flag).collect();
661
662 let unlisted: Vec<&&str> = derived.difference(&listed).collect();
663 assert!(
664 unlisted.is_empty(),
665 "these aomenc tools are switched off in all {gate_count} real-aomenc gates and on in \
666 none, so no real stream exercises them, and they are not listed in NEVER_EXERCISED: \
667 {unlisted:?} -- either enable the tool with `=1` in its own gate or add it to the \
668 list with a reason"
669 );
670 let stale: Vec<&&str> = listed.intersection(&exercised).collect();
671 assert!(
672 stale.is_empty(),
673 "NEVER_EXERCISED lists {stale:?}, but a gate now passes `=1` for them -- delete \
674 those entries, the coverage hole is closed"
675 );
676 }
677
678 /// The derivation is only meaningful if a flag left off a gate's command
679 /// line really does mean "aomenc's default", i.e. the parser above is
680 /// reading whole flags and not fragments.
681 #[test]
682 fn tool_settings_reads_whole_flags() {
683 let (gate_count, per_tool) = tool_settings();
684 assert!(
685 per_tool.contains_key("enable-cdef"),
686 "expected --enable-cdef among the gate flags"
687 );
688 for (name, &(off, on, defaulted)) in &per_tool {
689 assert!(
690 !name.is_empty() && !name.contains(['"', '=']),
691 "malformed flag {name:?}"
692 );
693 assert_eq!(
694 off + on + defaulted,
695 gate_count,
696 "{name} counts do not cover every gate"
697 );
698 }
699 }
700
701 /// A gate encodes at 10 bits when its recipe says so: the shared 10-bit
702 /// helper, an explicit `--bit-depth=10`/`--input-bit-depth=10`, or a
703 /// `yuv420p10le` fixture handed to aomenc. Everything else is aomenc's
704 /// 8-bit default.
705 /// lane-defon r1: a gate helper parameterised on `bit_depth` builds BOTH
706 /// an 8-bit and a 10-bit stream from one recipe, so its flags cover both
707 /// depths -- classifying it by the 10-bit strings inside its conditional
708 /// alone hid `--enable-tx-size-search=1` from the 8-bit list.
709 /// lane-reelckf r1: the same blind spot with the other spelling -- a gate
710 /// that loops `for depth in [8usize, 10]` builds BOTH streams from one
711 /// recipe, but its `yuv420p10le` arm made `is_ten_bit` classify it as
712 /// 10-bit only, hiding `--enable-cfl-intra=1` from the 8-bit list.
713 /// lane-av1-intrabc r1: the shared recipe helper
714 /// `screen_intrabc_stream_at_depth` is parameterised on `depth` and sits in
715 /// the segment that opens at the PRECEDING gate's `#[test]`, so without
716 /// this marker that gate's own 8-bit-only flags read as 10-bit-only -- the
717 /// lane-defon/reelckf blind spot with `depth` spelled instead of
718 /// `bit_depth`. Three gates share the helper, at both depths.
719 /// lane-av1distwtd r3: the THIRD spelling of the same blind spot, still
720 /// live after lane-defon and lane-reelckf. A recipe parameterised on
721 /// `ten_bit` names BOTH fixture formats in one body -- `let pix_fmt = if
722 /// ten_bit { "yuv420p10le" } else { "yuv420p" };` -- so `is_ten_bit` saw
723 /// the 10-bit arm and filed the whole body 10-bit-ONLY, hiding its 8-bit
724 /// arm from the 8-bit bucket. The marker is the PAIR OF FORMATS, not the
725 /// parameter name: a body spelling both pixel formats builds streams at
726 /// both depths, whatever it calls the flag. The quotes matter -- a bare
727 /// `yuv420p` substring test also matches `yuv420p10le` and would fire on
728 /// every 10-bit gate, retiring entries on no evidence.
729 ///
730 /// This is what mis-filed `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
731 /// and kept `enable-flip-idtx` on the 8-bit list while that gate ran 6
732 /// pixel-exact 8-bit decodes through it.
733 fn covers_both_depths(body: &str) -> bool {
734 body.contains("if bit_depth == 10")
735 || body.contains("if depth == 10")
736 || body.contains("for depth in [8usize, 10]")
737 || (body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\""))
738 }
739
740 /// lane-av1distwtd r3: the detector fix, pinned. A detector change with
741 /// no test can only be shown to find MORE, never to stop missing, so this
742 /// asserts the three gates the two blind spots actually hid are now seen
743 /// -- the two `enable-dual-filter` witnesses and the `enable-flip-idtx`
744 /// both-depths gate -- and that the fix is strictly ADDITIVE against the
745 /// old spelling-only filter.
746 #[test]
747 fn the_detector_sees_the_gates_the_spelling_filter_missed() {
748 let src = include_str!("stream.rs");
749 let gates = gate_bodies();
750 // The helper-delegation half: each of these builds its stream through
751 // `inter_sb_none_gate` and spells none of `legacy_gate_tokens`, so the
752 // old filter dropped both while each hard-asserts its tool arrived.
753 for name in [
754 "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact",
755 "a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour",
756 ] {
757 let body = gates
758 .iter()
759 .find(|b| b.contains(name))
760 .unwrap_or_else(|| panic!("{name}: not seen by gate_bodies()"));
761 assert_eq!(
762 flags_in(body).get("enable-dual-filter"),
763 Some(&'1'),
764 "{name}: seen, but its --enable-dual-filter=1 spelling is not visible to \
765 flags_in, so recognising the gate would not retire the entry"
766 );
767 }
768 // The both-depths half: this gate's recipe is parameterised on `ten_bit`
769 // and names both fixture formats, so `covers_both_depths` must credit
770 // it to the 8-bit bucket, not just the 10-bit one.
771 let flip = gates
772 .iter()
773 .find(|b| {
774 b.contains("a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform")
775 })
776 .expect("the flip-idtx gate must be seen");
777 assert!(
778 covers_both_depths(flip),
779 "the flip-idtx gate spells both fixture formats, so covers_both_depths must \
780 credit it to the 8-bit bucket as well"
781 );
782 assert!(
783 covers_depth(flip, false) && covers_depth(flip, true),
784 "the flip-idtx gate must cover BOTH depths"
785 );
786 // Strictly additive: every segment the old spelling-only filter kept
787 // is still kept, so the fix cannot have cost the census a gate.
788 let legacy_only: Vec<&str> = src
789 .split("\n #[")
790 .filter(|b| !b.starts_with("ignore") && legacy_gate_tokens(b))
791 .collect();
792 assert!(
793 legacy_only.len() < gates.len(),
794 "the call-resolving filter found {} gates, the old spelling-only filter found \
795 {} -- the fix is expected to ADD gates, never to drop one",
796 gates.len(),
797 legacy_only.len()
798 );
799 for body in &legacy_only {
800 assert!(
801 gates.contains(body),
802 "a gate the spelling-only filter recognised is no longer recognised: \
803 {:?}",
804 &body[..body.len().min(60)]
805 );
806 }
807 }
808
809 /// Whether a gate body drives a stream at this depth.
810 fn covers_depth(body: &str, ten_bit: bool) -> bool {
811 covers_both_depths(body) || is_ten_bit(body) == ten_bit
812 }
813
814 fn is_ten_bit(body: &str) -> bool {
815 // The lists pin two buckets, 8-bit and high-bit-depth; 12-bit gates
816 // count in the high-depth bucket (lane-av1gwarp12's ROTZOOM gate was
817 // the first 12-bit gate to positively enable a listed tool, and the
818 // 10-bit-only spellings mis-filed it as 8-bit).
819 body.contains("encode_10bit_gradients")
820 || body.contains("ten_bit_tool_gate(")
821 || body.contains("--bit-depth=10")
822 || body.contains("--input-bit-depth=10")
823 || body.contains("yuv420p10le")
824 || body.contains("encode_12bit(")
825 || body.contains("--bit-depth=12")
826 || body.contains("--input-bit-depth=12")
827 || body.contains("yuv420p12le")
828 }
829
830 /// Flags a gate positively enables (`=1`), at gates of the given depth.
831 fn enabled_at(ten_bit: bool) -> BTreeSet<String> {
832 let mut on = BTreeSet::new();
833 for gate in gate_bodies() {
834 if !covers_depth(gate, ten_bit) {
835 continue;
836 }
837 for (flag, value) in flags_in(gate) {
838 if value == '1' {
839 on.insert(flag);
840 }
841 }
842 // A tool driven by its own spelling counts as exercised.
843 let here = settings_in(gate);
844 for (alias, tool) in ALIASES {
845 if here.get(*alias).is_some_and(|v| v != "0") {
846 on.insert((*tool).to_owned());
847 }
848 }
849 }
850 on
851 }
852
853 /// The tools of [`TOOL_UNIVERSE`] that no gate of this depth enables.
854 fn never_exercised_at(ten_bit: bool) -> BTreeSet<&'static str> {
855 let on = enabled_at(ten_bit);
856 TOOL_UNIVERSE
857 .iter()
858 .copied()
859 .filter(|t| !on.contains(*t))
860 .collect()
861 }
862
863 fn check_depth(ten_bit: bool, listed: &[(&str, &str)]) {
864 let derived = never_exercised_at(ten_bit);
865 let listed: BTreeSet<&str> = listed.iter().map(|&(flag, _)| flag).collect();
866 let depth = if ten_bit { "10-bit" } else { "8-bit" };
867 let unlisted: Vec<&&str> = derived.difference(&listed).collect();
868 assert!(
869 unlisted.is_empty(),
870 "no {depth} gate passes `=1` for {unlisted:?}, so no real {depth} stream exercises \
871 them -- enable the tool in a {depth} gate that asserts it fired, or list it"
872 );
873 let stale: Vec<&&str> = listed.difference(&derived).collect();
874 assert!(
875 stale.is_empty(),
876 "the {depth} list still names {stale:?}, but a {depth} gate now passes `=1` for them \
877 -- delete those entries, the coverage hole is closed"
878 );
879 }
880
881 #[test]
882 fn never_exercised_8bit_matches_the_gate_recipes() {
883 check_depth(false, NEVER_EXERCISED_8BIT);
884 }
885
886 #[test]
887 fn never_exercised_10bit_matches_the_gate_recipes() {
888 check_depth(true, NEVER_EXERCISED_10BIT);
889 }
890
891 /// `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` prints both
892 /// lists, so the per-depth holes can be read without opening this file.
893 #[test]
894 fn print_never_exercised_per_bit_depth() {
895 let ten: Vec<&str> = gate_bodies()
896 .into_iter()
897 .filter(|b| is_ten_bit(b))
898 .collect();
899 let total = gate_bodies().len();
900 println!(
901 "gate_coverage: {} real-aomenc gates, {} of them 10-bit",
902 total,
903 ten.len()
904 );
905 for (label, ten_bit) in [("8BIT", false), ("10BIT", true)] {
906 let holes = never_exercised_at(ten_bit);
907 println!(
908 "NEVER_EXERCISED_{label} ({} of {}):",
909 holes.len(),
910 TOOL_UNIVERSE.len()
911 );
912 for flag in &holes {
913 println!(" --{flag}");
914 }
915 }
916 }
917
918 /// [`DEFAULT_ON_TOOLS`] per depth: `tool -> (off in N gates, on in N, defaulted in N)`.
919 fn default_on_settings(
920 ten_bit: bool,
921 ) -> (usize, BTreeMap<&'static str, (usize, usize, usize)>) {
922 let gates: Vec<&str> = gate_bodies()
923 .into_iter()
924 .filter(|b| covers_depth(b, ten_bit))
925 .collect();
926 let mut per_tool = BTreeMap::new();
927 for &(tool, spellings, _, on) in DEFAULT_ON_TOOLS {
928 let states: Vec<Option<bool>> = gates
929 .iter()
930 .map(|g| default_on_state(g, spellings, on))
931 .collect();
932 let turned_on = states.iter().filter(|s| **s == Some(true)).count();
933 let turned_off = states.iter().filter(|s| **s == Some(false)).count();
934 per_tool.insert(
935 tool,
936 (turned_off, turned_on, gates.len() - turned_off - turned_on),
937 );
938 }
939 (gates.len(), per_tool)
940 }
941
942 /// The [`DEFAULT_ON_TOOLS`] no gate of this depth positively enables.
943 fn never_on_at(ten_bit: bool) -> BTreeSet<&'static str> {
944 default_on_settings(ten_bit)
945 .1
946 .into_iter()
947 .filter(|&(_, (_, on, _))| on == 0)
948 .map(|(tool, _)| tool)
949 .collect()
950 }
951
952 fn check_default_on(ten_bit: bool, listed: &[(&str, &str)]) {
953 let derived = never_on_at(ten_bit);
954 let listed: BTreeSet<&str> = listed.iter().map(|&(tool, _)| tool).collect();
955 let depth = if ten_bit { "10-bit" } else { "8-bit" };
956 let unlisted: Vec<&&str> = derived.difference(&listed).collect();
957 assert!(
958 unlisted.is_empty(),
959 "no {depth} gate spells an on-value for {unlisted:?}, so no real {depth} stream is \
960 proven to carry them -- switch the tool on in a {depth} gate that asserts it fired, \
961 or list it with a reason"
962 );
963 let stale: Vec<&&str> = listed.difference(&derived).collect();
964 assert!(
965 stale.is_empty(),
966 "the {depth} default-on list still names {stale:?}, but a {depth} gate now switches \
967 them on -- delete those entries, the coverage hole is closed"
968 );
969 }
970
971 #[test]
972 fn never_on_8bit_matches_the_gate_recipes() {
973 check_default_on(false, NEVER_ON_8BIT);
974 }
975
976 #[test]
977 fn never_on_10bit_matches_the_gate_recipes() {
978 check_default_on(true, NEVER_ON_10BIT);
979 }
980
981 /// A tool must not be pinned twice: [`TOOL_UNIVERSE`] already derives the
982 /// `--enable-*` spellings under the `=1` rule.
983 #[test]
984 fn default_on_tools_do_not_duplicate_the_universe() {
985 for &(tool, spellings, _, _) in DEFAULT_ON_TOOLS {
986 assert!(
987 !TOOL_UNIVERSE.contains(&tool),
988 "{tool} is already covered by TOOL_UNIVERSE"
989 );
990 assert!(!spellings.is_empty(), "{tool} has no aomenc spelling");
991 }
992 for (alias, tool) in ALIASES {
993 assert!(
994 TOOL_UNIVERSE.contains(tool),
995 "alias --{alias} names {tool}, which is not a TOOL_UNIVERSE tool"
996 );
997 }
998 }
999
1000 /// `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` prints the
1001 /// default-on holes with their off/defaulted split.
1002 #[test]
1003 fn print_never_on_per_bit_depth() {
1004 for (label, ten_bit) in [("8BIT", false), ("10BIT", true)] {
1005 let (gate_count, per_tool) = default_on_settings(ten_bit);
1006 let holes = never_on_at(ten_bit);
1007 println!(
1008 "NEVER_ON_{label} ({} of {}, over {gate_count} {label} gates):",
1009 holes.len(),
1010 DEFAULT_ON_TOOLS.len()
1011 );
1012 for tool in &holes {
1013 let (off, _, defaulted) = per_tool[tool];
1014 let spellings = DEFAULT_ON_TOOLS
1015 .iter()
1016 .find(|e| e.0 == *tool)
1017 .map(|e| e.1.join(","))
1018 .unwrap_or_default();
1019 println!(
1020 " {tool} (--{spellings}): off in {off}, defaulted in {defaulted}, on in 0"
1021 );
1022 }
1023 }
1024 }
1025}