2
0

mixed.sh 2.1 KB

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