incr02.at 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2005, 2007, 2013-2014, 2016-2017 Free Software Foundation,
  4. # Inc.
  5. # This file is part of GNU tar.
  6. # GNU tar is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. # GNU tar is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Description:
  17. # Restoring of directory modes and timestamps works correctly only
  18. # if the archive has normal member ordering, i.e. each directory
  19. # member is immediately followed by members located under that directory.
  20. # This is not true for incremental archives, where directory members
  21. # precede the non-directory ones. Due to this, GNU tar up to version 1.15.2
  22. # failed to correctly restore directory timestamps from an incremental
  23. # archive if this directory contained some files in it.
  24. #
  25. # References: <200511291228.47081.karaman@dssgmbh.de>
  26. AT_SETUP([restoring timestamps from incremental])
  27. AT_KEYWORDS([incremental timestamp restore incr02])
  28. AT_TAR_CHECK([
  29. AT_CHECK_TIMESTAMP
  30. # Create directory structure
  31. mkdir dir
  32. mkdir dir/subdir1
  33. mkdir dir/subdir2
  34. genfile --length 10 --file dir/subdir1/file
  35. # Save mtime for later comparison
  36. genfile --stat=mtime dir/subdir1 > ts
  37. # Create an archive. Using incremental mode makes sure the
  38. # archive will have a directory-first member ordering,
  39. # i.e.:
  40. # dir/
  41. # dir/subdir1/
  42. # dir/subdir2/
  43. # dir/subdir1/foofile
  44. #
  45. # When restoring from this directory structure, 'dir/subdir2/' used to
  46. # trigger apply_nonancestor_delayed_set_stat() which restored stats for
  47. # 'subdir1' prior to restoring 'dir/subdir1/foofile'. Then, restoring the
  48. # latter clobbered the directory timestamp.
  49. tar -cf archive -g db dir
  50. # Move away the directory
  51. mv dir orig
  52. # Wait enough time for timestamps to differ in case of failure.
  53. sleep 5
  54. # Restore the directory
  55. tar -xf archive dir
  56. # Check the timestamp
  57. genfile --stat=mtime dir/subdir1 | diff ts -
  58. ],
  59. [0],
  60. [],[],[],[],[gnu, oldgnu, posix])
  61. AT_CLEANUP
  62. # End of incr02.at