remfiles01.at 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2009-2023 Free Software Foundation, Inc.
  4. # This file is part of GNU tar.
  5. # GNU tar 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. # GNU tar 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. # Description: When called with --create --remove-files and a compression
  16. # options tar (v. <= 1.22.90) would remove files even if it had failed
  17. # to store them in the archive.
  18. #
  19. # References: <[email protected]>
  20. # http://lists.gnu.org/archive/html/bug-tar/2009-10/msg00005.html
  21. AT_SETUP([remove-files with compression])
  22. AT_KEYWORDS([create remove-files remfiles01 gzip])
  23. unset TAR_OPTIONS
  24. AT_CHECK([
  25. AT_UNPRIVILEGED_PREREQ
  26. AT_GZIP_PREREQ
  27. AT_SIGPIPE_PREREQ
  28. AT_SORT_PREREQ
  29. mkdir dir
  30. cd dir
  31. genfile --file a --length 0
  32. chmod 0 a
  33. genfile --file b
  34. mkdir c
  35. # Depending on when the SIGPIPE gets delivered, the invocation below
  36. # may finish with either
  37. # tar: a: Cannot write: Broken pipe
  38. # or
  39. # tar: Child returned status 2
  40. # Discard diagnostics that some shells generate about broken pipes,
  41. # and discard all of tar's diagnostics except for the ones saying "(child)".
  42. # Gzip's exit code is propagated to the shell. Usually it is 141.
  43. # Convert all non-zero exits to 2 to make it predictable.
  44. (tar -c -f a -z --remove-files b c 2>err || (exit 2) ) 2>/dev/null
  45. EC=$?
  46. sed -n '/(child)/p' err >&2
  47. rm err
  48. find . | sort
  49. exit $EC
  50. ],
  51. [2],
  52. [.
  53. ./a
  54. ./b
  55. ./c
  56. ],
  57. [tar (child): a: Cannot open: Permission denied
  58. tar (child): Error is not recoverable: exiting now
  59. ])
  60. AT_CLEANUP