| 1 |
# Process this file with autom4te to create testsuite. -*- Autotest -*- |
| 2 |
|
| 3 |
# Test suite for GNU tar. |
| 4 |
# Copyright 2004-2023 Free Software Foundation, Inc. |
| 5 |
|
| 6 |
# This file is part of GNU tar. |
| 7 |
|
| 8 |
# GNU tar is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 3 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
|
| 13 |
# GNU tar is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
|
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
# Check if listed-incremental backups work for files moved from one directory |
| 22 |
# to another. |
| 23 |
# Based on a script by Martin Simmons <[email protected]> |
| 24 |
# References: |
| 25 |
# <20040626230315.163AA1D148@cpc5-cmbg1-6-0-cust208.cmbg.cable.ntl.com> |
| 26 |
# http://lists.gnu.org/archive/html/bug-tar/2004-06/msg00028.html |
| 27 |
|
| 28 |
AT_SETUP([working --listed]) |
| 29 |
AT_KEYWORDS([listed incremental listed02]) |
| 30 |
|
| 31 |
AT_TAR_CHECK([ |
| 32 |
AT_CHECK_TIMESTAMP |
| 33 |
AT_SORT_PREREQ |
| 34 |
echo Create directories |
| 35 |
|
| 36 |
mkdir tart |
| 37 |
sleep 1 |
| 38 |
mkdir tart/c0 |
| 39 |
sleep 1 |
| 40 |
mkdir tart/c1 |
| 41 |
sleep 1 |
| 42 |
|
| 43 |
for file in tart/a1 tart/b1 tart/c0/cq1 tart/c0/cq2 tart/c1/ca1 tart/c1/ca2 |
| 44 |
do |
| 45 |
echo File $file > $file |
| 46 |
sleep 1 |
| 47 |
done |
| 48 |
|
| 49 |
sleep 1 |
| 50 |
echo Creating main archive |
| 51 |
echo >&2 "Creating main archive" |
| 52 |
tar -c -v --listed-incremental=tart.incr1 -f archive.1 tart 2> err || exit 1 |
| 53 |
|
| 54 |
# The above prints two lines to stderr announcing the new directories c0 and c1. |
| 55 |
# Ensure that they appear in this script's stderr in sorted order. |
| 56 |
sort err 1>&2; rm -f err |
| 57 |
|
| 58 |
sleep 1 |
| 59 |
echo Modifying filesystem |
| 60 |
rm tart/a1 |
| 61 |
|
| 62 |
mv tart/b1 tart/b2 |
| 63 |
mv tart/c1 tart/c2 |
| 64 |
touch tart/c2/ca3 |
| 65 |
|
| 66 |
echo Directory contents |
| 67 |
find tart -print | sort 2>/dev/null |
| 68 |
|
| 69 |
sleep 1 |
| 70 |
echo Creating incremental archive |
| 71 |
echo >&2 "Creating incremental archive" |
| 72 |
cp -p tart.incr1 tart.incr2 |
| 73 |
tar -c -v --listed-incremental=tart.incr2 -f archive.2 tart || exit 1 |
| 74 |
|
| 75 |
sleep 1 |
| 76 |
|
| 77 |
rm -rf tart/* |
| 78 |
echo Extracting main archive |
| 79 |
echo >&2 "Extracting main archive" |
| 80 |
tar -x -v --listed-incremental=tart.incr1 -f archive.1 || exit 1 |
| 81 |
echo Extracting incremental archive |
| 82 |
# This command should produce three messages about deletion |
| 83 |
# of the existing files, that may appear in any order. Piping |
| 84 |
# to sort makes sure we don't depend on any particular ordering. |
| 85 |
tar -x -v --listed-incremental=tart.incr2 -f archive.2 | sort 2>/dev/null |
| 86 |
|
| 87 |
echo Final files: |
| 88 |
find tart -print | sort 2>/dev/null |
| 89 |
], |
| 90 |
[0], |
| 91 |
[Create directories |
| 92 |
Creating main archive |
| 93 |
tart/ |
| 94 |
tart/c0/ |
| 95 |
tart/c1/ |
| 96 |
tart/a1 |
| 97 |
tart/b1 |
| 98 |
tart/c0/cq1 |
| 99 |
tart/c0/cq2 |
| 100 |
tart/c1/ca1 |
| 101 |
tart/c1/ca2 |
| 102 |
Modifying filesystem |
| 103 |
Directory contents |
| 104 |
tart |
| 105 |
tart/b2 |
| 106 |
tart/c0 |
| 107 |
tart/c0/cq1 |
| 108 |
tart/c0/cq2 |
| 109 |
tart/c2 |
| 110 |
tart/c2/ca1 |
| 111 |
tart/c2/ca2 |
| 112 |
tart/c2/ca3 |
| 113 |
Creating incremental archive |
| 114 |
tart/ |
| 115 |
tart/c0/ |
| 116 |
tart/c2/ |
| 117 |
tart/b2 |
| 118 |
tart/c2/ca3 |
| 119 |
Extracting main archive |
| 120 |
tart/ |
| 121 |
tart/c0/ |
| 122 |
tart/c1/ |
| 123 |
tart/a1 |
| 124 |
tart/b1 |
| 125 |
tart/c0/cq1 |
| 126 |
tart/c0/cq2 |
| 127 |
tart/c1/ca1 |
| 128 |
tart/c1/ca2 |
| 129 |
Extracting incremental archive |
| 130 |
tar: Deleting 'tart/a1' |
| 131 |
tar: Deleting 'tart/b1' |
| 132 |
tart/ |
| 133 |
tart/b2 |
| 134 |
tart/c0/ |
| 135 |
tart/c2/ |
| 136 |
tart/c2/ca3 |
| 137 |
Final files: |
| 138 |
tart |
| 139 |
tart/b2 |
| 140 |
tart/c0 |
| 141 |
tart/c0/cq1 |
| 142 |
tart/c0/cq2 |
| 143 |
tart/c2 |
| 144 |
tart/c2/ca1 |
| 145 |
tart/c2/ca2 |
| 146 |
tart/c2/ca3 |
| 147 |
], |
| 148 |
[Creating main archive |
| 149 |
tar: tart/c0: Directory is new |
| 150 |
tar: tart/c1: Directory is new |
| 151 |
tar: tart: Directory is new |
| 152 |
Creating incremental archive |
| 153 |
tar: tart/c2: Directory has been renamed from 'tart/c1' |
| 154 |
Extracting main archive |
| 155 |
], |
| 156 |
[],[],[gnu, oldgnu]) |
| 157 |
|
| 158 |
AT_CLEANUP |