4
0

incr02.at 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2005, 2007, 2013-2014 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. # Create directory structure
  29. mkdir dir
  30. mkdir dir/subdir1
  31. mkdir dir/subdir2
  32. genfile --length 10 --file dir/subdir1/file
  33. # Save mtime for later comparison
  34. genfile --stat=mtime dir/subdir1 > ts
  35. # Create an archive. Using incremental mode makes sure the
  36. # archive will have a directory-first member ordering,
  37. # i.e.:
  38. # dir/
  39. # dir/subdir1/
  40. # dir/subdir2/
  41. # dir/subdir1/foofile
  42. #
  43. # When restoring from this directory structure, 'dir/subdir2/' used to
  44. # trigger apply_nonancestor_delayed_set_stat() which restored stats for
  45. # 'subdir1' prior to restoring 'dir/subdir1/foofile'. Then, restoring the
  46. # latter clobbered the directory timestamp.
  47. tar -cf archive -g db dir
  48. # Move away the directory
  49. mv dir orig
  50. # Wait enough time for timestamps to differ in case of failure.
  51. sleep 5
  52. # Restore the directory
  53. tar -xf archive dir
  54. # Check the timestamp
  55. genfile --stat=mtime dir/subdir1 | diff ts -
  56. ],
  57. [0],
  58. [],[],[],[],[gnu, oldgnu, posix])
  59. AT_CLEANUP
  60. # End of incr02.at