listed02.at 3.5 KB

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