maint: initialize MAINTAINERCLEANFILES
[gzip.git] / tests / reference
blobfa605ed63db7e05320e69a5873612257fed91849
1 #!/bin/sh
2 # Ensure that reference compressed files are still decompressible, and
3 # that their corresponding inputs still compress to precisely the same bytes.
4 # For a "normal" compression program, one must not require that the encoded
5 # bytes remain the same. The compression algorithm may change. What normally
6 # matters is solely that the decompressed result is the same as the input
7 # to the compressor. However, here, with gzip's current moribund state,
8 # it is fine to require that. In particular, this test ensures that
9 # a CRC-perf change doesn't accidentally cause trouble. It's not enough
10 # that gzip decompress files the compressor has just created: it must
11 # continue to decompress old compressed outputs, too.
13 # Copyright 2024 Free Software Foundation, Inc.
15 # This program is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation, either version 3 of the License, or
18 # (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program. If not, see <https://www.gnu.org/licenses/>.
27 # limit so don't run it by default.
29 . "${srcdir=.}/init.sh"; path_prepend_ ..
31 fail=0
33 cat <<EOF > exp || framework_failure_
34 : 1f 8b 08 00 00 00 00 00 00 03 03 00 00 00 00 00 00 00 00 00
35 a: 1f 8b 08 00 00 00 00 00 00 03 4b 04 00 43 be b7 e8 01 00 00 00
36 b: 1f 8b 08 00 00 00 00 00 00 03 4b 02 00 f9 ef be 71 01 00 00 00
37 c: 1f 8b 08 00 00 00 00 00 00 03 4b 06 00 6f df b9 06 01 00 00 00
38 yyy: 1f 8b 08 00 00 00 00 00 00 03 ab ac ac 04 00 ea 81 45 73 03 00 00 00
39 zzzzzzzzzzz: 1f 8b 08 00 00 00 00 00 00 03 ab aa 82 03 00 55 97 5b a7 0b 00 00 00
40 EOF
42 # Ensure that compressing these simple strings always produces the same bytes.
43 # If using "od" is not portable enough, consider using this:
44 # perl -ne 'printf "%02x ", ord($_) for split //'
45 for i in '' a b c yyy zzzzzzzzzzz; do
46 echo $i: $(printf %s "$i" | gzip | od -An -tx1 | tr -d '\n')
47 done > out || framework_failure_
49 compare exp out || fail=1
51 # Each output stream must inflate the original input.
52 for i in '' a b c yyy zzzzzzzzzzz; do
53 in=$(printf %s "$i" | gzip | gzip -d)
54 test "$i" = "$in" || fail=1
55 done
57 Exit $fail