gzip/tests/unzip-valid
2026-01-02 17:10:47 -08:00

62 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
# Test reading of PKZIP data descriptors.
# Copyright 2025-2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# limit so don't run it by default.
. "${srcdir=.}/init.sh"; path_prepend_ ..
printf '%s\n' \
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'\
' Quisque tempor suscipit quam.'\
' Aenean est lorem, luctus commodo massa quis, egestas molestie nisl.'\
' Maecenas ac erat tempor, malesuada dolor ut, ultricies diam.'\
' Suspendisse eget augue eget neque consectetur pellentesque sed sed massa.'\
' In hac habitasse platea dictumst.' >exp || framework_failure_
hex_printf_ \
'\x50\x4b\x03\x04\x2d\x00\x08\x00\x08\x00\x6e\x63\xcf\x5a\x00\x00'\
'\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x05\x00\x1d\x00\x6c\x6f'\
'\x72\x65\x6d\x01\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\
'\x00\x00\x00\x00\x00\x00\x00\x55\x54\x05\x00\x01\xa0\x1e\x4f\x68'\
'\x4d\x8f\x4d\x6a\xc5\x40\x0c\x83\xf7\x3d\x85\x0e\x10\x72\x87\x2e'\
'\x0b\xed\xa2\xf4\x04\xee\x8c\xc8\x33\xcc\xdf\x8b\xed\xfb\xd7\x09'\
'\x6f\xd1\xc5\x80\x19\x4b\xd6\xa7\xcf\x79\xb2\x43\x97\x45\x47\x9d'\
'\x6d\x9e\x30\x75\x48\xa7\x6f\x28\x73\x18\x8b\xd3\xe3\x84\x54\x5d'\
'\x6a\x45\xc7\x01\x36\xf5\x1d\xdf\xa1\xf6\x0c\xc2\xd9\xd7\xe5\x8a'\
'\x5c\xae\xb4\x3e\x43\xfa\x8e\x77\x0e\xca\x00\xcd\xd1\xae\x84\x0d'\
'\x2d\x8a\x87\xe5\xcd\xde\x67\x9d\xe8\x62\x26\x29\x56\xdb\xc0\x23'\
'\x75\x62\xe8\xb3\xe5\xa0\xc4\x50\x6b\x3b\xbe\x84\x85\x23\xff\xa5'\
'\x80\xa7\xf8\x2b\x6a\x4b\x6f\xea\x42\xaa\xbc\x88\x23\x59\xa3\xf9'\
'\xa9\x45\x69\xa8\x7a\x01\xfc\x84\x2d\x8e\xaa\x66\xbc\xee\x67\xa5'\
'\x38\xe2\x35\x0e\x5e\xe0\xff\xdb\x2d\xb6\xc6\xe1\xbc\x1b\x19\xeb'\
'\xfd\x6e\xc4\x1d\x1f\x03\x8f\x24\x78\xc8\xaf\x26\x64\x9e\x5b\x4d'\
'\x9c\x99\xad\x59\xa8\x9b\xef\x6f\x7f\x50\x4b\x07\x08\x1e\xf0\xbc'\
'\x58\xc9\x00\x00\x00\x00\x00\x00\x00\x44\x01\x00\x00\x00\x00\x00'\
'\x00\x50\x4b\x01\x02\x2d\xff\x2d\x00\x08\x00\x08\x00\x6e\x63\xcf'\
'\x5a\x1e\xf0\xbc\x58\xc9\x00\x00\x00\x44\x01\x00\x00\x05\x00\x09'\
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6c'\
'\x6f\x72\x65\x6d\x55\x54\x05\x00\x01\xa0\x1e\x4f\x68\x50\x4b\x05'\
'\x06\x00\x00\x00\x00\x01\x00\x01\x00\x3c\x00\x00\x00\x21\x01\x00'\
'\x00\x00\x00' > test.gz || framework_failure_
fail=0
gzip -dc test.gz > out 2> err || fail=1
compare exp out || fail=1
compare /dev/null err || fail=1
Exit $fail