remfiles01.at 2.1 KB

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