1 # cp_tests.mk - Set of test cases for busybox cp
3 # Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
15 - rm -rf cp_tests cp_*.{gnu,bb} cp
17 # check_cp_dir_to_dir_wo_a removed from this list; see below
18 cp_tests: cp_clean cp check_exists check_simple_cp check_cp_symlnk \
19 check_cp_symlink_w_a check_cp_files_to_dir check_cp_files_to_dir_w_d \
20 check_cp_files_to_dir_w_p check_cp_files_to_dir_w_p_and_d \
21 check_cp_dir_to_dir_w_a \
22 check_cp_dir_to_dir_w_a_take_two
26 @echo "No output from diff means busybox cp is functioning properly.";
27 @echo "Some tests might show timestamp differences that are Ok.";
30 @echo Verify that busybox cp exists;
31 @echo ------------------------------;
32 [ -x ${BCP} ] || exit 0
38 @echo Copy a file to a copy of the file;
39 @echo ------------------------------;
41 echo A file > afile; \
42 ls -l afile > ../cp_afile_afilecopy.gnu; \
43 ${GCP} afile afilecopy; \
44 ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu;
51 echo A file > afile; \
52 ls -l afile > ../cp_afile_afilecopy.bb; \
53 ${BCP} afile afilecopy; \
54 ls -l afile afilecopy >> ../cp_afile_afilecopy.bb;
57 @echo Might show timestamp differences.
58 -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb;
64 @echo; echo Copy a file pointed to by a symlink;
65 @echo ------------------------------;
68 echo A file > afile; \
74 ls -lR . > ../cp_symlink.gnu; \
75 ${GCP} here/afile there; \
76 ls -lR . >> ../cp_symlink.gnu;
79 rm -rf cp_tests/there/*;
85 ls -lR . > ../cp_symlink.bb; \
86 ${BCP} here/afile there; \
87 ls -lR . >> ../cp_symlink.bb;
90 @echo Will show timestamp difference.
91 -diff -u cp_symlink.gnu cp_symlink.bb;
97 @echo; echo Copy a symlink, useing the -a switch.;
98 @echo ------------------------------;
100 echo A file > afile; \
106 ls -lR . > ../cp_a_symlink.gnu; \
107 ${GCP} -a here/afile there; \
108 ls -lR . >> ../cp_a_symlink.gnu;
111 rm -rf cp_tests/there/*;
117 echo A file > afile; \
118 ls -lR . > ../cp_a_symlink.bb; \
119 ${BCP} -a here/afile there; \
120 ls -lR . >> ../cp_a_symlink.bb;
123 diff -u cp_a_symlink.gnu cp_a_symlink.bb;
129 check_cp_files_to_dir:
130 # Copy a set of files to a directory.
131 @echo; echo Copy a set of files to a directory.;
132 @echo ------------------------------;
134 echo A file number one > afile1; \
135 echo A file number two, blah. > afile2; \
136 ln -s afile1 symlink1; \
140 ${GCP} afile1 afile2 symlink1 there/; \
141 ls -lR > ../cp_files_dir.gnu;
144 rm -rf cp_tests/there/*;
148 ${BCP} afile1 afile2 symlink1 there/; \
149 ls -lR > ../cp_files_dir.bb;
152 diff -u cp_files_dir.gnu cp_files_dir.bb;
157 check_cp_files_to_dir_w_d:
158 # Copy a set of files to a directory with the -d switch.
159 @echo; echo Copy a set of files to a directory with the -d switch.;
160 @echo ------------------------------;
162 echo A file number one > afile1; \
163 echo A file number two, blah. > afile2; \
164 ln -s afile1 symlink1; \
166 ${GCP} -d afile1 afile2 symlink1 there1/; \
167 ls -lR > ../cp_d_files_dir.gnu;
170 rm -rf cp_tests/{afile{1,2},symlink1,there1};
174 echo A file number one > afile1; \
175 echo A file number two, blah. > afile2; \
176 ln -s afile1 symlink1; \
178 ${BCP} -d afile1 afile2 symlink1 there1/; \
179 ls -lR > ../cp_d_files_dir.bb;
182 diff -u cp_d_files_dir.gnu cp_d_files_dir.bb;
185 rm -rf cp_tests/{afile{1,2},symlink1,there1};
187 check_cp_files_to_dir_w_p:
188 # Copy a set of files to a directory with the -p switch.
189 @echo; echo Copy a set of files to a directory with the -p switch.;
190 @echo ------------------------------;
192 echo A file number one > afile1; \
193 echo A file number two, blah. > afile2; \
194 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
195 ln -s afile1 symlink1; \
197 ${GCP} -p afile1 afile2 symlink1 there1/; \
198 ls -lR > ../cp_p_files_dir.gnu;
201 rm -rf cp_tests/{afile{1,2},symlink1,there1};
205 echo A file number one > afile1; \
206 echo A file number two, blah. > afile2; \
207 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
208 ln -s afile1 symlink1; \
210 ${BCP} -p afile1 afile2 symlink1 there1/; \
211 ls -lR > ../cp_p_files_dir.bb;
214 diff -u cp_p_files_dir.gnu cp_p_files_dir.bb;
217 rm -rf cp_tests/{afile{1,2},symlink1,there1};
220 check_cp_files_to_dir_w_p_and_d:
221 @echo; echo Copy a set of files to a directory with -p and -d switches.
222 @echo ------------------------------;
224 echo A file number one > afile1; \
225 echo A file number two, blah. > afile2; \
226 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
227 ln -s afile1 symlink1; \
229 ${GCP} -p -d afile1 afile2 symlink1 there1/; \
230 ls -lR > ../cp_pd_files_dir.gnu;
233 rm -rf cp_tests/{afile{1,2},symlink1,there1};
237 echo A file number one > afile1; \
238 echo A file number two, blah. > afile2; \
239 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
240 ln -s afile1 symlink1; \
242 ${BCP} -p -d afile1 afile2 symlink1 there1/; \
243 ls -lR > ../cp_pd_files_dir.bb;
246 diff -u cp_pd_files_dir.gnu cp_pd_files_dir.bb;
249 rm -rf cp_tests/{afile{1,2},symlink1,there1};
251 # This test doesn't work any more; gnu cp now _does_ copy a directory
252 # to a subdirectory of itself. What's worse, that "feature" has no
253 # (documented) way to be disabled with command line switches.
254 # It's not obvious that busybox cp should mimic this behavior.
255 # For now, this test is removed from the cp_tests list, above.
256 check_cp_dir_to_dir_wo_a:
257 # Copy a directory to another directory, without the -a switch.
258 @echo; echo Copy a directory to another directory, without the -a switch.
259 @echo ------------------------------;
260 @echo There should be an error message about cannot cp a dir to a subdir of itself.
264 ls -lR . > ../cp_a_star_adir.gnu; \
266 ls -lR . >> ../cp_a_star_adir.gnu;
269 @echo There should be an error message about cannot cp a dir to a subdir of itself.
273 ls -lR . > ../cp_a_star_adir.bb; \
275 ls -lR . >> ../cp_a_star_adir.bb;
278 diff -u cp_a_star_adir.gnu cp_a_star_adir.bb;
286 check_cp_dir_to_dir_w_a:
287 @echo; echo Copy a directory into another directory with the -a switch.
288 @echo ------------------------------;
291 echo A file > dira/afile; \
292 echo A file in dirb > dirb/afileindirb; \
293 ln -s dira/afile dira/alinktoafile; \
294 mkdir dira/subdir1; \
295 echo Another file > dira/subdir1/anotherfile; \
296 ls -lR . > ../cp_a_dira_dirb.gnu; \
297 ${GCP} -a dira dirb; \
298 ls -lR . >> ../cp_a_dira_dirb.gnu;
301 rm -rf cp_tests/dir{a,b};
306 echo A file > dira/afile; \
307 echo A file in dirb > dirb/afileindirb; \
308 ln -s dira/afile dira/alinktoafile; \
309 mkdir dira/subdir1; \
310 echo Another file > dira/subdir1/anotherfile; \
311 ls -lR . > ../cp_a_dira_dirb.bb; \
312 ${BCP} -a dira dirb; \
313 ls -lR . >> ../cp_a_dira_dirb.bb;
316 diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb;
319 rm -rf cp_tests/dir{a,b};
322 check_cp_dir_to_dir_w_a_take_two:
323 @echo; echo Copy a directory into another directory with the -a switch;
324 @echo ------------------------------;
325 mkdir -p cp_tests/gnu; \
326 mkdir -p cp_tests/bb; \
329 echo A file > here/afile; \
331 touch here/adir/afileinadir; \
332 ln -s $$(pwd) here/alink;
336 ls -lR . > ../../cp_a_dir_dir.gnu; \
337 ${GCP} -a here/ there/; \
338 ls -lR . >> ../../cp_a_dir_dir.gnu;
341 rm -rf cp_tests/there/*;
347 ls -lR . > ../../cp_a_dir_dir.bb; \
348 ${BCP} -a here/ there/; \
349 ls -lR . >> ../../cp_a_dir_dir.bb;
353 diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb;