tests: cover x2w_inflate blocks, Huffman errors, Adler-32, and zlib framing #3761
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3761
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3759"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ammmae0x on GitHub · 2026-12-01 16:35 UTC · original
Ammmae0x:tests/inflate-unit→main· +1971 −0 · 5 files · 1 commits · merged 2026-12-02 02:07 UTCRefs #1149.
Standalone portable C++17 unit, boundary, and 1:1 header-mutation tests for
x2w_inflateinsrc/startup_stubs/inflate.h, with zero edits to existing files (5 new files only, +1971/-0; disjointinflate_unitprefix,tests/startup_inflate_check.py,tests/startup_inflate_probe.cpp,tests/startup_inflate_status.cpp, andCMakeLists.txtuntouched).bits/construct: LSB-first extraction across a byte boundary and thefailedflag at EOF; canonical Huffman tables, incomplete sets accepted, over-subscribed sets ({1, 1, 1}, five 2-bit codes) rejected, and decoding symbols 0, 1, 2, 0 from0x1A.copy_match/stored/fixed: distance 1 (memset), distance >= 8 with length >= 8 (chunked copy, including the exact length-8 tail), and overlapping periodic copies at distances 3 and 7, throughcopy_match()directly and throughcodes()(fast and slow paths); a match at distance 5 after"ABCD"refused with only the literals decoded. Stored blocks: zero length without == nullptr, a valid payload, badLEN ^ NLEN, truncated input, and insufficient output (overflowset); reserved block type 3 rejected. Fixed blocks: literals and a match at exact capacity (slow path only) and at 4096 (fast path), plus the fixed tables' counts and decoding'a'then'b'.dynamic/dynamic_rle/dynamic_errors/multi_block: a real dynamic stream (8799 bytes of repeated phrase); a hand-built dynamic block decoding to"ABABA"whose code-length sequence uses the repeat symbols 16, 17 and 18 (the meta check parses the block and pins the code lengths); three hand-built refusals (symbol 16 at index 0, a repeat pastnlen + ndist, a missing end-of-block code); and multi-block streams (BFINAL=0then1, and a sync flush).adler32/ zlib framing:"123456789"==0x091E01DE, empty == 1, and the 5552-byte chunk modulo boundary at 5552, 5553, 11104 and 6000 bytes.inflate_zlib_ex/inflate_zlib:corrupt_stream(null and <6-byte inputs, CM!= 8, FCHECK% 31 != 0, FDICT0x20,HLIT=31, missing/short Adler trailer),insufficient_output(one byte short in each block kind,overflowset, wrapperproduced == 0), andbad_checksum(out_sizestill set to the decoded size, wrapperproducedset vsproduced == nullptr).Mutation controls: 7
WILL_FAIL TRUECMake header-copy controls (fdict_flag,fcheck_mod,stored_nlen,oversubscribed_huffman,dynamic_eob_required,reserved_block_type,adler_modulo) mirrored 1:1 intests/inflate_unit_meta_check.py, which compiles and runs the real C++ check withg++(orcl) and every mutant against a real C++ copy, and also parses the dynamic RLE block and cross-checks the embedded streams against CPython's zlib.Caught in development: the hand-built dynamic RLE block first decoded to
"ABBBB"because distance code 0 means distance 1, not 2, so the block now carries two 1-bit distance codes and the match uses code 1; a non-final block still needs its end-of-block code, so the multi-block stream's first block now ends with one; the embedded dynamic stream was first copied with a duplicated row (95 bytes, Adler mismatch), caught by the meta check's zlib cross-check and corrected to the exact 92-byte stream; the fixed-tables decode test first calleddecode()without consuming the 3 header bits; and a plain drop of the missing-EOB check is unobservable (codes()can never emit symbol 256 without a code for it), so that mutant returns true on a missing EOB instead.Verification (Linux, this host,
g++ -std=c++17):Scratch CMake + CTest (standalone configure of the fragment, via symlinked
src/testsunderout/inflate-scratch; the full configure needs DXC, unavailable on Linux):That is 14 per-case tests,
inflate_unit_all, and the 7WILL_FAIL TRUEmutation controls.form_coverage_check.pypasses,docs_links_check.pypasses (208 files, 802 links),bidi_controls_check.pypasses (2827 files),git diff --checkis clean, merge-tree exits 0, and the fullpython-linuxsuite (tools/run_checks_parallel.py, from the CI workflow) passes with this check included:No mingw on this host, so no Windows compile check; WIN-VERIFY run is the arbiter.
Windows Verification (
119818bc)git merge-tree --write-tree upstream/main HEAD->6043debf(exit 0),git diff --check upstream/main...HEADcleanpy_compile,form_coverage_check.py,docs_links_check.py(209 files, 806 links),bidi_controls_check.py(2830 files),inflate_unit_meta_check.py(cl:14 cases, 7/7 mutations killed) passeddev22/22 passed (1.28s);release22/22 passed (0.99s); directinflate_unit_check.exe(dev&release):PASS: inflate_unit: 14/14 cases passed. AI-assisted.