Added support for grep -e and grep -f, closes bug #1164. Also added some
[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 grep -lc strdup ../*.c
154 grep -cv strdup ../*.c
155 grep -i null ../grep.c
156 grep -e strdup -e regcomp -e atexit ../grep.c
157
158 # gunzip
159
160 # gzip
161 echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
162 echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz
163 # halt
164
165 # head
166 head tester.sh
167 head -n 2 tester.sh
168
169 # hostid
170 hostid
171
172 # hostname
173 hostname
174 hostname -s
175 hostname -i
176 hostname -d
177 # not going to do this next one
178 #hostname -F
179
180 # id
181 id
182 id -u
183 id -g
184 id -ur
185 id -un
186
187
188 # ifconfig
189 # requires BB_FEATURE_IFCONFIG_STATUS
190 ifconfig
191 #ifconfig -a
192 #ifconfig eth0
193 #ifconfig lo
194
195 # init - won't test
196 # insmod - won't test
197
198 # kill
199 #kill -l
200 # not going to do any more
201
202 # length
203 # ln - see ln_tests.mk
204 # loadacm
205 # loadfont
206 # loadkmap
207 # logger
208 # logname
209
210 # ls
211 ls ../e*
212 ls -l ../e*
213 ls -s ../e*
214 ls -h ../e*
215 ls -1 ../e*
216
217 # lsmod
218 lsmod
219
220 # makedevs
221
222 # md5sum
223 md5sum tester.sh
224
225 # mkdir
226 mkdir D ; ls -ld D ; rmdir D
227
228 # mkfifo
229 #
230 # we will test making one. actually testing pushing data through it requires
231 # more interaction than we can manage here.
232 # (these lines turn up an existing ls bug)
233 mkfifo F ; ls -l F ; rm F
234 mkfifo -m 0600 F ; ls -l F ; rm F
235
236 # mkfs.minix - won't test
237 # mknod
238 # mkswap - won't test
239 # mktemp
240 # more - can't test: interactive
241
242 # mount
243 mount
244 # not going to test any more
245
246 # mt
247 # mv - see mv_tests.mk
248 # nc
249 # nfsmount
250 # nslookup
251 # ping
252 ping -c 3 yahoo.com
253 # pivot_root
254 # poweroff - won't test
255 # printf
256 # ps - there's lotsa differences between busybox ps and any other ps
257
258 # pwd
259 pwd
260
261 # rdate - won't test
262
263 # readlink
264 ln -sf tester.sh L ; readlink L ; rm -f L
265
266 # reboot - won't test
267 # renice - won't test
268 # reset - can't test: no output
269
270 # rm
271 touch F ; rm F
272
273 # rmdir
274 # rmmod - won't test: dangerous
275
276 # route
277 route
278
279 # rpmunpack
280
281 # sed - we can do some one-liners here; probably needs it's own input file
282 echo foo | sed -ne '/^$/p'
283 sed -e '/test$/d' testcases
284 sed -e '/^echo/d' testcases
285 sed -e '/test/s/dangerous/PELIGROSO/' testcases
286
287 # setkeycodes
288
289 # sh - note that we cannot test the shell interactively here
290 sh -c "echo a b c"
291 sh -c ">"
292 sh -c "a"
293 #sh sh.testcases
294
295
296 # sleep - can't test: produces no output
297
298 # sort
299 sort tester.sh
300 sort -n tester.sh
301 sort -r tester.sh
302
303 # stty
304 # swapon - won't test: dangerous
305 # swapoff - won't test: dangerous
306 # sync - can't test: no output
307 # syslogd - won't test: too involved
308
309 # tail
310 tail tester.sh
311 tail -n 2  tester.sh
312
313 # tar
314
315 # tee
316 echo "please tee me!" | tee A B C ; cat A B C
317 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
318
319 # telnet - can't test: interactive
320
321 # test
322 # tftp
323
324 # touch
325 touch tmpfile1; ls tmpfile1; rm -f tmpfile1
326 touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
327
328 # tr
329 echo "cbaab" | tr abc zyx
330 echo "TESTING A B C" | tr [A-Z] [a-z]
331 # not GNU compatible
332 echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
333 echo abc[] | tr a[b AXB
334 echo testing | tr -d aeiou
335
336 # true
337 true ; echo $?
338
339 # false
340 false ; echo $?
341
342 # tty
343 # umount
344 # uname
345 # uniq
346 # unix2dos
347 # update
348
349 # uptime
350 uptime
351
352 # usleep
353 # uudecode
354 # uuencode
355 # watchdog
356
357 # wc
358 wc tester.sh
359 wc -c tester.sh
360 wc -w tester.sh
361 wc -l tester.sh
362 wc -L tester.sh
363
364 # wget
365
366 # which
367 which ls
368
369 # whoami
370 whoami
371
372 # xargs
373 ls -1 ../e* | xargs
374 ls -1 ../e* | xargs md5sum
375
376 # yes - can't test: interactive (needs ^C)