2 # Copyright 2009 by Denys Vlasenko
3 # Licensed under GPL v2, see file LICENSE for details.
7 rm -rf tar.tempdir 2>/dev/null
8 mkdir tar.tempdir && cd tar.tempdir || exit 1
10 # testing "test name" "script" "expected result" "file input" "stdin"
12 testing "tar hardlinks and repeated files" '\
13 rm -rf input_* test.tar 2>/dev/null
15 ln input_hard1 input_hard2
20 tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input
21 tar tvf test.tar | sed "s/.*[0-9] input/input/"
24 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
30 input_hard2 -> input_hard1
31 input_hard1 -> input_hard1
36 -rw-r--r-- input_dir/file
38 -rw-r--r-- input_hard1
39 -rw-r--r-- input_hard2
43 testing "tar hardlinks mode" '\
44 rm -rf input_* test.tar 2>/dev/null
47 ln input_hard1 input_hard2
50 ln input_hard1 input_dir
51 ln input_hard2 input_dir
52 tar cf test.tar input_*
53 tar tvf test.tar | sed "s/.*[0-9] input/input/"
56 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
60 input_dir/input_hard2 -> input_dir/input_hard1
61 input_hard1 -> input_dir/input_hard1
62 input_hard2 -> input_dir/input_hard1
64 -rwxr----x input_dir/input_hard1
65 -rwxr----x input_dir/input_hard2
67 -rwxr----x input_hard1
68 -rwxr----x input_hard2
72 testing "tar symlinks mode" '\
73 rm -rf input_* test.tar 2>/dev/null
76 ln -s input_file input_soft
79 ln input_file input_dir
80 ln input_soft input_dir
81 tar cf test.tar input_*
82 tar tvf test.tar | sed "s/.*[0-9] input/input/"
85 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
89 input_dir/input_soft -> input_file
90 input_file -> input_dir/input_file
91 input_soft -> input_dir/input_soft
93 -rwxr----x input_dir/input_file
101 optional FEATURE_TAR_LONG_OPTIONS
102 testing "tar --overwrite" "\
103 rm -rf input_* test.tar 2>/dev/null
105 tar cf test.tar input_hard
107 # --overwrite opens 'input_hard' without unlinking,
108 # thus 'input_hard' still linked to 'input' and we write 'Ok' into it
109 tar xf test.tar --overwrite 2>&1 && cat input
116 cd .. && rm -rf tar.tempdir || exit 1