listed02.at 3.5 KB

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