remfiles01.at 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: <77cb99c00910020940k6ce15da4wb564d2418ec52cfb@mail.gmail.com>
  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_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