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 optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
13 testing "tar hardlinks and repeated files" '\
14 rm -rf input_* test.tar 2>/dev/null
16 ln input_hard1 input_hard2
21 tar cf test.tar input input_dir/ input_hard1 input_hard2 input_hard1 input_dir/ input
22 tar tvf test.tar | sed "s/.*[0-9] input/input/"
25 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
31 input_hard2 -> input_hard1
32 input_hard1 -> input_hard1
37 -rw-r--r-- input_dir/file
39 -rw-r--r-- input_hard1
40 -rw-r--r-- input_hard2
45 optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
46 testing "tar hardlinks mode" '\
47 rm -rf input_* test.tar 2>/dev/null
50 ln input_hard1 input_hard2
53 ln input_hard1 input_dir
54 ln input_hard2 input_dir
55 tar cf test.tar input_*
56 tar tvf test.tar | sed "s/.*[0-9] input/input/"
59 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
63 input_dir/input_hard2 -> input_dir/input_hard1
64 input_hard1 -> input_dir/input_hard1
65 input_hard2 -> input_dir/input_hard1
67 -rwxr----x input_dir/input_hard1
68 -rwxr----x input_dir/input_hard2
70 -rwxr----x input_hard1
71 -rwxr----x input_hard2
76 optional FEATURE_TAR_CREATE FEATURE_LS_SORTFILES
77 testing "tar symlinks mode" '\
78 rm -rf input_* test.tar 2>/dev/null
81 ln -s input_file input_soft
84 ln input_file input_dir
85 ln input_soft input_dir
86 tar cf test.tar input_*
87 tar tvf test.tar | sed "s/.*[0-9] input/input/"
90 ls -l . input_dir/* | grep input_ | sed "s/\\(^[^ ]*\\) .* input/\\1 input/"
94 input_dir/input_soft -> input_file
95 input_file -> input_dir/input_file
96 input_soft -> input_dir/input_soft
98 -rwxr----x input_dir/input_file
101 -rwxr----x input_file
102 lrwxrwxrwx input_file
107 optional FEATURE_TAR_LONG_OPTIONS
108 testing "tar --overwrite" "\
109 rm -rf input_* test.tar 2>/dev/null
111 tar cf test.tar input_hard
113 # --overwrite opens 'input_hard' without unlinking,
114 # thus 'input_hard' still linked to 'input' and we write 'Ok' into it
115 tar xf test.tar --overwrite 2>&1 && cat input
122 cd .. && rm -rf tar.tempdir || exit 1