Skip to content

test: make MRMesh.ZlibCompressStats engine-agnostic#5978

Merged
Fedr merged 1 commit intomasterfrom
test/zlib-stats-engine-agnostic
Apr 24, 2026
Merged

test: make MRMesh.ZlibCompressStats engine-agnostic#5978
Fedr merged 1 commit intomasterfrom
test/zlib-stats-engine-agnostic

Conversation

@Fedr
Copy link
Copy Markdown
Contributor

@Fedr Fedr commented Apr 24, 2026

Summary

Relax MRMesh.ZlibCompressStats so it stops comparing stats.compressedSize against the byte-exact size of the cRawLevel* / cWrappedLevel* reference blobs. Those blobs were captured from stock zlib, and the exact compressed byte count drifts from one deflate implementation to another — stock zlib, zlib-ng (native and compat), libdeflate, etc. all produce different (still-valid-DEFLATE) bytestreams for the same input and level, per RFC 1951's encoder latitude. The moment any part of the compress path is swapped to a non-zlib engine, this assertion fires for reasons that have nothing to do with correctness.

What the new assertions actually check

  • stats.crc32 == expectedCrc — defined by the input, engine-independent.
  • stats.uncompressedSize == sizeof( cInput ) — guards stats wiring.
  • stats.compressedSize == out.str().size() — API consistency: the stats block's claim matches the actual stream length, whichever engine produced it.
  • 0 < stats.compressedSize < sizeof( cInput ) — sanity floor + ceiling: we produced a non-empty payload, and it's strictly smaller than the input.

This preserves every property the test was actually trying to verify (CRC correctness, stats plumbing, that compression happened) while dropping the one that pinned correctness to one specific encoder's byte-level output.

Why a standalone PR

Split out of #5959 (route MRZlib through zlib-ng). The zlib-ng PR needs this relaxation to pass, but the relaxation itself is orthogonal — anyone benchmarking libdeflate, zlib-ng-compat, etc. wants the same change. Landing it first keeps #5959 focused on the compressor routing and avoids a test-assertion change bundled into an ABI / CI PR.

Scope

One file: source/MRTest/MRZlibTests.cpp. No source/build/CI changes.

🤖 Generated with Claude Code

The test currently compares `stats.compressedSize` and `out.str().size()`
against `sizeof( cRawLevel* )` / `sizeof( cWrappedLevel* )`. Those
reference blobs were captured from stock zlib, and the exact compressed
byte count drifts from one deflate implementation to another (stock zlib
vs zlib-ng compat vs zlib-ng native vs libdeflate -- all lossless, but
each picks its own block-split / Huffman / match-length heuristics).
Once we swap any part of the compress path to a non-zlib engine, this
assertion fails for reasons that have nothing to do with correctness.

Replace with engine-agnostic assertions:
- CRC matches the reference CRC of the input (decoder-defined, engine-
  independent).
- Uncompressed size matches the input size (tautology that still guards
  against stats wiring regressions).
- `stats.compressedSize == out.str().size()` -- API consistency between
  the stats block and the actual stream, regardless of engine.
- `0 < stats.compressedSize < sizeof( cInput )` -- sanity: we produced a
  non-empty payload smaller than the input.

Split out of #5959 so the test relaxation can land independently of the
zlib-ng routing. Pure test change -- no source / build / CI impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Fedr Fedr requested a review from Grantim April 24, 2026 13:20
@Fedr Fedr merged commit 9df425b into master Apr 24, 2026
28 checks passed
@Fedr Fedr deleted the test/zlib-stats-engine-agnostic branch April 24, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants