incr02.at 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2005-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:
  16. # Restoring of directory modes and timestamps works correctly only
  17. # if the archive has normal member ordering, i.e. each directory
  18. # member is immediately followed by members located under that directory.
  19. # This is not true for incremental archives, where directory members
  20. # precede the non-directory ones. Due to this, GNU tar up to version 1.15.2
  21. # failed to correctly restore directory timestamps from an incremental
  22. # archive if this directory contained some files in it.
  23. #
  24. # References: <[email protected]>
  25. AT_SETUP([restoring timestamps from incremental])
  26. AT_KEYWORDS([incremental timestamp restore incr02])
  27. AT_TAR_CHECK([
  28. AT_CHECK_TIMESTAMP
  29. # Create directory structure
  30. mkdir dir
  31. mkdir dir/subdir1
  32. mkdir dir/subdir2
  33. genfile --length 10 --file dir/subdir1/file
  34. # Save mtime for later comparison
  35. genfile --stat=mtime dir/subdir1 > ts
  36. # Create an archive. Using incremental mode makes sure the
  37. # archive will have a directory-first member ordering,
  38. # i.e.:
  39. # dir/
  40. # dir/subdir1/
  41. # dir/subdir2/
  42. # dir/subdir1/foofile
  43. #
  44. # When restoring from this directory structure, 'dir/subdir2/' used to
  45. # trigger apply_nonancestor_delayed_set_stat() which restored stats for
  46. # 'subdir1' prior to restoring 'dir/subdir1/foofile'. Then, restoring the
  47. # latter clobbered the directory timestamp.
  48. tar -cf archive -g db dir
  49. # Move away the directory
  50. mv dir orig
  51. # Wait enough time for timestamps to differ in case of failure.
  52. sleep 5
  53. # Restore the directory
  54. tar -xf archive dir
  55. # Check the timestamp
  56. genfile --stat=mtime dir/subdir1 | diff ts -
  57. ],
  58. [0],
  59. [],[],[],[],[gnu, oldgnu, posix])
  60. AT_CLEANUP
  61. # End of incr02.at