keep.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. # Exercise the --keep option.
  3. # Copyright (C) 2013-2016 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. # limit so don't run it by default.
  15. . "${srcdir=.}/init.sh"; path_prepend_ .
  16. echo fooooooooo > in || framework_failure_
  17. cp in orig || framework_failure_
  18. fail=0
  19. # Compress and decompress both with and without --keep.
  20. for k in --keep ''; do
  21. # With --keep, the source must be retained, otherwise, it must be removed.
  22. case $k in --keep) op='||' ;; *) op='&&' ;; esac
  23. gzip $k in || fail=1
  24. eval "test -f in $op fail=1"
  25. test -f in.gz || fail=1
  26. rm -f in || fail=1
  27. gzip -d $k in.gz || fail=1
  28. eval "test -f in.gz $op fail=1"
  29. test -f in || fail=1
  30. compare in orig || fail=1
  31. rm -f in.gz || fail=1
  32. done
  33. cp orig in || framework_failure_
  34. log=$(gzip -kv in 2>&1) || fail=1
  35. case $log in
  36. *'created in.gz'*) ;;
  37. *) fail=1;;
  38. esac
  39. Exit $fail