summaryrefslogtreecommitdiff
path: root/tests/incr08.at
blob: e74be3d54cb8fbe09822876b01b28ad4ce9195fe (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
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2013-2014, 2016 Free Software Foundation, Inc.
#
# 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/>.

# Description: In tar 1.26 listed-incremental with -C and absolute path
# would malfunction under certain conditions due to buggy filename
# normalization.
#
# The value returned by normalize_filename() is used to populate the "caname"
# field in both the "directory" structure in incremen.c and the "name"
# structure in names.c, and in both cases that field is then used in the
# "hash" and "compare" functions for the related hash tables.  Thus, the
# fact that the returned value doesn't reflect the operation of previous
# "-C" options means that it's possible for two different directories to
# be given the same "caname" value in the hashed structure and thus end up
# being confused with each other.
#
# The bug is triggered when dumping both relative paths after -C and
# absolute paths that match the process' current working directory.
#
# Reported by: Nathan Stratton Treadway <nathanst@ontko.com>
# References: <20130922192135.GJ32256@shire.ontko.com>,
#             http://lists.gnu.org/archive/html/bug-tar/2013-09/msg00034.html

AT_SETUP([filename normalization])
AT_KEYWORDS([incremental create incr08])

AT_TAR_CHECK([
AT_CHECK_TIMESTAMP
AT_SORT_PREREQ
mkdir tartest
cd tartest
mkdir foo
mkdir foo/subdir
mkdir foo/subdir/dir1
mkdir subdir
mkdir subdir/dir2
decho A
find .|sort

decho B
DIR=`pwd`
tar -cvf ../foo.tar --listed-incremental=../foo.snar -C foo . $DIR 2>../err |\
  sed "s|$DIR|ABSPATH|"
sed "s|$DIR|ABSPATH|" ../err >&2
],
[0],
[A
.
./foo
./foo/subdir
./foo/subdir/dir1
./subdir
./subdir/dir2
B
./
./subdir/
./subdir/dir1/
ABSPATH/
ABSPATH/subdir/
ABSPATH/subdir/dir2/
],
[A
B
tar: .: Directory is new
tar: ./subdir: Directory is new
tar: ./subdir/dir1: Directory is new
tar: ABSPATH: Directory is new
tar: ABSPATH/subdir: Directory is new
tar: ABSPATH/subdir/dir2: Directory is new
tar: Removing leading `/' from member names
],[],[],[gnu])

AT_CLEANUP