Skip to content

BUG: Compare NIfTI test output by content, not by compressed bytes - #96

Merged
hjmjohnson merged 1 commit into
masterfrom
pr/test-gz-content-compare
Nov 9, 2026
Merged

hjmjohnson merged 1 commit into
masterfrom
pr/test-gz-content-compare

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

nifti_c22_copy_image compared gzip bytes, which differ between zlib and zlib-ng 1.3.1; it now compares decompressed content. The i16 -> f32 -> i16 comparison now fails the test on a mismatch instead of only printing a message.

Re-submission of #31, reverted from master on 2026-09-24 so it can be reviewed before merging. Base: master. Independent: nothing has to land before it. Ordering for all the re-submitted work is tracked in #84.

Changes since the original #31
  • The second (f32) round-trip comparison now exits 1 on a mismatch, as the first one does. It still passes.
  • nii_cmp removes its temporary .raw files when decompression fails, too.
  • Failure messages read "decompressed content differs" instead of "not a binary match".
  • Commit message: dropped the cherry-pick line and named zlib-ng 1.3.1 as the platform.
Test evidence
  • Full suite (CIFTI and shell-script tests on, macOS): 344 of 344 passed.
  • Red: appending one extra gzip member to out.c22.2.1.i16.nii.gz makes the test fail ("decompressed content differs"). A truncated gzip file also fails it and leaves no .raw files behind.

@hjmjohnson
hjmjohnson marked this pull request as ready for review September 24, 2026 12:17
@hjmjohnson
hjmjohnson force-pushed the pr/test-gz-content-compare branch from 07c38b2 to 0f3a71d Compare October 6, 2026 14:35
@hjmjohnson
hjmjohnson force-pushed the pr/test-gz-content-compare branch 2 times, most recently from 56d537f to 05b9f9d Compare November 2, 2026 20:37
nifti_c22_copy_image fails on systems whose zlib is zlib-ng 1.3.1. It
converts an image i16 -> i64 -> i16 and asserts the result matches the
original, using

    cmp out.c22.0.i16.nii.gz out.c22.2.0.i16.nii.gz

That compares gzip output, which is not reproducible across zlib
implementations. zlib-ng, which Arch, CachyOS, and a growing number of
distributions ship in place of stock zlib, encodes the same input
differently. Both files come out at exactly 642454 bytes and differ from
byte 321594 on.

The conversion itself is fine. Decompressed, the two files are
byte-identical at 1114768 bytes each, so the round-trip through int64
and back preserves the data exactly, which is what the test set out to
check. Confirmed the other way too: in an Ubuntu 24.04 container with
stock zlib 1.3, the test passes unmodified.

The test now decompresses before comparing, via a small nii_cmp helper
that falls back to plain cmp for uncompressed files. The i16 -> f32 ->
i16 comparison now also fails the test on a mismatch; it only printed a
message before. With this the suite is 92 of 92 on both zlib-ng and
stock zlib; previously it was 91 of 92 on any zlib-ng system.
@hjmjohnson
hjmjohnson force-pushed the pr/test-gz-content-compare branch from 05b9f9d to 09adee5 Compare November 6, 2026 15:10
@hjmjohnson

Copy link
Copy Markdown
Member Author

@greptileai review

@hjmjohnson
hjmjohnson merged commit 50a9216 into master Nov 9, 2026
8 checks passed
@hjmjohnson
hjmjohnson deleted the pr/test-gz-content-compare branch November 9, 2026 14:24
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.

3 participants