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; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 23 | @echo Verify that busybox cp exists; |
| 24 | @echo ------------------------------; |
| 25 | [ -x ${BCP} ] || exit 0 |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 26 | |
| 27 | @echo; |
| 28 | mkdir cp_tests; |
| 29 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 30 | @echo Copy a file to a copy of the file; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 31 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 32 | 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 39 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 40 | |
| 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 49 | @echo Might show timestamp differences. |
| 50 | -diff -u cp_afile_afilecopy.gnu cp_afile_afilecopy.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 51 | |
| 52 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 53 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 54 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 55 | @echo; echo Copy a file pointed to by a symlink; |
| 56 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 57 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 58 | 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 Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 87 | @echo; echo Copy a symlink, useing the -a switch.; |
| 88 | @echo ------------------------------; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 89 | cd cp_tests; \ |
| 90 | echo A file > afile; \ |
| 91 | mkdir here there; \ |
| 92 | cd here; \ |
| 93 | ln -s ../afile . |
| 94 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 95 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 96 | ls -lR . > ../cp_a_symlink.gnu; \ |
| 97 | ${GCP} -a here/afile there; \ |
| 98 | ls -lR . >> ../cp_a_symlink.gnu; |
| 99 | |
| 100 | @echo; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 101 | rm -rf cp_tests/there/*; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 102 | |
| 103 | sleep 1; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 104 | |
| 105 | @echo; |
| 106 | cd cp_tests; \ |
| 107 | echo A file > afile; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 108 | ls -lR . > ../cp_a_symlink.bb; \ |
| 109 | ${BCP} -a here/afile there; \ |
| 110 | ls -lR . >> ../cp_a_symlink.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 111 | |
| 112 | @echo; |
| 113 | diff -u cp_a_symlink.gnu cp_a_symlink.bb; |
| 114 | |
| 115 | @echo; |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 116 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 117 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 118 | @echo; echo Copy a directory into another directory with the -a switch; |
| 119 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 120 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 121 | 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 126 | |
| 127 | @echo; |
| 128 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 129 | ls -lR . > ../cp_a_dir_dir.gnu; \ |
| 130 | ${GCP} -a here/ there/; \ |
| 131 | ls -lR . >> ../cp_a_dir_dir.gnu; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 132 | |
| 133 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 134 | rm -rf cp_tests/there/*; |
| 135 | |
| 136 | sleep 1; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 137 | |
| 138 | @echo; |
| 139 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 140 | ls -lR . > ../cp_a_dir_dir.bb; \ |
| 141 | ${BCP} -a here/ there/; \ |
| 142 | ls -lR . >> ../cp_a_dir_dir.bb; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 143 | |
| 144 | @echo; |
| 145 | diff -u cp_a_dir_dir.gnu cp_a_dir_dir.bb; |
| 146 | |
| 147 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 148 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 149 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 150 | # Copy a set of files to a directory. |
| 151 | @echo; echo Copy a set of files to a directory.; |
| 152 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 153 | cd cp_tests; \ |
| 154 | echo A file number one > afile1; \ |
| 155 | echo A file number two, blah. > afile2; \ |
| 156 | ln -s afile1 symlink1; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 157 | mkdir there; |
| 158 | |
| 159 | cd cp_tests; \ |
| 160 | ${GCP} afile1 afile2 symlink1 there/; \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 161 | ls -lR > ../cp_files_dir.gnu; |
| 162 | |
| 163 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 164 | rm -rf cp_tests/there/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 165 | |
| 166 | @echo; |
| 167 | cd cp_tests; \ |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 168 | ${BCP} afile1 afile2 symlink1 there/; \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 169 | ls -lR > ../cp_files_dir.bb; |
| 170 | |
| 171 | @echo; |
| 172 | diff -u cp_files_dir.gnu cp_files_dir.bb; |
| 173 | |
| 174 | @echo; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 175 | rm -rf cp_tests/*; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 176 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 177 | # 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 180 | 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 Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 206 | # 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 209 | 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 Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 237 | @echo; echo Copy a set of files to a directory with -p and -d switches. |
| 238 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 239 | 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 Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 267 | @echo; echo Copy a directory into another directory with the -a switch. |
| 268 | @echo ------------------------------; |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 269 | 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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 280 | @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 Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 298 | @echo; |
| 299 | rm -rf cp_tests/dir{a,b}; |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 300 | |
Erik Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 301 | # 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 Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 304 | @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 Andersen | e90f404 | 2000-04-21 21:53:58 +0000 | [diff] [blame^] | 323 | |
| 324 | # Done |
Erik Andersen | 029011b | 2000-03-04 21:19:32 +0000 | [diff] [blame] | 325 | @echo; |
| 326 | rm -rf cp_tests; |
| 327 | @echo; echo Done. |