Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 1 | # cp_tests.mk - Set of test cases for busybox cp |
| 2 | # ------------- |
| 3 | # Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> GPL |
| 4 | # |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 5 | |
| 6 | # GNU `cp' |
| 7 | GCP = /bin/cp |
| 8 | # BusyBox `cp' |
| 9 | BCP = $(shell pwd)/cp |
| 10 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 11 | all:: cp_tests |
| 12 | clean:: cp_clean |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 13 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 14 | cp_clean: |
| 15 | - rm -rf cp_tests cp_*.{gnu,bb} cp |
| 16 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 17 | cp_tests: cp_clean cp |
| 18 | @echo; |
| 19 | @echo "No output from diff means busybox cp is functioning properly."; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 20 | @echo "Some tests might show timestamp differences that are Ok."; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 21 | |
| 22 | @echo; |
| 23 | ${BCP} || true; |
| 24 | |
| 25 | @echo; |
| 26 | mkdir cp_tests; |
| 27 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 28 | # Copy a file to a copy of the file |
| 29 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 30 | 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 37 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 38 | |
| 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 47 | @echo Might show timestamp differences. |
| 48 | -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 49 | |
| 50 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 51 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 52 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 53 | # Copy a file pointed to by a symlink |
| 54 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 55 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 56 | 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 102 | |
| 103 | @echo; |
| 104 | cd cp_tests; \ |
| 105 | echo A file > afile; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 106 | ls -lR . > ../cp_a_symlink.bb; \ |
| 107 | ${BCP} -a here/afile there; \ |
| 108 | ls -lR . >> ../cp_a_symlink.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 109 | |
| 110 | @echo; |
| 111 | diff -u cp_a_symlink.gnu cp_a_symlink.bb; |
| 112 | |
| 113 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 114 | rm -f cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 115 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 116 | # Copy a directory into another directory with the -a switch |
| 117 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 118 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 119 | 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 124 | |
| 125 | @echo; |
| 126 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 127 | ls -lR . > ../cp_a_dir_dir.gnu; \ |
| 128 | ${GCP} -a here/ there/; \ |
| 129 | ls -lR . >> ../cp_a_dir_dir.gnu; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 130 | |
| 131 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 132 | rm -rf cp_tests/there/*; |
| 133 | |
| 134 | sleep 1; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 135 | |
| 136 | @echo; |
| 137 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 138 | ls -lR . > ../cp_a_dir_dir.bb; \ |
| 139 | ${BCP} -a here/ there/; \ |
| 140 | ls -lR . >> ../cp_a_dir_dir.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 141 | |
| 142 | @echo; |
| 143 | diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb; |
| 144 | |
| 145 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 146 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 147 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 148 | # Copy a set of files to a directory. |
| 149 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 150 | cd cp_tests; \ |
| 151 | echo A file number one > afile1; \ |
| 152 | echo A file number two, blah. > afile2; \ |
| 153 | ln -s afile1 symlink1; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 154 | mkdir there; |
| 155 | |
| 156 | cd cp_tests; \ |
| 157 | ${GCP} afile1 afile2 symlink1 there/; \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 158 | ls -lR > ../cp_files_dir.gnu; |
| 159 | |
| 160 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 161 | rm -rf cp_tests/there/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 162 | |
| 163 | @echo; |
| 164 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 165 | ${BCP} afile1 afile2 symlink1 there/; \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 166 | ls -lR > ../cp_files_dir.bb; |
| 167 | |
| 168 | @echo; |
| 169 | diff -u cp_files_dir.gnu cp_files_dir.bb; |
| 170 | |
| 171 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 172 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 173 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 174 | # Copy a set of files to a directory with the -d switch. |
| 175 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 176 | 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 202 | # Copy a set of files to a directory with the -p switch. |
| 203 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 204 | 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 232 | # Copy a set of files to a directory with -p and -d switches. |
| 233 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 234 | 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 262 | # Copy a directory into another directory with the -a switch. |
| 263 | @echo; echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 264 | 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 275 | @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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 293 | @echo; |
| 294 | rm -rf cp_tests/dir{a,b}; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 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. |