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 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 17 | cp_tests: cp_clean cp check_exists check_simple_cp check_cp_symlnk \ |
| 18 | check_cp_symlink_w_a check_cp_files_to_dir check_cp_files_to_dir_w_d \ |
Eric Andersen | 3f75503 | 2000-06-14 22:16:59 +0000 | [diff] [blame^] | 19 | check_cp_files_to_dir_w_p check_cp_files_to_dir_w_p_and_d \ |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 20 | check_cp_dir_to_dir_wo_a check_cp_dir_to_dir_w_a \ |
| 21 | check_cp_dir_to_dir_w_a_take_two |
| 22 | |
| 23 | check_exists: |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 24 | @echo; |
| 25 | @echo "No output from diff means busybox cp is functioning properly."; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 26 | @echo "Some tests might show timestamp differences that are Ok."; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 27 | |
| 28 | @echo; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 29 | @echo Verify that busybox cp exists; |
| 30 | @echo ------------------------------; |
| 31 | [ -x ${BCP} ] || exit 0 |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 32 | |
| 33 | @echo; |
| 34 | mkdir cp_tests; |
| 35 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 36 | check_simple_cp: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 37 | @echo Copy a file to a copy of the file; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 38 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 39 | cd cp_tests; \ |
| 40 | echo A file > afile; \ |
| 41 | ls -l afile > ../cp_afile_afilecopy.gnu; \ |
| 42 | ${GCP} afile afilecopy; \ |
| 43 | ls -l afile afilecopy >> ../cp_afile_afilecopy.gnu; |
| 44 | |
| 45 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 46 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 47 | |
| 48 | @echo; |
| 49 | cd cp_tests; \ |
| 50 | echo A file > afile; \ |
| 51 | ls -l afile > ../cp_afile_afilecopy.bb; \ |
| 52 | ${BCP} afile afilecopy; \ |
| 53 | ls -l afile afilecopy >> ../cp_afile_afilecopy.bb; |
| 54 | |
| 55 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 56 | @echo Might show timestamp differences. |
| 57 | -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 58 | |
| 59 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 60 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 61 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 62 | check_cp_symlnk: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 63 | @echo; echo Copy a file pointed to by a symlink; |
| 64 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 65 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 66 | mkdir here there; \ |
| 67 | echo A file > afile; \ |
| 68 | cd here; \ |
| 69 | ln -s ../afile .; \ |
| 70 | |
| 71 | @echo; |
| 72 | cd cp_tests; \ |
| 73 | ls -lR . > ../cp_symlink.gnu; \ |
| 74 | ${GCP} here/afile there; \ |
| 75 | ls -lR . >> ../cp_symlink.gnu; |
| 76 | |
| 77 | @echo; |
| 78 | rm -rf cp_tests/there/*; |
| 79 | |
| 80 | sleep 1; |
| 81 | |
| 82 | @echo; |
| 83 | cd cp_tests; \ |
| 84 | ls -lR . > ../cp_symlink.bb; \ |
| 85 | ${BCP} here/afile there; \ |
| 86 | ls -lR . >> ../cp_symlink.bb; |
| 87 | |
| 88 | @echo; |
| 89 | @echo Will show timestamp difference. |
| 90 | -diff -u cp_symlink.gnu cp_symlink.bb; |
| 91 | |
| 92 | @echo; |
| 93 | rm -rf cp_tests/* |
| 94 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 95 | check_cp_symlink_w_a: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 96 | @echo; echo Copy a symlink, useing the -a switch.; |
| 97 | @echo ------------------------------; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 98 | cd cp_tests; \ |
| 99 | echo A file > afile; \ |
| 100 | mkdir here there; \ |
| 101 | cd here; \ |
| 102 | ln -s ../afile . |
| 103 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 104 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 105 | ls -lR . > ../cp_a_symlink.gnu; \ |
| 106 | ${GCP} -a here/afile there; \ |
| 107 | ls -lR . >> ../cp_a_symlink.gnu; |
| 108 | |
| 109 | @echo; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 110 | rm -rf cp_tests/there/*; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 111 | |
| 112 | sleep 1; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 113 | |
| 114 | @echo; |
| 115 | cd cp_tests; \ |
| 116 | echo A file > afile; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 117 | ls -lR . > ../cp_a_symlink.bb; \ |
| 118 | ${BCP} -a here/afile there; \ |
| 119 | ls -lR . >> ../cp_a_symlink.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 120 | |
| 121 | @echo; |
| 122 | diff -u cp_a_symlink.gnu cp_a_symlink.bb; |
| 123 | |
| 124 | @echo; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 125 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 126 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 127 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 128 | check_cp_files_to_dir: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 129 | # Copy a set of files to a directory. |
| 130 | @echo; echo Copy a set of files to a directory.; |
| 131 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 132 | cd cp_tests; \ |
| 133 | echo A file number one > afile1; \ |
| 134 | echo A file number two, blah. > afile2; \ |
| 135 | ln -s afile1 symlink1; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 136 | mkdir there; |
| 137 | |
| 138 | cd cp_tests; \ |
| 139 | ${GCP} afile1 afile2 symlink1 there/; \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 140 | ls -lR > ../cp_files_dir.gnu; |
| 141 | |
| 142 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 143 | rm -rf cp_tests/there/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 144 | |
| 145 | @echo; |
| 146 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 147 | ${BCP} afile1 afile2 symlink1 there/; \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 148 | ls -lR > ../cp_files_dir.bb; |
| 149 | |
| 150 | @echo; |
| 151 | diff -u cp_files_dir.gnu cp_files_dir.bb; |
| 152 | |
| 153 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 154 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 155 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 156 | check_cp_files_to_dir_w_d: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 157 | # Copy a set of files to a directory with the -d switch. |
| 158 | @echo; echo Copy a set of files to a directory with the -d switch.; |
| 159 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 160 | cd cp_tests; \ |
| 161 | echo A file number one > afile1; \ |
| 162 | echo A file number two, blah. > afile2; \ |
| 163 | ln -s afile1 symlink1; \ |
| 164 | mkdir there1; \ |
| 165 | ${GCP} -d afile1 afile2 symlink1 there1/; \ |
| 166 | ls -lR > ../cp_d_files_dir.gnu; |
| 167 | |
| 168 | @echo; |
| 169 | rm -rf cp_tests/{afile{1,2},symlink1,there1}; |
| 170 | |
| 171 | @echo; |
| 172 | cd cp_tests; \ |
| 173 | echo A file number one > afile1; \ |
| 174 | echo A file number two, blah. > afile2; \ |
| 175 | ln -s afile1 symlink1; \ |
| 176 | mkdir there1; \ |
| 177 | ${BCP} -d afile1 afile2 symlink1 there1/; \ |
| 178 | ls -lR > ../cp_d_files_dir.bb; |
| 179 | |
| 180 | @echo; |
| 181 | diff -u cp_d_files_dir.gnu cp_d_files_dir.bb; |
| 182 | |
| 183 | @echo; |
| 184 | rm -rf cp_tests/{afile{1,2},symlink1,there1}; |
| 185 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 186 | check_cp_files_to_dir_w_p: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 187 | # Copy a set of files to a directory with the -p switch. |
| 188 | @echo; echo Copy a set of files to a directory with the -p switch.; |
| 189 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 190 | cd cp_tests; \ |
| 191 | echo A file number one > afile1; \ |
| 192 | echo A file number two, blah. > afile2; \ |
| 193 | touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \ |
| 194 | ln -s afile1 symlink1; \ |
| 195 | mkdir there1; \ |
| 196 | ${GCP} -p afile1 afile2 symlink1 there1/; \ |
| 197 | ls -lR > ../cp_p_files_dir.gnu; |
| 198 | |
| 199 | @echo; |
| 200 | rm -rf cp_tests/{afile{1,2},symlink1,there1}; |
| 201 | |
| 202 | @echo; |
| 203 | cd cp_tests; \ |
| 204 | echo A file number one > afile1; \ |
| 205 | echo A file number two, blah. > afile2; \ |
| 206 | touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \ |
| 207 | ln -s afile1 symlink1; \ |
| 208 | mkdir there1; \ |
| 209 | ${BCP} -p afile1 afile2 symlink1 there1/; \ |
| 210 | ls -lR > ../cp_p_files_dir.bb; |
| 211 | |
| 212 | @echo; |
| 213 | diff -u cp_p_files_dir.gnu cp_p_files_dir.bb; |
| 214 | |
| 215 | @echo; |
| 216 | rm -rf cp_tests/{afile{1,2},symlink1,there1}; |
| 217 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 218 | |
| 219 | check_cp_files_to_dir_w_p_and_d: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 220 | @echo; echo Copy a set of files to a directory with -p and -d switches. |
| 221 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 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 | ${GCP} -p -d afile1 afile2 symlink1 there1/; \ |
| 229 | ls -lR > ../cp_pd_files_dir.gnu; |
| 230 | |
| 231 | @echo; |
| 232 | rm -rf cp_tests/{afile{1,2},symlink1,there1}; |
| 233 | |
| 234 | @echo; |
| 235 | cd cp_tests; \ |
| 236 | echo A file number one > afile1; \ |
| 237 | echo A file number two, blah. > afile2; \ |
| 238 | touch --date='Sat Jan 29 21:24:08 PST 2000' afile1; \ |
| 239 | ln -s afile1 symlink1; \ |
| 240 | mkdir there1; \ |
| 241 | ${BCP} -p -d afile1 afile2 symlink1 there1/; \ |
| 242 | ls -lR > ../cp_pd_files_dir.bb; |
| 243 | |
| 244 | @echo; |
| 245 | diff -u cp_pd_files_dir.gnu cp_pd_files_dir.bb; |
| 246 | |
| 247 | @echo; |
| 248 | rm -rf cp_tests/{afile{1,2},symlink1,there1}; |
| 249 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 250 | check_cp_dir_to_dir_wo_a: |
| 251 | # Copy a directory to another directory, without the -a switch. |
| 252 | @echo; echo Copy a directory to another directory, without the -a switch. |
| 253 | @echo ------------------------------; |
| 254 | @echo There should be an error message about cannot cp a dir to a subdir of itself. |
| 255 | cd cp_tests; \ |
| 256 | touch a b c; \ |
| 257 | mkdir adir; \ |
| 258 | ls -lR . > ../cp_a_star_adir.gnu; \ |
| 259 | ${GCP} -a * adir; \ |
| 260 | ls -lR . >> ../cp_a_star_adir.gnu; |
| 261 | |
| 262 | @echo |
| 263 | @echo There should be an error message about cannot cp a dir to a subdir of itself. |
| 264 | cd cp_tests; \ |
| 265 | rm -rf adir; \ |
| 266 | mkdir adir; \ |
| 267 | ls -lR . > ../cp_a_star_adir.bb; \ |
| 268 | ${BCP} -a * adir; \ |
| 269 | ls -lR . >> ../cp_a_star_adir.bb; |
| 270 | |
| 271 | @echo; |
| 272 | diff -u cp_a_star_adir.gnu cp_a_star_adir.bb; |
| 273 | |
| 274 | # Done |
| 275 | @echo; |
| 276 | rm -rf cp_tests; |
| 277 | @echo; echo Done. |
| 278 | |
| 279 | |
| 280 | check_cp_dir_to_dir_w_a: |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 281 | @echo; echo Copy a directory into another directory with the -a switch. |
| 282 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 283 | cd cp_tests; \ |
| 284 | mkdir dir{a,b}; \ |
| 285 | echo A file > dira/afile; \ |
| 286 | echo A file in dirb > dirb/afileindirb; \ |
| 287 | ln -s dira/afile dira/alinktoafile; \ |
| 288 | mkdir dira/subdir1; \ |
| 289 | echo Another file > dira/subdir1/anotherfile; \ |
| 290 | ls -lR . > ../cp_a_dira_dirb.gnu; \ |
| 291 | ${GCP} -a dira dirb; \ |
| 292 | ls -lR . >> ../cp_a_dira_dirb.gnu; |
| 293 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 294 | @echo; |
| 295 | rm -rf cp_tests/dir{a,b}; |
| 296 | |
| 297 | @echo; |
| 298 | cd cp_tests; \ |
| 299 | mkdir dir{a,b}; \ |
| 300 | echo A file > dira/afile; \ |
| 301 | echo A file in dirb > dirb/afileindirb; \ |
| 302 | ln -s dira/afile dira/alinktoafile; \ |
| 303 | mkdir dira/subdir1; \ |
| 304 | echo Another file > dira/subdir1/anotherfile; \ |
| 305 | ls -lR . > ../cp_a_dira_dirb.bb; \ |
| 306 | ${BCP} -a dira dirb; \ |
| 307 | ls -lR . >> ../cp_a_dira_dirb.bb; |
| 308 | |
| 309 | @echo; |
| 310 | diff -u cp_a_dira_dirb.gnu cp_a_dira_dirb.bb; |
| 311 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 312 | @echo; |
| 313 | rm -rf cp_tests/dir{a,b}; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 314 | |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 315 | |
| 316 | check_cp_dir_to_dir_w_a_take_two: |
| 317 | @echo; echo Copy a directory into another directory with the -a switch; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 318 | @echo ------------------------------; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 319 | mkdir -p cp_tests/gnu; \ |
| 320 | mkdir -p cp_tests/bb; \ |
| 321 | cd cp_tests; \ |
| 322 | mkdir here there; \ |
| 323 | echo A file > here/afile; \ |
| 324 | mkdir here/adir; \ |
| 325 | touch here/adir/afileinadir; \ |
| 326 | ln -s $$(pwd) here/alink; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 327 | |
| 328 | @echo; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 329 | cd cp_tests/gnu; \ |
| 330 | ls -lR . > ../../cp_a_dir_dir.gnu; \ |
| 331 | ${GCP} -a here/ there/; \ |
| 332 | ls -lR . >> ../../cp_a_dir_dir.gnu; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame] | 333 | |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 334 | @echo; |
Eric Andersen | 28c70b3 | 2000-06-14 20:42:57 +0000 | [diff] [blame] | 335 | rm -rf cp_tests/there/*; |
| 336 | |
| 337 | sleep 1; |
| 338 | |
| 339 | @echo; |
| 340 | cd cp_tests/bb; \ |
| 341 | ls -lR . > ../../cp_a_dir_dir.bb; \ |
| 342 | ${BCP} -a here/ there/; \ |
| 343 | ls -lR . >> ../../cp_a_dir_dir.bb; |
| 344 | |
| 345 | @echo; |
| 346 | echo "Erik 1" |
| 347 | diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb; |
| 348 | echo "Erik 2" |
| 349 | |
| 350 | @echo; |
| 351 | echo "Erik 3" |
| 352 | rm -rf cp_tests/*; |
| 353 | |
| 354 | |