Added some testcases for grep and sed (many more could still be added)
[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
34 # chmod
35 # chown
36 # chgrp
37 # chroot
38 # chvt - can't be tested here
39 # clear - can't be tested here
40 # cmp
41 # cp
42 # mv
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 # XXX: something's wrong with the way I'm doing these. Figure it out later.
106 #expr 1 \| 1
107 #expr 1 \| 0
108 #expr 0 \| 1
109 #expr 0 \| 0
110 #
111 #expr 1 \& 1
112 #expr 1 \& 0
113 #expr 0 \& 1
114 #expr 0 \& 0
115 #
116 #expr 0 \< 1
117 #expr 1 \< 0
118 #
119 #expr 1 \> 0
120 #expr 0 \> 1
121 #
122 #expr 0 \<= 1
123 #expr 1 \<= 0
124 #expr 1 \<= 1
125 #
126 #expr 1 \>= 0
127 #expr 0 \>= 1
128 #expr 1 \>= 1
129 #
130 #expr 1 + 2
131 #expr 2 - 1
132 #expr 2 \* 3
133 #expr 12 / 2
134 #expr 12 % 5
135
136 # somebody else can do all the string stuff
137
138
139 # fbset - can't be tested here
140 # fdflush
141 # find
142 find .
143
144 # free
145 free
146
147 # freeramdisk
148 # fsck.minix - won't test
149 # getopt
150
151 # grep
152 grep -l strdup ../*.c
153 grep -c strdup ../*.c
154 # I swear, GNU grep seems broken for this next one
155 grep -lc strdup ../*.c
156 grep -cv strdup ../*.c
157
158 # gunzip
159 # gzip
160 # halt
161
162 # head
163 head tester.sh
164 head -n 2 tester.sh
165
166 # hostid
167 hostid
168
169 # hostname
170 hostname
171 hostname -s
172 hostname -i
173 hostname -d
174 # not going to do this next one
175 #hostname -F
176
177 # id
178 id
179 id -u
180 id -g
181 id -ur
182 id -un
183
184
185 # ifconfig
186 #ifconfig
187 #ifconfig -a
188 #ifconfig eth0
189 #ifconfig lo
190
191 # init - won't test
192 # insmod - won't test
193
194 # kill
195 #kill -l
196 # not going to do any more
197
198 # length
199 # ln
200 # loadacm
201 # loadfont
202 # loadkmap
203 # logger
204 # logname
205
206 # ls
207 ls ../e*
208 ls -l ../e*
209 ls -s ../e*
210 ls -h ../e*
211 ls -1 ../e*
212
213 # lsmod
214 lsmod
215
216 # makedevs
217
218 # md5sum
219 md5sum tester.sh
220
221 # mkdir
222 mkdir D ; ls -ld D ; rmdir D
223
224 # mkfifo
225 #
226 # we will test making one. actually testing pushing data through it requires
227 # more interaction than we can manage here.
228 # (these lines turn up an existing ls bug)
229 mkfifo F ; ls -l F ; rm F
230 mkfifo -m 0600 F ; ls -l F ; rm F
231
232 # mkfs.minix - won't test
233 # mknod
234 # mkswap - won't test
235 # mktemp
236 # more - can't test: interactive
237
238 # mount
239 mount
240 # not going to test any more
241
242 # mt
243 # nc
244 # nfsmount
245 # nslookup
246 # ping
247 ping -c 3 yahoo.com
248 # pivot_root
249 # poweroff - won't test
250 # printf
251 # ps - there's lotsa differences between busybox ps and any other ps
252
253 # pwd
254 pwd
255
256 # rdate - won't test
257
258 # readlink
259 ln -sf tester.sh L ; readlink L ; rm -f L
260
261 # reboot - won't test
262 # renice - won't test
263 # reset - can't test: no output
264
265 # rm
266 touch F ; rm F
267
268 # rmdir
269 # rmmod - won't test: dangerous
270 # route
271 # rpmunpack
272
273 # sed - we can do some one-liners here; probably needs it's own input file
274 echo foo | sed -ne '/^$/p'
275 sed -e '/test$/d' testcases
276 sed -e '/^echo/d' testcases
277 sed -e '/test/s/dangerous/PELIGROSO/' testcases
278
279 # setkeycodes
280
281 # sh - note that we cannot test the shell interactively here
282 sh -c "echo a b c"
283 sh -c ">"
284 sh -c "a"
285
286 # sleep - can't test: produces no output
287
288 # sort
289 sort tester.sh
290 sort -n tester.sh
291 sort -r tester.sh
292
293 # stty
294 # swapon - won't test: dangerous
295 # swapoff - won't test: dangerous
296 # sync - can't test: no output
297 # syslogd - won't test: too involved
298
299 # tail
300 tail tester.sh
301 tail -n 2  tester.sh
302
303 # tar
304
305 # tee
306 echo "please tee me!" | tee A B C ; cat A B C
307 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
308
309 # telnet - can't test: interactive
310
311 # test
312 # tftp
313 # touch
314 # tr
315 true ; echo $?
316 false ; echo $?
317 # tty
318 # umount
319 # uname
320 # uniq
321 # unix2dos
322 # update
323
324 # uptime
325 uptime
326
327 # usleep
328 # uudecode
329 # uuencode
330 # watchdog
331
332 # wc
333 wc tester.sh
334 wc -c tester.sh
335 wc -w tester.sh
336 wc -l tester.sh
337 wc -L tester.sh
338
339 # wget
340
341 # which
342 which ls
343
344 # whoami
345 whoami
346
347 # xargs
348 ls -1 ../e* | xargs
349 ls -1 ../e* | xargs md5sum
350
351 # yes - can't test: interactive (needs ^C)