#!/bin/bash # The first group of sizes covers the range around where the terminating CRLFCRLF gets truncated. # The second group covers the range around the internal buffer size. for s in {1048470..1048490} {1048570..1048580}; do for meta in '' '--meta'; do expectedHash="$({ if [[ "${meta}" ]]; then printf 'https://example.org/ %d\n' "$s"; fi; yes | tr -d '\n' | head -c "$s"; printf '\n'; } | sha1sum)" actualHash="$( { printf '%s\r\n' 'WARC/1.0' 'Content-Length: '"$s" 'WARC-Type: response' 'WARC-Target-URI: https://example.org/' '' yes | tr -d '\n' | head -c "$s" printf '\r\n\r\n' } | "$(dirname "$0")"/warc-dump-responses ${meta} | sha1sum )" if [[ "${expectedHash}" != "${actualHash}" ]]; then printf 'Error: output mismatch on size %q, meta %q\n' "${s}" "${meta}" printf 'Expected hash: %q\n' "${expectedHash}" printf 'Actual hash: %q\n' "${actualHash}" exit 1 fi done done