2 # Copyright 2009 by Denys Vlasenko
3 # Licensed under GPLv2, see file LICENSE in this source tree.
13 rm -rf tar.tempdir 2>/dev/null
14 mkdir tar.tempdir && cd tar.tempdir || exit 1
16 # testing "test name" "script" "expected result" "file input" "stdin"
18 optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
19 testing "tar hardlinks and repeated files" '\
20 rm -rf input_* test.tar 2>/dev/null
22 ln input_hard1 input_hard2
27 tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input
28 tar tvf test.tar | sed "s/.*[0-9] input/input/"
31 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
37 input_hard2 -> input_hard1
38 input_hard1 -> input_hard1
43 -rw-r--r-- input_dir/file
45 -rw-r--r-- input_hard1
46 -rw-r--r-- input_hard2
51 optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
52 testing "tar hardlinks mode" '\
53 rm -rf input_* test.tar 2>/dev/null
56 ln input_hard1 input_hard2
58 ln input_hard1 input_dir
59 ln input_hard2 input_dir
61 tar cf test.tar input_*
62 tar tvf test.tar | sed "s/.*[0-9] input/input/"
67 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
71 input_dir/input_hard2 -> input_dir/input_hard1
72 input_hard1 -> input_dir/input_hard1
73 input_hard2 -> input_dir/input_hard1
75 -rwxr----x input_dir/input_hard1
76 -rwxr----x input_dir/input_hard2
78 -rwxr----x input_hard1
79 -rwxr----x input_hard2
84 optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
85 testing "tar symlinks mode" '\
86 rm -rf input_* test.tar 2>/dev/null
89 ln -s input_file input_soft
91 ln input_file input_dir
92 ln input_soft input_dir
94 tar cf test.tar input_*
95 tar tvf test.tar | sed "s/.*[0-9] input/input/" | sort
100 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
104 input_dir/input_soft -> input_file
105 input_file -> input_dir/input_file
106 input_soft -> input_dir/input_soft
108 -rwxr----x input_dir/input_file
109 lrwxrwxrwx input_file
111 -rwxr----x input_file
112 lrwxrwxrwx input_file
117 optional FEATURE_TAR_CREATE FEATURE_TAR_LONG_OPTIONS
118 testing "tar --overwrite" "\
119 rm -rf input_* test.tar 2>/dev/null
121 tar cf test.tar input_hard
123 # --overwrite opens 'input_hard' without unlinking,
124 # thus 'input_hard' still linked to 'input' and we write 'Ok' into it
125 tar xf test.tar --overwrite 2>&1 && cat input
132 cd .. && rm -rf tar.tempdir || exit 1