blob: 2082d7386d85d727943897f7b3d1a2f5a27803b6 [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;
Erik Andersene90f4042000-04-21 21:53:58 +000023 @echo Verify that busybox cp exists;
24 @echo ------------------------------;
25 [ -x ${BCP} ] || exit 0
Erik Andersenfac10d72000-02-07 05:29:42 +000026
27 @echo;
28 mkdir cp_tests;
29
Erik Andersene90f4042000-04-21 21:53:58 +000030 @echo Copy a file to a copy of the file;
Erik Andersen029011b2000-03-04 21:19:32 +000031 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +000032 cd cp_tests; \
33 echo A file > afile; \
34 ls -l afile > ../cp_afile_afilecopy.gnu; \
35 ${GCP} afile afilecopy; \
36 ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu;
37
38 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +000039 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +000040
41 @echo;
42 cd cp_tests; \
43 echo A file > afile; \
44 ls -l afile > ../cp_afile_afilecopy.bb; \
45 ${BCP} afile afilecopy; \
46 ls -l afile afilecopy >> ../cp_afile_afilecopy.bb;
47
48 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +000049 @echo Might show timestamp differences.
50 -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb;
Erik Andersenfac10d72000-02-07 05:29:42 +000051
52 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +000053 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +000054
Erik Andersene90f4042000-04-21 21:53:58 +000055 @echo; echo Copy a file pointed to by a symlink;
56 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +000057 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +000058 mkdir here there; \
59 echo A file > afile; \
60 cd here; \
61 ln -s ../afile .; \
62
63 @echo;
64 cd cp_tests; \
65 ls -lR . > ../cp_symlink.gnu; \
66 ${GCP} here/afile there; \
67 ls -lR . >> ../cp_symlink.gnu;
68
69 @echo;
70 rm -rf cp_tests/there/*;
71
72 sleep 1;
73
74 @echo;
75 cd cp_tests; \
76 ls -lR . > ../cp_symlink.bb; \
77 ${BCP} here/afile there; \
78 ls -lR . >> ../cp_symlink.bb;
79
80 @echo;
81 @echo Will show timestamp difference.
82 -diff -u cp_symlink.gnu cp_symlink.bb;
83
84 @echo;
85 rm -rf cp_tests/*
86
Erik Andersene90f4042000-04-21 21:53:58 +000087 @echo; echo Copy a symlink, useing the -a switch.;
88 @echo ------------------------------;
Erik Andersen029011b2000-03-04 21:19:32 +000089 cd cp_tests; \
90 echo A file > afile; \
91 mkdir here there; \
92 cd here; \
93 ln -s ../afile .
94
Erik Andersene90f4042000-04-21 21:53:58 +000095 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +000096 ls -lR . > ../cp_a_symlink.gnu; \
97 ${GCP} -a here/afile there; \
98 ls -lR . >> ../cp_a_symlink.gnu;
99
100 @echo;
Erik Andersene90f4042000-04-21 21:53:58 +0000101 rm -rf cp_tests/there/*;
Erik Andersen029011b2000-03-04 21:19:32 +0000102
103 sleep 1;
Erik Andersenfac10d72000-02-07 05:29:42 +0000104
105 @echo;
106 cd cp_tests; \
107 echo A file > afile; \
Erik Andersen029011b2000-03-04 21:19:32 +0000108 ls -lR . > ../cp_a_symlink.bb; \
109 ${BCP} -a here/afile there; \
110 ls -lR . >> ../cp_a_symlink.bb;
Erik Andersenfac10d72000-02-07 05:29:42 +0000111
112 @echo;
113 diff -u cp_a_symlink.gnu cp_a_symlink.bb;
114
115 @echo;
Erik Andersene90f4042000-04-21 21:53:58 +0000116 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000117
Erik Andersene90f4042000-04-21 21:53:58 +0000118 @echo; echo Copy a directory into another directory with the -a switch;
119 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000120 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000121 mkdir here there; \
122 echo A file > here/afile; \
123 mkdir here/adir; \
124 touch here/adir/afileinadir; \
125 ln -s $$(pwd) here/alink;
Erik Andersenfac10d72000-02-07 05:29:42 +0000126
127 @echo;
128 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000129 ls -lR . > ../cp_a_dir_dir.gnu; \
130 ${GCP} -a here/ there/; \
131 ls -lR . >> ../cp_a_dir_dir.gnu;
Erik Andersenfac10d72000-02-07 05:29:42 +0000132
133 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000134 rm -rf cp_tests/there/*;
135
136 sleep 1;
Erik Andersenfac10d72000-02-07 05:29:42 +0000137
138 @echo;
139 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000140 ls -lR . > ../cp_a_dir_dir.bb; \
141 ${BCP} -a here/ there/; \
142 ls -lR . >> ../cp_a_dir_dir.bb;
Erik Andersenfac10d72000-02-07 05:29:42 +0000143
144 @echo;
145 diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb;
146
147 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000148 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000149
Erik Andersene90f4042000-04-21 21:53:58 +0000150 # Copy a set of files to a directory.
151 @echo; echo Copy a set of files to a directory.;
152 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000153 cd cp_tests; \
154 echo A file number one > afile1; \
155 echo A file number two, blah. > afile2; \
156 ln -s afile1 symlink1; \
Erik Andersen029011b2000-03-04 21:19:32 +0000157 mkdir there;
158
159 cd cp_tests; \
160 ${GCP} afile1 afile2 symlink1 there/; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000161 ls -lR > ../cp_files_dir.gnu;
162
163 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000164 rm -rf cp_tests/there/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000165
166 @echo;
167 cd cp_tests; \
Erik Andersen029011b2000-03-04 21:19:32 +0000168 ${BCP} afile1 afile2 symlink1 there/; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000169 ls -lR > ../cp_files_dir.bb;
170
171 @echo;
172 diff -u cp_files_dir.gnu cp_files_dir.bb;
173
174 @echo;
Erik Andersen029011b2000-03-04 21:19:32 +0000175 rm -rf cp_tests/*;
Erik Andersenfac10d72000-02-07 05:29:42 +0000176
Erik Andersene90f4042000-04-21 21:53:58 +0000177 # Copy a set of files to a directory with the -d switch.
178 @echo; echo Copy a set of files to a directory with the -d switch.;
179 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000180 cd cp_tests; \
181 echo A file number one > afile1; \
182 echo A file number two, blah. > afile2; \
183 ln -s afile1 symlink1; \
184 mkdir there1; \
185 ${GCP} -d afile1 afile2 symlink1 there1/; \
186 ls -lR > ../cp_d_files_dir.gnu;
187
188 @echo;
189 rm -rf cp_tests/{afile{1,2},symlink1,there1};
190
191 @echo;
192 cd cp_tests; \
193 echo A file number one > afile1; \
194 echo A file number two, blah. > afile2; \
195 ln -s afile1 symlink1; \
196 mkdir there1; \
197 ${BCP} -d afile1 afile2 symlink1 there1/; \
198 ls -lR > ../cp_d_files_dir.bb;
199
200 @echo;
201 diff -u cp_d_files_dir.gnu cp_d_files_dir.bb;
202
203 @echo;
204 rm -rf cp_tests/{afile{1,2},symlink1,there1};
205
Erik Andersene90f4042000-04-21 21:53:58 +0000206 # Copy a set of files to a directory with the -p switch.
207 @echo; echo Copy a set of files to a directory with the -p switch.;
208 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000209 cd cp_tests; \
210 echo A file number one > afile1; \
211 echo A file number two, blah. > afile2; \
212 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
213 ln -s afile1 symlink1; \
214 mkdir there1; \
215 ${GCP} -p afile1 afile2 symlink1 there1/; \
216 ls -lR > ../cp_p_files_dir.gnu;
217
218 @echo;
219 rm -rf cp_tests/{afile{1,2},symlink1,there1};
220
221 @echo;
222 cd cp_tests; \
223 echo A file number one > afile1; \
224 echo A file number two, blah. > afile2; \
225 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
226 ln -s afile1 symlink1; \
227 mkdir there1; \
228 ${BCP} -p afile1 afile2 symlink1 there1/; \
229 ls -lR > ../cp_p_files_dir.bb;
230
231 @echo;
232 diff -u cp_p_files_dir.gnu cp_p_files_dir.bb;
233
234 @echo;
235 rm -rf cp_tests/{afile{1,2},symlink1,there1};
236
Erik Andersene90f4042000-04-21 21:53:58 +0000237 @echo; echo Copy a set of files to a directory with -p and -d switches.
238 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000239 cd cp_tests; \
240 echo A file number one > afile1; \
241 echo A file number two, blah. > afile2; \
242 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
243 ln -s afile1 symlink1; \
244 mkdir there1; \
245 ${GCP} -p -d afile1 afile2 symlink1 there1/; \
246 ls -lR > ../cp_pd_files_dir.gnu;
247
248 @echo;
249 rm -rf cp_tests/{afile{1,2},symlink1,there1};
250
251 @echo;
252 cd cp_tests; \
253 echo A file number one > afile1; \
254 echo A file number two, blah. > afile2; \
255 touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \
256 ln -s afile1 symlink1; \
257 mkdir there1; \
258 ${BCP} -p -d afile1 afile2 symlink1 there1/; \
259 ls -lR > ../cp_pd_files_dir.bb;
260
261 @echo;
262 diff -u cp_pd_files_dir.gnu cp_pd_files_dir.bb;
263
264 @echo;
265 rm -rf cp_tests/{afile{1,2},symlink1,there1};
266
Erik Andersene90f4042000-04-21 21:53:58 +0000267 @echo; echo Copy a directory into another directory with the -a switch.
268 @echo ------------------------------;
Erik Andersenfac10d72000-02-07 05:29:42 +0000269 cd cp_tests; \
270 mkdir dir{a,b}; \
271 echo A file > dira/afile; \
272 echo A file in dirb > dirb/afileindirb; \
273 ln -s dira/afile dira/alinktoafile; \
274 mkdir dira/subdir1; \
275 echo Another file > dira/subdir1/anotherfile; \
276 ls -lR . > ../cp_a_dira_dirb.gnu; \
277 ${GCP} -a dira dirb; \
278 ls -lR . >> ../cp_a_dira_dirb.gnu;
279
Erik Andersenfac10d72000-02-07 05:29:42 +0000280 @echo;
281 rm -rf cp_tests/dir{a,b};
282
283 @echo;
284 cd cp_tests; \
285 mkdir dir{a,b}; \
286 echo A file > dira/afile; \
287 echo A file in dirb > dirb/afileindirb; \
288 ln -s dira/afile dira/alinktoafile; \
289 mkdir dira/subdir1; \
290 echo Another file > dira/subdir1/anotherfile; \
291 ls -lR . > ../cp_a_dira_dirb.bb; \
292 ${BCP} -a dira dirb; \
293 ls -lR . >> ../cp_a_dira_dirb.bb;
294
295 @echo;
296 diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb;
297
Erik Andersenfac10d72000-02-07 05:29:42 +0000298 @echo;
299 rm -rf cp_tests/dir{a,b};
Erik Andersen029011b2000-03-04 21:19:32 +0000300
Erik Andersene90f4042000-04-21 21:53:58 +0000301 # Copy a directory to another directory, without the -a switch.
302 @echo; echo Copy a directory to another directory, without the -a switch.
303 @echo ------------------------------;
Erik Andersen029011b2000-03-04 21:19:32 +0000304 @echo There should be an error message about cannot cp a dir to a subdir of itself.
305 cd cp_tests; \
306 touch a b c; \
307 mkdir adir; \
308 ls -lR . > ../cp_a_star_adir.gnu; \
309 ${GCP} -a * adir; \
310 ls -lR . >> ../cp_a_star_adir.gnu;
311
312 @echo
313 @echo There should be an error message about cannot cp a dir to a subdir of itself.
314 cd cp_tests; \
315 rm -rf adir; \
316 mkdir adir; \
317 ls -lR . > ../cp_a_star_adir.bb; \
318 ${BCP} -a * adir; \
319 ls -lR . >> ../cp_a_star_adir.bb;
320
321 @echo;
322 diff -u cp_a_star_adir.gnu cp_a_star_adir.bb;
Erik Andersene90f4042000-04-21 21:53:58 +0000323
324 # Done
Erik Andersen029011b2000-03-04 21:19:32 +0000325 @echo;
326 rm -rf cp_tests;
327 @echo; echo Done.