git/t/helper
Jeff King f2ed511a2f t/helper: add zlib test-tool
It's occasionally useful when testing or debugging to be able to do raw
zlib inflate/deflate operations (e.g., to check the bytes of a specific
loose or packed object).

Even though zlib's deflate algorithm is used by many other programs,
this is surprisingly hard to do in a portable way. E.g., gzip can do
this if you manually munge some header bytes. But the result is somewhat
arcane, and we don't assume gzip is available anyway. Likewise, pigz
will handle raw zlib, but we can't assume it is available.

So let's introduce a short test helper for just doing zlib operations.
We'll use it in subsequent patches to add some new tests, but it would
also have come in handy a few times in the past:

  - The hard-coded pack data from 3b910d0c5e (add tests for indexing
    packs with delta cycles, 2013-08-23) could probably be generated on
    the fly.

  - Likewise we could avoid the hard-coded data from 0b1493c2d4
    (git_inflate(): skip zlib_post_call() sanity check on Z_NEED_DICT,
    2025-02-25). Though note this would require support for more zlib
    options.

  - It would have helped with the debugging documented in 41dfbb2dbe
    (howto: add article on recovering a corrupted object, 2013-10-25).

I'll leave refactoring existing tests for another day, but I hope the
examples above show the general utility.

I aimed for simplicity in the code. In particular, it will read all
input into a memory buffer, rather than streaming. That makes the zlib
loops harder to get wrong (which has been a source of subtle bugs in the
past).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-05-16 09:43:11 -07:00
..
.gitignore
meson.build t/helper: add zlib test-tool 2025-05-16 09:43:11 -07:00
test-advise.c
test-bitmap.c
test-bloom.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-bundle-uri.c
test-cache-tree.c
test-chmtime.c
test-config.c
test-crontab.c
test-csprng.c
test-date.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-delete-gpgsig.c
test-delta.c
test-dir-iterator.c refs/iterator: separate lifecycle from iteration 2025-03-12 11:31:18 -07:00
test-drop-caches.c
test-dump-cache-tree.c
test-dump-fsmonitor.c
test-dump-split-index.c
test-dump-untracked-cache.c
test-env-helper.c
test-example-tap.c
test-fake-ssh.c
test-find-pack.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-fsmonitor-client.c
test-genrandom.c
test-genzeros.c
test-getcwd.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-hash-speed.c global: adapt callers to use generic hash context helpers 2025-01-31 10:06:11 -08:00
test-hash.c global: adapt callers to use generic hash context helpers 2025-01-31 10:06:11 -08:00
test-hashmap.c
test-hexdump.c
test-json-writer.c
test-lazy-init-name-hash.c
test-match-trees.c
test-mergesort.c
test-mktemp.c
test-name-hash.c test-tool: add helper for name-hash values 2025-01-27 13:21:43 -08:00
test-online-cpus.c
test-pack-deltas.c test-tool: add pack-deltas helper 2025-04-28 15:37:25 -07:00
test-pack-mtimes.c Merge branch 'az/tighten-string-array-constness' 2025-04-29 14:21:28 -07:00
test-parse-options.c parse-options: introduce precision handling for `OPTION_UNSIGNED` 2025-04-17 08:15:16 -07:00
test-parse-pathspec-file.c
test-partial-clone.c object-store: merge "object-store-ll.h" and "object-store.h" 2025-04-15 08:24:37 -07:00
test-path-utils.c Merge branch 'ps/test-wo-perl-prereq' 2025-04-16 13:54:20 -07:00
test-path-walk.c backfill: add --sparse option 2025-02-03 16:12:42 -08:00
test-pcre2-config.c
test-pkt-line.c
test-proc-receive.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-progress.c
test-reach.c
test-read-cache.c
test-read-graph.c object-store: merge "object-store-ll.h" and "object-store.h" 2025-04-15 08:24:37 -07:00
test-read-midx.c object-store: merge "object-store-ll.h" and "object-store.h" 2025-04-15 08:24:37 -07:00
test-ref-store.c object-store: merge "object-store-ll.h" and "object-store.h" 2025-04-15 08:24:37 -07:00
test-reftable.c reftable/table: move printing logic into test helper 2025-04-07 14:53:13 -07:00
test-regex.c
test-repository.c
test-revision-walking.c
test-rot13-filter.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-run-command.c
test-scrap-cache-tree.c
test-serve-v2.c
test-sha1.c t/helper/test-tool: implement sha1-unsafe helper 2025-01-23 10:28:16 -08:00
test-sha1.sh t: refactor tests depending on Perl transliteration operator 2025-04-07 14:47:38 -07:00
test-sha256.c t/helper/test-tool: implement sha1-unsafe helper 2025-01-23 10:28:16 -08:00
test-sigchain.c
test-simple-ipc.c
test-string-list.c
test-submodule-config.c
test-submodule-nested-repo-config.c hash: stop depending on `the_repository` in `null_oid()` 2025-03-10 13:16:20 -07:00
test-submodule.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-subprocess.c
test-tool-utils.h
test-tool.c t/helper: add zlib test-tool 2025-05-16 09:43:11 -07:00
test-tool.h t/helper: add zlib test-tool 2025-05-16 09:43:11 -07:00
test-trace2.c
test-truncate.c
test-userdiff.c
test-wildmatch.c
test-windows-named-pipe.c global: mark usage strings and string tables const 2025-04-21 21:01:19 -07:00
test-write-cache.c
test-xml-encode.c
test-zlib.c t/helper: add zlib test-tool 2025-05-16 09:43:11 -07:00