blob: e79f2b38b8a7e5cae10eda19f5795e38f572502a [file] [log] [blame]
Erik Andersen029011b2000-03-04 21:19:32 +00001# cp_tests.mk - Set of test cases for busybox cp
2# -------------
3# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
4#
Erik Andersenfac10d72000-02-07 05:29:42 +00005
6# GNU `cp'
7GCP = /bin/cp
8# BusyBox `cp'
9BCP = $(shell pwd)/cp
10
Erik Andersen029011b2000-03-04 21:19:32 +000011all:: cp_tests
12clean:: cp_clean
Erik Andersenfac10d72000-02-07 05:29:42 +000013
Erik Andersen029011b2000-03-04 21:19:32 +000014cp_clean:
15 - rm -rf cp_tests cp_*.{gnu,bb} cp
16
Erik Andersenfac10d72000-02-07 05:29:42 +000017cp_tests: cp_clean cp
18 @echo;
19 @echo "No output from diff means busybox cp is functioning properly.";
Erik Andersen029011b2000-03-04 21:19:32 +000020 @echo "Some tests might show timestamp differences that are Ok.";
Erik Andersenfac10d72000-02-07 05:29:42 +000021
22 @echo;
23 ${BCP} || true;
24
25 @echo;
26 mkdir cp_tests;
27
Erik Andersen029011b2000-03-04 21:19:32 +000028 # Copy a file to a copy of the file
29 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +000030 cd cp_tests; \
31 echo A file > afile; \
32 ls -l afile > ../cp_afile_afilecopy.gnu; \
33 ${GCP} afile afilecopy; \
34 ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu;
35
36 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +000037 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +000038
39 @echo;
40 cd cp_tests; \
41 echo A file > afile; \
42 ls -l afile > ../cp_afile_afilecopy.bb; \
43 ${BCP} afile afilecopy; \
44 ls -l afile afilecopy >> ../cp_afile_afilecopy.bb;
45
46 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +000047 @echo Might show timestamp differences.
48 -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb;
Erik Andersenfac10d72000-02-07 05:29:42 +000049
50 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +000051 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +000052
Erik Andersen029011b2000-03-04 21:19:32 +000053 # Copy a file pointed to by a symlink
54 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +000055 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +000056 mkdir here there; \
57 echo A file > afile; \
58 cd here; \
59 ln -s ../afile .; \
60
61 @echo;
62 cd cp_tests; \
63 ls -lR . > ../cp_symlink.gnu; \
64 ${GCP} here/afile there; \
65 ls -lR . >> ../cp_symlink.gnu;
66
67 @echo;
68 rm -rf cp_tests/there/*;
69
70 sleep 1;
71
72 @echo;
73 cd cp_tests; \
74 ls -lR . > ../cp_symlink.bb; \
75 ${BCP} here/afile there; \
76 ls -lR . >> ../cp_symlink.bb;
77
78 @echo;
79 @echo Will show timestamp difference.
80 -diff -u cp_symlink.gnu cp_symlink.bb;
81
82 @echo;
83 rm -rf cp_tests/*
84
85 # Copy a symlink, useing the -a switch.
86 @echo; echo ------------------------------;
87 cd cp_tests; \
88 echo A file > afile; \
89 mkdir here there; \
90 cd here; \
91 ln -s ../afile .
92
93 cd cp_test; \
94 ls -lR . > ../cp_a_symlink.gnu; \
95 ${GCP} -a here/afile there; \
96 ls -lR . >> ../cp_a_symlink.gnu;
97
98 @echo;
99 rm -f cp_tests/there/*;
100
101 sleep 1;
Erik Andersenfac10d72000-02-07 05:29:42 +0000102
103 @echo;
104 cd cp_tests; \
105 echo A file > afile; \
Erik Andersen029011b2000-03-04 21:19:32 +0000106 ls -lR . > ../cp_a_symlink.bb; \
107 ${BCP} -a here/afile there; \
108 ls -lR . >> ../cp_a_symlink.bb;
Erik Andersenfac10d72000-02-07 05:29:42 +0000109
110 @echo;
111 diff -u cp_a_symlink.gnu cp_a_symlink.bb;
112
113 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000114 rm -f cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000115
Erik Andersen029011b2000-03-04 21:19:32 +0000116 # Copy a directory into another directory with the -a switch
117 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000118 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000119 mkdir here there; \
120 echo A file > here/afile; \
121 mkdir here/adir; \
122 touch here/adir/afileinadir; \
123 ln -s $$(pwd) here/alink;
Erik Andersenfac10d72000-02-07 05:29:42 +0000124
125 @echo;
126 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000127 ls -lR . > ../cp_a_dir_dir.gnu; \
128 ${GCP} -a here/ there/; \
129 ls -lR . >> ../cp_a_dir_dir.gnu;
Erik Andersenfac10d72000-02-07 05:29:42 +0000130
131 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000132 rm -rf cp_tests/there/*;
133
134 sleep 1;
Erik Andersenfac10d72000-02-07 05:29:42 +0000135
136 @echo;
137 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000138 ls -lR . > ../cp_a_dir_dir.bb; \
139 ${BCP} -a here/ there/; \
140 ls -lR . >> ../cp_a_dir_dir.bb;
Erik Andersenfac10d72000-02-07 05:29:42 +0000141
142 @echo;
143 diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb;
144
145 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000146 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000147
Erik Andersen029011b2000-03-04 21:19:32 +0000148 # Copy a set of files to a directory.
149 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000150 cd cp_tests; \
151 echo A file number one > afile1; \
152 echo A file number two, blah. > afile2; \
153 ln -s afile1 symlink1; \
Erik Andersen029011b2000-03-04 21:19:32 +0000154 mkdir there;
155
156 cd cp_tests; \
157 ${GCP} afile1 afile2 symlink1 there/; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000158 ls -lR > ../cp_files_dir.gnu;
159
160 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000161 rm -rf cp_tests/there/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000162
163 @echo;
164 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000165 ${BCP} afile1 afile2 symlink1 there/; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000166 ls -lR > ../cp_files_dir.bb;
167
168 @echo;
169 diff -u cp_files_dir.gnu cp_files_dir.bb;
170
171 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000172 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000173
Erik Andersen029011b2000-03-04 21:19:32 +0000174 # Copy a set of files to a directory with the -d switch.
175 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000176 cd cp_tests; \
177 echo A file number one > afile1; \
178 echo A file number two, blah. > afile2; \
179 ln -s afile1 symlink1; \
180 mkdir there1; \
181 ${GCP} -d afile1 afile2 symlink1 there1/; \
182 ls -lR > ../cp_d_files_dir.gnu;
183
184 @echo;
185 rm -rf cp_tests/{afile{1,2},symlink1,there1};
186
187 @echo;
188 cd cp_tests; \
189 echo A file number one > afile1; \
190 echo A file number two, blah. > afile2; \
191 ln -s afile1 symlink1; \
192 mkdir there1; \
193 ${BCP} -d afile1 afile2 symlink1 there1/; \
194 ls -lR > ../cp_d_files_dir.bb;
195
196 @echo;
197 diff -u cp_d_files_dir.gnu cp_d_files_dir.bb;
198
199 @echo;
200 rm -rf cp_tests/{afile{1,2},symlink1,there1};
201
Erik Andersen029011b2000-03-04 21:19:32 +0000202 # Copy a set of files to a directory with the -p switch.
203 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000204 cd cp_tests; \
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; \
209 mkdir there1; \
210 ${GCP} -p afile1 afile2 symlink1 there1/; \
211 ls -lR > ../cp_p_files_dir.gnu;
212
213 @echo;
214 rm -rf cp_tests/{afile{1,2},symlink1,there1};
215
216 @echo;
217 cd cp_tests; \
218 echo A file number one > afile1; \
219 echo A file number two, blah. > afile2; \
220 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
221 ln -s afile1 symlink1; \
222 mkdir there1; \
223 ${BCP} -p afile1 afile2 symlink1 there1/; \
224 ls -lR > ../cp_p_files_dir.bb;
225
226 @echo;
227 diff -u cp_p_files_dir.gnu cp_p_files_dir.bb;
228
229 @echo;
230 rm -rf cp_tests/{afile{1,2},symlink1,there1};
231
Erik Andersen029011b2000-03-04 21:19:32 +0000232 # Copy a set of files to a directory with -p and -d switches.
233 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000234 cd cp_tests; \
235 echo A file number one > afile1; \
236 echo A file number two, blah. > afile2; \
237 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
238 ln -s afile1 symlink1; \
239 mkdir there1; \
240 ${GCP} -p -d afile1 afile2 symlink1 there1/; \
241 ls -lR > ../cp_pd_files_dir.gnu;
242
243 @echo;
244 rm -rf cp_tests/{afile{1,2},symlink1,there1};
245
246 @echo;
247 cd cp_tests; \
248 echo A file number one > afile1; \
249 echo A file number two, blah. > afile2; \
250 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
251 ln -s afile1 symlink1; \
252 mkdir there1; \
253 ${BCP} -p -d afile1 afile2 symlink1 there1/; \
254 ls -lR > ../cp_pd_files_dir.bb;
255
256 @echo;
257 diff -u cp_pd_files_dir.gnu cp_pd_files_dir.bb;
258
259 @echo;
260 rm -rf cp_tests/{afile{1,2},symlink1,there1};
261
Erik Andersen029011b2000-03-04 21:19:32 +0000262 # Copy a directory into another directory with the -a switch.
263 @echo; echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000264 cd cp_tests; \
265 mkdir dir{a,b}; \
266 echo A file > dira/afile; \
267 echo A file in dirb > dirb/afileindirb; \
268 ln -s dira/afile dira/alinktoafile; \
269 mkdir dira/subdir1; \
270 echo Another file > dira/subdir1/anotherfile; \
271 ls -lR . > ../cp_a_dira_dirb.gnu; \
272 ${GCP} -a dira dirb; \
273 ls -lR . >> ../cp_a_dira_dirb.gnu;
274
Erik Andersenfac10d72000-02-07 05:29:42 +0000275 @echo;
276 rm -rf cp_tests/dir{a,b};
277
278 @echo;
279 cd cp_tests; \
280 mkdir dir{a,b}; \
281 echo A file > dira/afile; \
282 echo A file in dirb > dirb/afileindirb; \
283 ln -s dira/afile dira/alinktoafile; \
284 mkdir dira/subdir1; \
285 echo Another file > dira/subdir1/anotherfile; \
286 ls -lR . > ../cp_a_dira_dirb.bb; \
287 ${BCP} -a dira dirb; \
288 ls -lR . >> ../cp_a_dira_dirb.bb;
289
290 @echo;
291 diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb;
292
Erik Andersenfac10d72000-02-07 05:29:42 +0000293 @echo;
294 rm -rf cp_tests/dir{a,b};
Erik Andersen029011b2000-03-04 21:19:32 +0000295
296 # Copy a directory to another directory, without the -a switch.
297 @echo; echo ------------------------------;
298 @echo There should be an error message about cannot cp a dir to a subdir of itself.
299 cd cp_tests; \
300 touch a b c; \
301 mkdir adir; \
302 ls -lR . > ../cp_a_star_adir.gnu; \
303 ${GCP} -a * adir; \
304 ls -lR . >> ../cp_a_star_adir.gnu;
305
306 @echo
307 @echo There should be an error message about cannot cp a dir to a subdir of itself.
308 cd cp_tests; \
309 rm -rf adir; \
310 mkdir adir; \
311 ls -lR . > ../cp_a_star_adir.bb; \
312 ${BCP} -a * adir; \
313 ls -lR . >> ../cp_a_star_adir.bb;
314
315 @echo;
316 diff -u cp_a_star_adir.gnu cp_a_star_adir.bb;
317
318 @echo;
319 rm -rf cp_tests;
320 @echo; echo Done.