1*3117ece4Schristos#!/bin/sh 2*3117ece4Schristos# Ensure that gzip -cdf handles mixed compressed/not-compressed data 3*3117ece4Schristos# Before gzip-1.5, it would produce invalid output. 4*3117ece4Schristos 5*3117ece4Schristos# Copyright (C) 2010-2016 Free Software Foundation, Inc. 6*3117ece4Schristos 7*3117ece4Schristos# This program is free software: you can redistribute it and/or modify 8*3117ece4Schristos# it under the terms of the GNU General Public License as published by 9*3117ece4Schristos# the Free Software Foundation, either version 3 of the License, or 10*3117ece4Schristos# (at your option) any later version. 11*3117ece4Schristos 12*3117ece4Schristos# This program is distributed in the hope that it will be useful, 13*3117ece4Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*3117ece4Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*3117ece4Schristos# GNU General Public License for more details. 16*3117ece4Schristos 17*3117ece4Schristos# You should have received a copy of the GNU General Public License 18*3117ece4Schristos# along with this program. If not, see <https://www.gnu.org/licenses/>. 19*3117ece4Schristos# limit so don't run it by default. 20*3117ece4Schristos 21*3117ece4Schristos. "${srcdir=.}/init.sh"; path_prepend_ . 22*3117ece4Schristos 23*3117ece4Schristosprintf 'xxx\nyyy\n' > exp2 || framework_failure_ 24*3117ece4Schristosprintf 'aaa\nbbb\nccc\n' > exp3 || framework_failure_ 25*3117ece4Schristos 26*3117ece4Schristosfail=0 27*3117ece4Schristos 28*3117ece4Schristos(echo xxx; echo yyy) > in || fail=1 29*3117ece4Schristosgzip -cdf < in > out || fail=1 30*3117ece4Schristoscompare exp2 out || fail=1 31*3117ece4Schristos 32*3117ece4Schristos# Uncompressed input, followed by compressed data. 33*3117ece4Schristos# Currently fails, so skip it. 34*3117ece4Schristos# (echo xxx; echo yyy|gzip) > in || fail=1 35*3117ece4Schristos# gzip -cdf < in > out || fail=1 36*3117ece4Schristos# compare exp2 out || fail=1 37*3117ece4Schristos 38*3117ece4Schristos# Compressed input, followed by regular (not-compressed) data. 39*3117ece4Schristos(echo xxx|gzip; echo yyy) > in || fail=1 40*3117ece4Schristosgzip -cdf < in > out || fail=1 41*3117ece4Schristoscompare exp2 out || fail=1 42*3117ece4Schristos 43*3117ece4Schristos(echo xxx|gzip; echo yyy|gzip) > in || fail=1 44*3117ece4Schristosgzip -cdf < in > out || fail=1 45*3117ece4Schristoscompare exp2 out || fail=1 46*3117ece4Schristos 47*3117ece4Schristosin_str=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+=% 48*3117ece4Schristosfor i in 0 1 2 3 4 5 6 7 8 9 a; do in_str="$in_str$in_str" ;done 49*3117ece4Schristos 50*3117ece4Schristos# Start with some small sizes. $(seq 64) 51*3117ece4Schristossizes=$(i=0; while :; do echo $i; test $i = 64 && break; i=$(expr $i + 1); done) 52*3117ece4Schristos 53*3117ece4Schristos# gzip's internal buffer size is 32KiB + 64 bytes: 54*3117ece4Schristossizes="$sizes 32831 32832 32833" 55*3117ece4Schristos 56*3117ece4Schristos# 128KiB, +/- 1 57*3117ece4Schristossizes="$sizes 131071 131072 131073" 58*3117ece4Schristos 59*3117ece4Schristos# Ensure that "gzip -cdf" acts like cat, for a range of small input files. 60*3117ece4Schristosi=0 61*3117ece4Schristosfor i in $sizes; do 62*3117ece4Schristos echo $i 63*3117ece4Schristos printf %$i.${i}s $in_str > in 64*3117ece4Schristos gzip -cdf < in > out 65*3117ece4Schristos compare in out || fail=1 66*3117ece4Schristosdone 67*3117ece4Schristos 68*3117ece4SchristosExit $fail 69