listed02.at 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2004-2007, 2009, 2013-2014, 2016-2017 Free Software
  4. # Foundation, 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. # Check if listed-incremental backups work for files moved from one directory
  17. # to another.
  18. # Based on a script by Martin Simmons <ZYHYLCRMZPRP@spammotel.com>
  19. # References:
  20. # <20040626230315.163AA1D148@cpc5-cmbg1-6-0-cust208.cmbg.cable.ntl.com>
  21. # http://lists.gnu.org/archive/html/bug-tar/2004-06/msg00028.html
  22. AT_SETUP([working --listed])
  23. AT_KEYWORDS([listed incremental listed02])
  24. AT_TAR_CHECK([
  25. AT_CHECK_TIMESTAMP
  26. AT_SORT_PREREQ
  27. echo Create directories
  28. mkdir tart
  29. sleep 1
  30. mkdir tart/c0
  31. sleep 1
  32. mkdir tart/c1
  33. sleep 1
  34. for file in tart/a1 tart/b1 tart/c0/cq1 tart/c0/cq2 tart/c1/ca1 tart/c1/ca2
  35. do
  36. echo File $file > $file
  37. sleep 1
  38. done
  39. sleep 1
  40. echo Creating main archive
  41. echo >&2 "Creating main archive"
  42. tar -c -v --listed-incremental=tart.incr1 -f archive.1 tart 2> err || exit 1
  43. # The above prints two lines to stderr announcing the new directories c0 and c1.
  44. # Ensure that they appear in this script's stderr in sorted order.
  45. sort err 1>&2; rm -f err
  46. sleep 1
  47. echo Modifying filesystem
  48. rm tart/a1
  49. mv tart/b1 tart/b2
  50. mv tart/c1 tart/c2
  51. touch tart/c2/ca3
  52. echo Directory contents
  53. find tart -print | sort 2>/dev/null
  54. sleep 1
  55. echo Creating incremental archive
  56. echo >&2 "Creating incremental archive"
  57. cp -p tart.incr1 tart.incr2
  58. tar -c -v --listed-incremental=tart.incr2 -f archive.2 tart || exit 1
  59. sleep 1
  60. rm -rf tart/*
  61. echo Extracting main archive
  62. echo >&2 "Extracting main archive"
  63. tar -x -v --listed-incremental=tart.incr1 -f archive.1 || exit 1
  64. echo Extracting incremental archive
  65. # This command should produce three messages about deletion
  66. # of the existing files, that may appear in any order. Piping
  67. # to sort makes sure we don't depend on any particular ordering.
  68. tar -x -v --listed-incremental=tart.incr2 -f archive.2 | sort 2>/dev/null
  69. echo Final files:
  70. find tart -print | sort 2>/dev/null
  71. ],
  72. [0],
  73. [Create directories
  74. Creating main archive
  75. tart/
  76. tart/c0/
  77. tart/c1/
  78. tart/a1
  79. tart/b1
  80. tart/c0/cq1
  81. tart/c0/cq2
  82. tart/c1/ca1
  83. tart/c1/ca2
  84. Modifying filesystem
  85. Directory contents
  86. tart
  87. tart/b2
  88. tart/c0
  89. tart/c0/cq1
  90. tart/c0/cq2
  91. tart/c2
  92. tart/c2/ca1
  93. tart/c2/ca2
  94. tart/c2/ca3
  95. Creating incremental archive
  96. tart/
  97. tart/c0/
  98. tart/c2/
  99. tart/b2
  100. tart/c2/ca3
  101. Extracting main archive
  102. tart/
  103. tart/c0/
  104. tart/c1/
  105. tart/a1
  106. tart/b1
  107. tart/c0/cq1
  108. tart/c0/cq2
  109. tart/c1/ca1
  110. tart/c1/ca2
  111. Extracting incremental archive
  112. tar: Deleting 'tart/a1'
  113. tar: Deleting 'tart/b1'
  114. tart/
  115. tart/b2
  116. tart/c0/
  117. tart/c2/
  118. tart/c2/ca3
  119. Final files:
  120. tart
  121. tart/b2
  122. tart/c0
  123. tart/c0/cq1
  124. tart/c0/cq2
  125. tart/c2
  126. tart/c2/ca1
  127. tart/c2/ca2
  128. tart/c2/ca3
  129. ],
  130. [Creating main archive
  131. tar: tart/c0: Directory is new
  132. tar: tart/c1: Directory is new
  133. tar: tart: Directory is new
  134. Creating incremental archive
  135. tar: tart/c2: Directory has been renamed from 'tart/c1'
  136. Extracting main archive
  137. ],
  138. [],[],[gnu, oldgnu])
  139. AT_CLEANUP