aboutsummaryrefslogtreecommitdiff
path: root/tests/cp_tests.mk
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cp_tests.mk')
-rw-r--r--tests/cp_tests.mk170
1 files changed, 110 insertions, 60 deletions
diff --git a/tests/cp_tests.mk b/tests/cp_tests.mk
index e14262ac1..e79f2b38b 100644
--- a/tests/cp_tests.mk
+++ b/tests/cp_tests.mk
@@ -1,18 +1,23 @@
1# This is a -*- makefile -*- 1# cp_tests.mk - Set of test cases for busybox cp
2# -------------
3# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL
4#
2 5
3# GNU `cp' 6# GNU `cp'
4GCP = /bin/cp 7GCP = /bin/cp
5# BusyBox `cp' 8# BusyBox `cp'
6BCP = $(shell pwd)/cp 9BCP = $(shell pwd)/cp
7 10
8.PHONY: cp_clean 11all:: cp_tests
12clean:: cp_clean
13
9cp_clean: 14cp_clean:
10 rm -rf cp_tests cp_*.{gnu,bb} cp 15 - rm -rf cp_tests cp_*.{gnu,bb} cp
11 16
12.PHONY: cp_tests
13cp_tests: cp_clean cp 17cp_tests: cp_clean cp
14 @echo; 18 @echo;
15 @echo "No output from diff means busybox cp is functioning properly."; 19 @echo "No output from diff means busybox cp is functioning properly.";
20 @echo "Some tests might show timestamp differences that are Ok.";
16 21
17 @echo; 22 @echo;
18 ${BCP} || true; 23 ${BCP} || true;
@@ -20,7 +25,8 @@ cp_tests: cp_clean cp
20 @echo; 25 @echo;
21 mkdir cp_tests; 26 mkdir cp_tests;
22 27
23 @echo; 28 # Copy a file to a copy of the file
29 @echo ------------------------------;
24 cd cp_tests; \ 30 cd cp_tests; \
25 echo A file > afile; \ 31 echo A file > afile; \
26 ls -l afile > ../cp_afile_afilecopy.gnu; \ 32 ls -l afile > ../cp_afile_afilecopy.gnu; \
@@ -28,7 +34,7 @@ cp_tests: cp_clean cp
28 ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu; 34 ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu;
29 35
30 @echo; 36 @echo;
31 rm -f cp_tests/afile*; 37 rm -rf cp_tests/*;
32 38
33 @echo; 39 @echo;
34 cd cp_tests; \ 40 cd cp_tests; \
@@ -38,118 +44,135 @@ cp_tests: cp_clean cp
38 ls -l afile afilecopy >> ../cp_afile_afilecopy.bb; 44 ls -l afile afilecopy >> ../cp_afile_afilecopy.bb;
39 45
40 @echo; 46 @echo;
41 diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb; 47 @echo Might show timestamp differences.
48 -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb;
42 49
43 @echo; 50 @echo;
44 rm -f cp_tests/afile*; 51 rm -rf cp_tests/*;
45 52
46 @echo; echo; 53 # Copy a file pointed to by a symlink
54 @echo; echo ------------------------------;
47 cd cp_tests; \ 55 cd cp_tests; \
48 mkdir there there1; \ 56 mkdir here there; \
49 cd there; \ 57 echo A file > afile; \
50 ln -s ../afile .; 58 cd here; \
59 ln -s ../afile .; \
51 60
52 @echo; 61 @echo;
53 cd cp_tests; \ 62 cd cp_tests; \
54 echo A file > afile; \ 63 ls -lR . > ../cp_symlink.gnu; \
55 ls -l afile > ../cp_symlink.gnu; \ 64 ${GCP} here/afile there; \
56 ${GCP} there/afile there1/; \ 65 ls -lR . >> ../cp_symlink.gnu;
57 ls -l afile there/afile there1/afile >> ../cp_symlink.gnu;
58 66
59 @echo; 67 @echo;
60 rm -f cp_tests/afile cp_tests/there1/afile; 68 rm -rf cp_tests/there/*;
69
70 sleep 1;
61 71
62 @echo; 72 @echo;
63 cd cp_tests; \ 73 cd cp_tests; \
64 echo A file > afile; \ 74 ls -lR . > ../cp_symlink.bb; \
65 ls -l afile > ../cp_symlink.bb; \ 75 ${BCP} here/afile there; \
66 ${BCP} there/afile there1/; \ 76 ls -lR . >> ../cp_symlink.bb;
67 ls -l afile there/afile there1/afile >> ../cp_symlink.bb;
68 77
69 @echo; 78 @echo;
70 diff -u cp_symlink.gnu cp_symlink.bb; 79 @echo Will show timestamp difference.
80 -diff -u cp_symlink.gnu cp_symlink.bb;
71 81
72 @echo; 82 @echo;
73 rm -f cp_tests/afile cp_tests/there1/afile; 83 rm -rf cp_tests/*
74 84
75 @echo; echo; 85 # Copy a symlink, useing the -a switch.
86 @echo; echo ------------------------------;
76 cd cp_tests; \ 87 cd cp_tests; \
77 echo A file > afile; \ 88 echo A file > afile; \
78 ls -l afile > ../cp_a_symlink.gnu; \ 89 mkdir here there; \
79 ${GCP} -a there/afile there1/; \ 90 cd here; \
80 ls -l afile there/afile there1/afile >> ../cp_a_symlink.gnu; 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;
81 97
82 @echo; 98 @echo;
83 rm -f cp_tests/afile cp_tests/there1/afile; 99 rm -f cp_tests/there/*;
100
101 sleep 1;
84 102
85 @echo; 103 @echo;
86 cd cp_tests; \ 104 cd cp_tests; \
87 echo A file > afile; \ 105 echo A file > afile; \
88 ls -l afile > ../cp_a_symlink.bb; \ 106 ls -lR . > ../cp_a_symlink.bb; \
89 ${BCP} -a there/afile there1/; \ 107 ${BCP} -a here/afile there; \
90 ls -l afile there/afile there1/afile >> ../cp_a_symlink.bb; 108 ls -lR . >> ../cp_a_symlink.bb;
91 109
92 @echo; 110 @echo;
93 diff -u cp_a_symlink.gnu cp_a_symlink.bb; 111 diff -u cp_a_symlink.gnu cp_a_symlink.bb;
94 112
95 @echo; 113 @echo;
96 rm -f cp_tests/afile 114 rm -f cp_tests/*;
97 rm -rf cp_tests/there{,1};
98 115
99 @echo; echo; 116 # Copy a directory into another directory with the -a switch
117 @echo; echo ------------------------------;
100 cd cp_tests; \ 118 cd cp_tests; \
101 echo A file > there/afile; \ 119 mkdir here there; \
102 mkdir there/adir; \ 120 echo A file > here/afile; \
103 touch there/adir/afileinadir; \ 121 mkdir here/adir; \
104 ln -s $(shell pwd) there/alink; 122 touch here/adir/afileinadir; \
123 ln -s $$(pwd) here/alink;
105 124
106 @echo; 125 @echo;
107 cd cp_tests; \ 126 cd cp_tests; \
108 ${GCP} -a there/ there1/; \ 127 ls -lR . > ../cp_a_dir_dir.gnu; \
109 ls -lR there/ there1/ > ../cp_a_dir_dir.gnu; 128 ${GCP} -a here/ there/; \
129 ls -lR . >> ../cp_a_dir_dir.gnu;
110 130
111 @echo; 131 @echo;
112 rm -rf cp_tests/there1; 132 rm -rf cp_tests/there/*;
133
134 sleep 1;
113 135
114 @echo; 136 @echo;
115 cd cp_tests; \ 137 cd cp_tests; \
116 ${BCP} -a there/ there1/; \ 138 ls -lR . > ../cp_a_dir_dir.bb; \
117 ls -lR there/ there1/ > ../cp_a_dir_dir.bb; 139 ${BCP} -a here/ there/; \
140 ls -lR . >> ../cp_a_dir_dir.bb;
118 141
119 @echo; 142 @echo;
120 diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb; 143 diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb;
121 144
122 @echo; 145 @echo;
123 rm -rf cp_tests/there1/; 146 rm -rf cp_tests/*;
124 147
125 @echo; echo; 148 # Copy a set of files to a directory.
149 @echo; echo ------------------------------;
126 cd cp_tests; \ 150 cd cp_tests; \
127 echo A file number one > afile1; \ 151 echo A file number one > afile1; \
128 echo A file number two, blah. > afile2; \ 152 echo A file number two, blah. > afile2; \
129 ln -s afile1 symlink1; \ 153 ln -s afile1 symlink1; \
130 mkdir there1; \ 154 mkdir there;
131 ${GCP} afile1 afile2 symlink1 there1/; \ 155
156 cd cp_tests; \
157 ${GCP} afile1 afile2 symlink1 there/; \
132 ls -lR > ../cp_files_dir.gnu; 158 ls -lR > ../cp_files_dir.gnu;
133 159
134 @echo; 160 @echo;
135 rm -rf cp_tests/{afile{1,2},symlink1,there1}; 161 rm -rf cp_tests/there/*;
136 162
137 @echo; 163 @echo;
138 cd cp_tests; \ 164 cd cp_tests; \
139 echo A file number one > afile1; \ 165 ${BCP} afile1 afile2 symlink1 there/; \
140 echo A file number two, blah. > afile2; \
141 ln -s afile1 symlink1; \
142 mkdir there1; \
143 ${BCP} afile1 afile2 symlink1 there1/; \
144 ls -lR > ../cp_files_dir.bb; 166 ls -lR > ../cp_files_dir.bb;
145 167
146 @echo; 168 @echo;
147 diff -u cp_files_dir.gnu cp_files_dir.bb; 169 diff -u cp_files_dir.gnu cp_files_dir.bb;
148 170
149 @echo; 171 @echo;
150 rm -rf cp_tests/{afile{1,2},symlink1,there1}; 172 rm -rf cp_tests/*;
151 173
152 @echo; echo; 174 # Copy a set of files to a directory with the -d switch.
175 @echo; echo ------------------------------;
153 cd cp_tests; \ 176 cd cp_tests; \
154 echo A file number one > afile1; \ 177 echo A file number one > afile1; \
155 echo A file number two, blah. > afile2; \ 178 echo A file number two, blah. > afile2; \
@@ -176,7 +199,8 @@ cp_tests: cp_clean cp
176 @echo; 199 @echo;
177 rm -rf cp_tests/{afile{1,2},symlink1,there1}; 200 rm -rf cp_tests/{afile{1,2},symlink1,there1};
178 201
179 @echo; echo; 202 # Copy a set of files to a directory with the -p switch.
203 @echo; echo ------------------------------;
180 cd cp_tests; \ 204 cd cp_tests; \
181 echo A file number one > afile1; \ 205 echo A file number one > afile1; \
182 echo A file number two, blah. > afile2; \ 206 echo A file number two, blah. > afile2; \
@@ -205,7 +229,8 @@ cp_tests: cp_clean cp
205 @echo; 229 @echo;
206 rm -rf cp_tests/{afile{1,2},symlink1,there1}; 230 rm -rf cp_tests/{afile{1,2},symlink1,there1};
207 231
208 @echo; echo; 232 # Copy a set of files to a directory with -p and -d switches.
233 @echo; echo ------------------------------;
209 cd cp_tests; \ 234 cd cp_tests; \
210 echo A file number one > afile1; \ 235 echo A file number one > afile1; \
211 echo A file number two, blah. > afile2; \ 236 echo A file number two, blah. > afile2; \
@@ -234,7 +259,8 @@ cp_tests: cp_clean cp
234 @echo; 259 @echo;
235 rm -rf cp_tests/{afile{1,2},symlink1,there1}; 260 rm -rf cp_tests/{afile{1,2},symlink1,there1};
236 261
237 @echo; echo; 262 # Copy a directory into another directory with the -a switch.
263 @echo; echo ------------------------------;
238 cd cp_tests; \ 264 cd cp_tests; \
239 mkdir dir{a,b}; \ 265 mkdir dir{a,b}; \
240 echo A file > dira/afile; \ 266 echo A file > dira/afile; \
@@ -246,7 +272,6 @@ cp_tests: cp_clean cp
246 ${GCP} -a dira dirb; \ 272 ${GCP} -a dira dirb; \
247 ls -lR . >> ../cp_a_dira_dirb.gnu; 273 ls -lR . >> ../cp_a_dira_dirb.gnu;
248 274
249 # false;
250 @echo; 275 @echo;
251 rm -rf cp_tests/dir{a,b}; 276 rm -rf cp_tests/dir{a,b};
252 277
@@ -265,6 +290,31 @@ cp_tests: cp_clean cp
265 @echo; 290 @echo;
266 diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb; 291 diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb;
267 292
268 # false;
269 @echo; 293 @echo;
270 rm -rf cp_tests/dir{a,b}; 294 rm -rf cp_tests/dir{a,b};
295
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.