Numerous new testcases from Larry Doolittle and a patch to tester.sh to avoid
[oweals/busybox.git] / tests / testcases
1 # testcases
2 #
3 # This file should be filled with test cases to test applets that:
4 #
5 #  - can somehow produce output (we can't test sync or sleep)
6 #  - have a GNU (or other) counterpart
7 #  - are not interactive (don't require a ^C or anything)
8 #  - don't require extensive setup or cleanup (a litte setup is fine)
9 #  - don't have huge and possibly damaging effects (fsck, swapoff)
10 #
11 # If possible, a test case should be made that tests each option the applet
12 # supports. When a new option is added, a new test case should be written for
13 # it. When somebody reports a bug with a testcase, that testcase should be
14 # added here as well.
15 #
16 # Some other guidelines to follow:
17 #
18 #  - please try to keep applets alphabetized, it will make life easier
19 #  - use the file tester.sh or testcases when you need to do a non-destructive
20 #    test on a file (i.e., cat, md5sum)
21 #  - try to make the applet you're testing the first thing on the line (this
22 #    not always possible)
23 #  - (???) if you have to create a temporary file, call it TMPFILE
24
25
26 # ar
27
28 # basename
29 basename `pwd`
30
31 # cat
32 cat tester.sh
33 echo hello there | cat tester.sh -
34
35 # chmod
36 # chown
37 # chgrp
38 # chroot
39 # chvt - can't be tested here
40 # clear - can't be tested here
41 # cmp
42 # cp
43
44 # cut
45 echo "1234" | cut -c1
46 echo "1234" | cut -c 1
47 echo "1234567890" | cut -c2-7
48 echo "1234567890" | cut -c 2-7
49 echo "f1        f2" | cut -f2
50 echo "f1        f2" | cut -f 2
51 echo "f1        f2      f3      f4      f5" | cut -f2-4
52 echo "f1        f2      f3      f4      f5" | cut -f 2-4
53
54 # date
55 date
56 date -R
57 date -u
58 date +%d/%m/%y
59
60 # dc - needs an input file
61
62 # dd
63 dd if=/dev/urandom of=O bs=1k count=1 ; ls -l O ; rm O
64
65 # deallocvt
66
67 # df
68 df
69 df .
70 df -k
71 df -h
72 df -m
73
74 # dirname
75 dirname `pwd`
76
77 # dmesg (XXX: change the silly cmd business in the source)
78 dmesg
79 dmesg -n 8
80 dmesg -s 512
81 # I really don't want to do this next one
82 #dmesg -c
83
84 # dos2unix - needs an input file
85 # dpkg
86 # dpkg_deb
87
88 # du
89 du
90 du -s
91 du -l
92 du -k
93 du -h
94 du -m
95
96 # dumpkmap - no counterprt?
97 # dutmp - no counterprt?
98
99 # echo
100 echo "foo bar baz"
101 echo -n "no newline"
102
103
104 # expr
105 expr 1 \\| 1
106 expr 1 \\| 0
107 expr 0 \\| 1
108 expr 0 \\| 0
109
110 expr 1 \\& 1
111 expr 1 \\& 0
112 expr 0 \\& 1
113 expr 0 \\& 0
114
115 expr 0 \\< 1
116 expr 1 \\< 0
117
118 expr 1 \\> 0
119 expr 0 \\> 1
120
121 expr 0 \\<= 1
122 expr 1 \\<= 0
123 expr 1 \\<= 1
124
125 expr 1 \\>= 0
126 expr 0 \\>= 1
127 expr 1 \\>= 1
128
129 expr 1 + 2
130 expr 2 - 1
131 expr 2 \\* 3
132 expr 12 / 2
133 expr 12 % 5
134
135 # somebody else can do all the string stuff
136
137
138 # fbset - can't be tested here
139 # fdflush
140 # find
141 find .
142
143 # free
144 free
145
146 # freeramdisk
147 # fsck.minix - won't test
148 # getopt
149
150 # grep
151 grep -l strdup ../*.c
152 grep -c strdup ../*.c
153 # I swear, GNU grep seems broken for this next one
154 grep -lc strdup ../*.c
155 grep -cv strdup ../*.c
156
157 # gunzip
158
159 # gzip
160 echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
161 echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz
162 # halt
163
164 # head
165 head tester.sh
166 head -n 2 tester.sh
167
168 # hostid
169 hostid
170
171 # hostname
172 hostname
173 hostname -s
174 hostname -i
175 hostname -d
176 # not going to do this next one
177 #hostname -F
178
179 # id
180 id
181 id -u
182 id -g
183 id -ur
184 id -un
185
186
187 # ifconfig
188 # requires BB_FEATURE_IFCONFIG_STATUS
189 ifconfig
190 #ifconfig -a
191 #ifconfig eth0
192 #ifconfig lo
193
194 # init - won't test
195 # insmod - won't test
196
197 # kill
198 #kill -l
199 # not going to do any more
200
201 # length
202 # ln - see ln_tests.mk
203 # loadacm
204 # loadfont
205 # loadkmap
206 # logger
207 # logname
208
209 # ls
210 ls ../e*
211 ls -l ../e*
212 ls -s ../e*
213 ls -h ../e*
214 ls -1 ../e*
215
216 # lsmod
217 lsmod
218
219 # makedevs
220
221 # md5sum
222 md5sum tester.sh
223
224 # mkdir
225 mkdir D ; ls -ld D ; rmdir D
226
227 # mkfifo
228 #
229 # we will test making one. actually testing pushing data through it requires
230 # more interaction than we can manage here.
231 # (these lines turn up an existing ls bug)
232 mkfifo F ; ls -l F ; rm F
233 mkfifo -m 0600 F ; ls -l F ; rm F
234
235 # mkfs.minix - won't test
236 # mknod
237 # mkswap - won't test
238 # mktemp
239 # more - can't test: interactive
240
241 # mount
242 mount
243 # not going to test any more
244
245 # mt
246 # mv - see mv_tests.mk
247 # nc
248 # nfsmount
249 # nslookup
250 # ping
251 ping -c 3 yahoo.com
252 # pivot_root
253 # poweroff - won't test
254 # printf
255 # ps - there's lotsa differences between busybox ps and any other ps
256
257 # pwd
258 pwd
259
260 # rdate - won't test
261
262 # readlink
263 ln -sf tester.sh L ; readlink L ; rm -f L
264
265 # reboot - won't test
266 # renice - won't test
267 # reset - can't test: no output
268
269 # rm
270 touch F ; rm F
271
272 # rmdir
273 # rmmod - won't test: dangerous
274
275 # route
276 route
277
278 # rpmunpack
279
280 # sed - we can do some one-liners here; probably needs it's own input file
281 echo foo | sed -ne '/^$/p'
282 sed -e '/test$/d' testcases
283 sed -e '/^echo/d' testcases
284 sed -e '/test/s/dangerous/PELIGROSO/' testcases
285
286 # setkeycodes
287
288 # sh - note that we cannot test the shell interactively here
289 sh -c "echo a b c"
290 sh -c ">"
291 sh -c "a"
292 #sh sh.testcases
293
294
295 # sleep - can't test: produces no output
296
297 # sort
298 sort tester.sh
299 sort -n tester.sh
300 sort -r tester.sh
301
302 # stty
303 # swapon - won't test: dangerous
304 # swapoff - won't test: dangerous
305 # sync - can't test: no output
306 # syslogd - won't test: too involved
307
308 # tail
309 tail tester.sh
310 tail -n 2  tester.sh
311
312 # tar
313
314 # tee
315 echo "please tee me!" | tee A B C ; cat A B C
316 echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B C ; rm A B C
317
318 # telnet - can't test: interactive
319
320 # test
321 # tftp
322
323 # touch
324 touch tmpfile1; ls tmpfile1; rm -f tmpfile1
325 touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
326
327 # tr
328 echo "cbaab" | tr abc zyx
329 echo "TESTING A B C" | tr [A-Z] [a-z]
330 # not GNU compatible
331 echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
332 echo abc[] | tr a[b AXB
333 echo testing | tr -d aeiou
334
335 # true
336 true ; echo $?
337
338 # false
339 false ; echo $?
340
341 # tty
342 # umount
343 # uname
344 # uniq
345 # unix2dos
346 # update
347
348 # uptime
349 uptime
350
351 # usleep
352 # uudecode
353 # uuencode
354 # watchdog
355
356 # wc
357 wc tester.sh
358 wc -c tester.sh
359 wc -w tester.sh
360 wc -l tester.sh
361 wc -L tester.sh
362
363 # wget
364
365 # which
366 which ls
367
368 # whoami
369 whoami
370
371 # xargs
372 ls -1 ../e* | xargs
373 ls -1 ../e* | xargs md5sum
374
375 # yes - can't test: interactive (needs ^C)