]> git.cworth.org Git - tar/blob - tests/append02.at
upstream: Fix extraction of device nodes.
[tar] / tests / append02.at
1 # Process this file with autom4te to create testsuite. -*- Autotest -*-
2
3 # Test suite for GNU tar.
4 # Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21 # Using tar 1.15.x the following equivalent command sets:
22 #
23 #   1. tar cf archive file1 file2
24 # and
25 #   2. tar cfT archive /dev/null
26 #      tar rf archive file1
27 #      tar rt archive file2
28 #
29 # produced different archives (GNU format is assumed). It was reported
30 # by TAMUKI Shoichi on 2006-07-21 [1].
31 #
32 # The bug was due to tar being unable to discern between GNU and OLDGNU
33 # formats and always assuming the latter. The main difference between
34 # the two is that OLDGNU preserves all bits in the mode field, whereas
35 # GNU format keeps only the lower 9 ones (mode & 0777).
36 #
37 # This was fixed on 2006-07-24 (commit f4e4adea80a) by making tar truncate
38 # the mode field even in OLDGNU format. Obviously, the fix broke the
39 # format backward compatibility, but it went unnoticed until 2009-10-03
40 # (after all, the OLDGNU format is not in much use nowadays), when
41 # Igor Zhbanov reported it [2].
42 #
43 # The final fix was applied on 2009-10-04.
44 #
45 # References:
46 # [1] <200607210526.AA03440@tamuki.linet.gr.jp>
47 #     http://lists.gnu.org/archive/html/bug-tar/2006-07/msg00029.html
48 # [2] <f44001920910020335v4cadfesf54f6593d5124814@mail.gmail.com>
49 #     http://lists.gnu.org/archive/html/bug-tar/2009-10/msg00006.html
50
51 # The test case below verifies that the equivalent create and append commands
52 # produce binary equivalent archives for all formats.
53
54 AT_SETUP([append vs. create])
55 AT_KEYWORDS([append append02 append-gnu])
56
57 AT_TAR_CHECK([
58 genfile --file file1
59 genfile --file file2
60
61 # Make sure file timestamps in the archive will not differ
62 MTIME="--mtime=@0"
63
64 # For PAX archives, we need to make sure extended header names are
65 # reproducible and that their contents won't change with time
66 if test $[]TEST_TAR_FORMAT = posix; then
67   TAR_OPTIONS="$TAR_OPTIONS --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=mtime,delete=atime,delete=ctime"
68 fi
69
70 echo Creating archive.1
71 tar $MTIME -cf archive.1 file1 file2
72
73 echo Creating archive.2
74 tar $MTIME -cf archive.2 -T /dev/null
75 tar $MTIME -rf archive.2 file1
76 tar $MTIME -rf archive.2 file2
77
78 echo Comparing archives
79 cmp archive.1 archive.2
80 ],
81 [0],
82 [Creating archive.1
83 Creating archive.2
84 Comparing archives
85 ])
86
87 AT_CLEANUP
88
89 # End of append02.at