summaryrefslogtreecommitdiff
path: root/tests/listed02.at
blob: 153644ba574d49d66f84ab9361341b863cd686fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Process this file with autom4te to create testsuite. -*- Autotest -*-

# Test suite for GNU tar.
# Copyright 2004-2007, 2009, 2013-2014, 2016 Free Software Foundation,
# Inc.

# This file is part of GNU tar.

# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Check if listed-incremental backups work for files moved from one directory
# to another.
# Based on a script by Martin Simmons <ZYHYLCRMZPRP@spammotel.com>
# References:
#  <20040626230315.163AA1D148@cpc5-cmbg1-6-0-cust208.cmbg.cable.ntl.com>
#  http://lists.gnu.org/archive/html/bug-tar/2004-06/msg00028.html

AT_SETUP([working --listed])
AT_KEYWORDS([listed incremental listed02])

AT_TAR_CHECK([
AT_CHECK_TIMESTAMP
AT_SORT_PREREQ
echo Create directories

mkdir tart
sleep 1
mkdir tart/c0
sleep 1
mkdir tart/c1
sleep 1

for file in tart/a1 tart/b1 tart/c0/cq1 tart/c0/cq2 tart/c1/ca1 tart/c1/ca2
do
  echo File $file > $file
  sleep 1
done

sleep 1
echo Creating main archive
echo >&2 "Creating main archive"
tar -c -v --listed-incremental=tart.incr1 -f archive.1 tart 2> err || exit 1

# The above prints two lines to stderr announcing the new directories c0 and c1.
# Ensure that they appear in this script's stderr in sorted order.
sort err 1>&2; rm -f err

sleep 1
echo Modifying filesystem
rm tart/a1

mv tart/b1 tart/b2
mv tart/c1 tart/c2
touch tart/c2/ca3

echo Directory contents
find tart -print | sort 2>/dev/null

sleep 1
echo Creating incremental archive
echo >&2 "Creating incremental archive"
cp -p tart.incr1 tart.incr2
tar -c -v --listed-incremental=tart.incr2 -f archive.2 tart || exit 1

sleep 1

rm -rf tart/*
echo Extracting main archive
echo >&2 "Extracting main archive"
tar -x -v --listed-incremental=tart.incr1 -f archive.1 || exit 1
echo Extracting incremental archive
# This command should produce three messages about deletion
# of the existing files, that may appear in any order. Piping
# to sort makes sure we don't depend on any particular ordering.
tar -x -v --listed-incremental=tart.incr2 -f archive.2 | sort 2>/dev/null

echo Final files:
find tart -print | sort 2>/dev/null
],
[0],
[Create directories
Creating main archive
tart/
tart/c0/
tart/c1/
tart/a1
tart/b1
tart/c0/cq1
tart/c0/cq2
tart/c1/ca1
tart/c1/ca2
Modifying filesystem
Directory contents
tart
tart/b2
tart/c0
tart/c0/cq1
tart/c0/cq2
tart/c2
tart/c2/ca1
tart/c2/ca2
tart/c2/ca3
Creating incremental archive
tart/
tart/c0/
tart/c2/
tart/b2
tart/c2/ca3
Extracting main archive
tart/
tart/c0/
tart/c1/
tart/a1
tart/b1
tart/c0/cq1
tart/c0/cq2
tart/c1/ca1
tart/c1/ca2
Extracting incremental archive
tar: Deleting 'tart/a1'
tar: Deleting 'tart/b1'
tart/
tart/b2
tart/c0/
tart/c2/
tart/c2/ca3
Final files:
tart
tart/b2
tart/c0
tart/c0/cq1
tart/c0/cq2
tart/c2
tart/c2/ca1
tart/c2/ca2
tart/c2/ca3
],
[Creating main archive
tar: tart/c0: Directory is new
tar: tart/c1: Directory is new
tar: tart: Directory is new
Creating incremental archive
tar: tart/c2: Directory has been renamed from 'tart/c1'
Extracting main archive
],
[],[],[gnu, oldgnu])

AT_CLEANUP