Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / busybox / testsuite / cp.tests
blob33cd876be1248798f2252129b83da3ad584a7630
1 #!/bin/sh
2 # Copyright 2010 by Denys Vlasenko
3 # Licensed under GPLv2, see file LICENSE in this source tree.
5 . ./testing.sh
7 # Opening quote in "omitting directory 'dir'" message:
8 sq='`' # GNU cp: `
9 sq="'" # bbox cp: '
11 rm -rf cp.testdir >/dev/null
13 mkdir cp.testdir
14 mkdir cp.testdir/dir
15 > cp.testdir/dir/file
16 ln -s file cp.testdir/dir/file_symlink
18 > cp.testdir/file
19 ln -s file cp.testdir/file_symlink
20 ln -s dir cp.testdir/dir_symlink
23 # testing "test name" "command" "expected result" "file input" "stdin"
25 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
26 testing "cp" '\
27 cd cp.testdir || exit 1; cp * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
28 test ! -L file && test -f file || echo BAD: file
29 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
30 test ! -L dir && test ! -e dir || echo BAD: dir
31 test ! -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
32 ' "\
33 cp: omitting directory ${sq}dir'
34 cp: omitting directory ${sq}dir_symlink'
36 " "" ""
38 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
39 testing "cp -d" '\
40 cd cp.testdir || exit 1; cp -d * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
41 test ! -L file && test -f file || echo BAD: file
42 test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
43 test ! -L dir && test ! -e dir || echo BAD: dir
44 test -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
45 ' "\
46 cp: omitting directory ${sq}dir'
48 " "" ""
50 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
51 testing "cp -P" '\
52 cd cp.testdir || exit 1; cp -P * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
53 test ! -L file && test -f file || echo BAD: file
54 test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
55 test ! -L dir && test ! -e dir || echo BAD: dir
56 test -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
57 ' "\
58 cp: omitting directory ${sq}dir'
60 " "" ""
62 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
63 testing "cp -L" '\
64 cd cp.testdir || exit 1; cp -L * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
65 test ! -L file && test -f file || echo BAD: file
66 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
67 test ! -L dir && test ! -e dir || echo BAD: dir
68 test ! -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
69 ' "\
70 cp: omitting directory ${sq}dir'
71 cp: omitting directory ${sq}dir_symlink'
73 " "" ""
75 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
76 testing "cp -H" '\
77 cd cp.testdir || exit 1; cp -H * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
78 test ! -L file && test -f file || echo BAD: file
79 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
80 test ! -L dir && test ! -e dir || echo BAD: dir
81 test ! -L dir_symlink && test ! -e dir_symlink || echo BAD: dir_symlink
82 ' "\
83 cp: omitting directory ${sq}dir'
84 cp: omitting directory ${sq}dir_symlink'
86 " "" ""
88 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
89 testing "cp -R" '\
90 cd cp.testdir || exit 1; cp -R * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
91 test ! -L file && test -f file || echo BAD: file
92 test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
93 test ! -L dir && test -d dir || echo BAD: dir
94 test -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
95 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
96 test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
97 ' "\
99 " "" ""
101 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
102 testing "cp -Rd" '\
103 cd cp.testdir || exit 1; cp -Rd * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
104 test ! -L file && test -f file || echo BAD: file
105 test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
106 test ! -L dir && test -d dir || echo BAD: dir
107 test -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
108 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
109 test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
110 ' "\
112 " "" ""
114 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
115 testing "cp -RP" '\
116 cd cp.testdir || exit 1; cp -RP * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
117 test ! -L file && test -f file || echo BAD: file
118 test -L file_symlink && test -f file_symlink || echo BAD: file_symlink
119 test ! -L dir && test -d dir || echo BAD: dir
120 test -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
121 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
122 test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
123 ' "\
125 " "" ""
127 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
128 testing "cp -RL" '\
129 cd cp.testdir || exit 1; cp -RL * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
130 test ! -L file && test -f file || echo BAD: file
131 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
132 test ! -L dir && test -d dir || echo BAD: dir
133 test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
134 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
135 test ! -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
136 ' "\
138 " "" ""
140 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
141 # GNU coreutils 7.2 says:
142 # cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
143 test x"$SKIP_KNOWN_BUGS" = x"" && \
144 testing "cp -RH" '\
145 cd cp.testdir || exit 1; cp -RH * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
146 test ! -L file && test -f file || echo BAD: file
147 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
148 test ! -L dir && test -d dir || echo BAD: dir
149 test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
150 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
151 test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
152 ' "\
154 " "" ""
156 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
157 # GNU coreutils 7.2 says:
158 # cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
159 test x"$SKIP_KNOWN_BUGS" = x"" && \
160 testing "cp -RHP" '\
161 cd cp.testdir || exit 1; cp -RHP * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
162 test ! -L file && test -f file || echo BAD: file
163 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
164 test ! -L dir && test -d dir || echo BAD: dir
165 test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
166 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
167 test -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
168 ' "\
170 " "" ""
172 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
173 testing "cp -RHL" '\
174 cd cp.testdir || exit 1; cp -RHL * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
175 test ! -L file && test -f file || echo BAD: file
176 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
177 test ! -L dir && test -d dir || echo BAD: dir
178 test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
179 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
180 test ! -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
181 ' "\
183 " "" ""
185 rm -rf cp.testdir2 >/dev/null && mkdir cp.testdir2 || exit 1
186 # Wow! "cp -RLH" is not the same as "cp -RHL" (prev test)!
187 # GNU coreutils 7.2 says:
188 # cp: will not create hard link `../cp.testdir2/dir_symlink' to directory `../cp.testdir2/dir'
189 test x"$SKIP_KNOWN_BUGS" = x"" && \
190 testing "cp -RLH" '\
191 cd cp.testdir || exit 1; cp -RLH * ../cp.testdir2 2>&1; echo $?; cd ../cp.testdir2 || exit 1
192 test ! -L file && test -f file || echo BAD: file
193 test ! -L file_symlink && test -f file_symlink || echo BAD: file_symlink
194 test ! -L dir && test -d dir || echo BAD: dir
195 test ! -L dir_symlink && test -d dir_symlink || echo BAD: dir_symlink
196 test ! -L dir/file && test -f dir/file || echo BAD: dir/file
197 test ! -L dir/file_symlink && test -f dir/file_symlink || echo BAD: dir/file_symlink
198 ' "\
200 " "" ""
203 # Clean up
204 rm -rf cp.testdir cp.testdir2 2>/dev/null
206 exit $FAILCOUNT