append02.at 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright (C) 2006, 2007 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. # Using tar 1.15.x the following equivalent command sets:
  17. #
  18. # 1. tar cf archive file1 file2
  19. # and
  20. # 2. tar cfT archive /dev/null
  21. # tar rf archive file1
  22. # tar rt archive file2
  23. #
  24. # produced different archives (GNU format is assumed). Namely, in the
  25. # second case the mode field of all members, except the first, was truncated
  26. # to lower 3 octets (& 0777).
  27. #
  28. # References:
  29. # <[email protected]>
  30. # http://lists.gnu.org/archive/html/bug-tar/2006-07/msg00029.html
  31. # The test case below verifies that the equivalent create and append commands
  32. # produce binary equivalent archives for all formats.
  33. AT_SETUP([append vs. create])
  34. AT_KEYWORDS([append append02 append-gnu])
  35. AT_TAR_CHECK([
  36. genfile --file file1
  37. genfile --file file2
  38. # Make sure file timestamps in the archive will not differ
  39. MTIME="--mtime=@0"
  40. # For PAX archives, we need to make sure extended header names are
  41. # reproducible and that their contents won't change with time
  42. if test $[]TEST_TAR_FORMAT = posix; then
  43. TAR_OPTIONS="$TAR_OPTIONS --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=mtime,delete=atime,delete=ctime"
  44. fi
  45. echo Creating archive.1
  46. tar $MTIME -cf archive.1 file1 file2
  47. echo Creating archive.2
  48. tar $MTIME -cf archive.2 -T /dev/null
  49. tar $MTIME -rf archive.2 file1
  50. tar $MTIME -rf archive.2 file2
  51. echo Comparing archives
  52. cmp archive.1 archive.2
  53. ],
  54. [0],
  55. [Creating archive.1
  56. Creating archive.2
  57. Comparing archives
  58. ])
  59. AT_CLEANUP
  60. # End of append02.at