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