blob: a38d317707760c887936ae0a34c9d22d36f7b270 [file] [log] [blame]
Mark Whitleyd2117e92001-03-10 00:51:29 +00001# 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
Eric Andersen77d92682001-05-23 20:32:09 +000020# test on a file (i.e., cat, md5sum)
Mark Whitleyd2117e92001-03-10 00:51:29 +000021# - 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
Mark Whitley0a4f5782001-05-24 21:24:39 +000024# - pipe symbols that represent real pipes need a space in front of them
25# (so the test script can find them and add the "../busybox" after it).
26# - pipe symbols that are not used for pipes need to be shell-escaped,
27# with a double \. See the expr test cases.
Mark Whitleyd2117e92001-03-10 00:51:29 +000028
29
30# ar
31
32# basename
33basename `pwd`
34
35# cat
36cat tester.sh
Mark Whitley04052f92001-05-24 17:15:33 +000037echo hello there | cat tester.sh -
Mark Whitleyd2117e92001-03-10 00:51:29 +000038
39# chmod
40# chown
41# chgrp
42# chroot
43# chvt - can't be tested here
44# clear - can't be tested here
45# cmp
46# cp
Mark Whitleyd2117e92001-03-10 00:51:29 +000047
48# cut
49echo "1234" | cut -c1
Mark Whitleycc7b4f32001-03-27 20:48:01 +000050echo "1234" | cut -c 1
51echo "1234567890" | cut -c2-7
52echo "1234567890" | cut -c 2-7
Mark Whitleyd2117e92001-03-10 00:51:29 +000053echo "f1 f2" | cut -f2
Mark Whitleycc7b4f32001-03-27 20:48:01 +000054echo "f1 f2" | cut -f 2
55echo "f1 f2 f3 f4 f5" | cut -f2-4
56echo "f1 f2 f3 f4 f5" | cut -f 2-4
Mark Whitleyd2117e92001-03-10 00:51:29 +000057
58# date
59date
60date -R
61date -u
62date +%d/%m/%y
63
64# dc - needs an input file
Mark Whitleyc75f83d2001-03-13 23:30:18 +000065
Mark Whitleyd2117e92001-03-10 00:51:29 +000066# dd
Mark Whitley0a4f5782001-05-24 21:24:39 +000067# BUG: record count line goes to stdout instead of stderr
Mark Whitleyc75f83d2001-03-13 23:30:18 +000068dd if=/dev/urandom of=O bs=1k count=1 ; ls -l O ; rm O
69
Mark Whitleyd2117e92001-03-10 00:51:29 +000070# deallocvt
71
72# df
Mark Whitley0a4f5782001-05-24 21:24:39 +000073# XXX: minor formatting differences
Mark Whitleyd2117e92001-03-10 00:51:29 +000074df
75df .
76df -k
77df -h
78df -m
79
80# dirname
81dirname `pwd`
82
83# dmesg (XXX: change the silly cmd business in the source)
84dmesg
85dmesg -n 8
86dmesg -s 512
87# I really don't want to do this next one
88#dmesg -c
89
90# dos2unix - needs an input file
91# dpkg
92# dpkg_deb
93
94# du
Mark Whitley0a4f5782001-05-24 21:24:39 +000095# BUG: rounding behavior differs from GNU du
Mark Whitleyd2117e92001-03-10 00:51:29 +000096du
97du -s
98du -l
99du -k
100du -h
101du -m
102
103# dumpkmap - no counterprt?
104# dutmp - no counterprt?
105
106# echo
107echo "foo bar baz"
108echo -n "no newline"
109
110
111# expr
Mark Whitley04052f92001-05-24 17:15:33 +0000112expr 1 \\| 1
113expr 1 \\| 0
114expr 0 \\| 1
115expr 0 \\| 0
116
117expr 1 \\& 1
118expr 1 \\& 0
119expr 0 \\& 1
120expr 0 \\& 0
121
122expr 0 \\< 1
123expr 1 \\< 0
124
125expr 1 \\> 0
126expr 0 \\> 1
127
128expr 0 \\<= 1
129expr 1 \\<= 0
130expr 1 \\<= 1
131
132expr 1 \\>= 0
133expr 0 \\>= 1
134expr 1 \\>= 1
135
136expr 1 + 2
137expr 2 - 1
138expr 2 \\* 3
139expr 12 / 2
140expr 12 % 5
Mark Whitleyd2117e92001-03-10 00:51:29 +0000141
142# somebody else can do all the string stuff
143
144
145# fbset - can't be tested here
146# fdflush
147# find
148find .
149
150# free
Mark Whitley0a4f5782001-05-24 21:24:39 +0000151# XXX: minor formatting differences
Mark Whitleyd2117e92001-03-10 00:51:29 +0000152free
153
154# freeramdisk
155# fsck.minix - won't test
156# getopt
Mark Whitley336480f2001-05-14 21:18:54 +0000157
Mark Whitleyd2117e92001-03-10 00:51:29 +0000158# grep
Mark Whitley336480f2001-05-14 21:18:54 +0000159grep -l strdup ../*.c
160grep -c strdup ../*.c
Mark Whitley336480f2001-05-14 21:18:54 +0000161grep -lc strdup ../*.c
162grep -cv strdup ../*.c
Mark Whitleyfa43e542001-05-24 18:36:18 +0000163grep -i null ../grep.c
164grep -e strdup -e regcomp -e atexit ../grep.c
Mark Whitley336480f2001-05-14 21:18:54 +0000165
Mark Whitleyd2117e92001-03-10 00:51:29 +0000166# gunzip
Mark Whitley04052f92001-05-24 17:15:33 +0000167
Mark Whitleyd2117e92001-03-10 00:51:29 +0000168# gzip
Mark Whitley0a4f5782001-05-24 21:24:39 +0000169# XXX: compressed output differs from gzip-1.2.4, but decompresses fine
Mark Whitley04052f92001-05-24 17:15:33 +0000170echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
171echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz
Mark Whitley0a4f5782001-05-24 21:24:39 +0000172
173
174# halt - won't test, dangerous
Mark Whitleyd2117e92001-03-10 00:51:29 +0000175
176# head
177head tester.sh
178head -n 2 tester.sh
179
180# hostid
181hostid
182
183# hostname
Mark Whitley0a4f5782001-05-24 21:24:39 +0000184# XXX: minor formatting differences
Mark Whitleyd2117e92001-03-10 00:51:29 +0000185hostname
186hostname -s
187hostname -i
188hostname -d
189# not going to do this next one
190#hostname -F
191
192# id
Mark Whitley0a4f5782001-05-24 21:24:39 +0000193# BUG: Busybox id doesn't print supplemental groups
Mark Whitleyd2117e92001-03-10 00:51:29 +0000194id
195id -u
196id -g
197id -ur
198id -un
199
200
201# ifconfig
Mark Whitley04052f92001-05-24 17:15:33 +0000202# requires BB_FEATURE_IFCONFIG_STATUS
203ifconfig
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000204#ifconfig -a
Mark Whitleyd2117e92001-03-10 00:51:29 +0000205#ifconfig eth0
206#ifconfig lo
207
208# init - won't test
209# insmod - won't test
210
211# kill
212#kill -l
213# not going to do any more
214
215# length
Mark Whitley04052f92001-05-24 17:15:33 +0000216# ln - see ln_tests.mk
Mark Whitleyd2117e92001-03-10 00:51:29 +0000217# loadacm
218# loadfont
219# loadkmap
220# logger
221# logname
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000222
Mark Whitleyd2117e92001-03-10 00:51:29 +0000223# ls
Mark Whitley0a4f5782001-05-24 21:24:39 +0000224# XXX: minor formatting differences
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000225ls ../e*
226ls -l ../e*
227ls -s ../e*
228ls -h ../e*
229ls -1 ../e*
Mark Whitleyd2117e92001-03-10 00:51:29 +0000230
231# lsmod
232lsmod
233
234# makedevs
235
236# md5sum
237md5sum tester.sh
238
239# mkdir
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000240mkdir D ; ls -ld D ; rmdir D
241
Mark Whitleyd2117e92001-03-10 00:51:29 +0000242# mkfifo
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000243#
244# we will test making one. actually testing pushing data through it requires
245# more interaction than we can manage here.
246# (these lines turn up an existing ls bug)
247mkfifo F ; ls -l F ; rm F
248mkfifo -m 0600 F ; ls -l F ; rm F
249
Mark Whitleyd2117e92001-03-10 00:51:29 +0000250# mkfs.minix - won't test
251# mknod
252# mkswap - won't test
253# mktemp
254# more - can't test: interactive
255
256# mount
Mark Whitley0a4f5782001-05-24 21:24:39 +0000257# BUG: proc line starts with /proc instead of proc
Mark Whitleyd2117e92001-03-10 00:51:29 +0000258mount
Mark Whitley0a4f5782001-05-24 21:24:39 +0000259# not going to test mount with any args, can't be done safely or sanely
Mark Whitleyd2117e92001-03-10 00:51:29 +0000260
261# mt
Mark Whitley04052f92001-05-24 17:15:33 +0000262# mv - see mv_tests.mk
Mark Whitleyd2117e92001-03-10 00:51:29 +0000263# nc
264# nfsmount
265# nslookup
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000266# ping
267ping -c 3 yahoo.com
Mark Whitleyd2117e92001-03-10 00:51:29 +0000268# pivot_root
269# poweroff - won't test
270# printf
271# ps - there's lotsa differences between busybox ps and any other ps
272
273# pwd
274pwd
275
276# rdate - won't test
277
278# readlink
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000279ln -sf tester.sh L ; readlink L ; rm -f L
Mark Whitleyd2117e92001-03-10 00:51:29 +0000280
281# reboot - won't test
282# renice - won't test
283# reset - can't test: no output
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000284
Mark Whitleyd2117e92001-03-10 00:51:29 +0000285# rm
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000286touch F ; rm F
287
Mark Whitleyd2117e92001-03-10 00:51:29 +0000288# rmdir
289# rmmod - won't test: dangerous
Mark Whitley04052f92001-05-24 17:15:33 +0000290
Mark Whitleyd2117e92001-03-10 00:51:29 +0000291# route
Mark Whitley0a4f5782001-05-24 21:24:39 +0000292# XXX: doesn't DNS resolve
Mark Whitley04052f92001-05-24 17:15:33 +0000293route
294
Mark Whitleyd2117e92001-03-10 00:51:29 +0000295# rpmunpack
Mark Whitley336480f2001-05-14 21:18:54 +0000296
Mark Whitley0915c4b2001-06-11 23:50:06 +0000297# sed - we can do some one-liners here, some testing is a little
298# difficult to do in just this space (like a,i,c cmds).
299
300# test ^$ matching
Mark Whitley336480f2001-05-14 21:18:54 +0000301echo foo | sed -ne '/^$/p'
Mark Whitley0915c4b2001-06-11 23:50:06 +0000302echo -e "foo\\n\\nbar" | sed -ne '/^$/p'
303
Mark Whitley336480f2001-05-14 21:18:54 +0000304sed -e '/test$/d' testcases
305sed -e '/^echo/d' testcases
306sed -e '/test/s/dangerous/PELIGROSO/' testcases
Mark Whitley0915c4b2001-06-11 23:50:06 +0000307sed -ne '1,/getopt/p' ../pwd.c
308sed -e '/getopt/r ../pwd.c' ../sed.c
309
Mark Whitley336480f2001-05-14 21:18:54 +0000310
Mark Whitleyd2117e92001-03-10 00:51:29 +0000311# setkeycodes
Mark Whitley7384d7d2001-03-15 18:19:13 +0000312
313# sh - note that we cannot test the shell interactively here
314sh -c "echo a b c"
315sh -c ">"
316sh -c "a"
Mark Whitley4f6aea82001-05-24 23:05:13 +0000317sh sh.testcases
Mark Whitley04052f92001-05-24 17:15:33 +0000318
Mark Whitley7384d7d2001-03-15 18:19:13 +0000319
Mark Whitleyd2117e92001-03-10 00:51:29 +0000320# sleep - can't test: produces no output
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000321
Mark Whitleyd2117e92001-03-10 00:51:29 +0000322# sort
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000323sort tester.sh
324sort -n tester.sh
325sort -r tester.sh
326
Mark Whitleyd2117e92001-03-10 00:51:29 +0000327# stty
328# swapon - won't test: dangerous
329# swapoff - won't test: dangerous
330# sync - can't test: no output
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000331# syslogd - won't test: too involved
Mark Whitleyd2117e92001-03-10 00:51:29 +0000332
333# tail
334tail tester.sh
335tail -n 2 tester.sh
336
337# tar
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000338
Mark Whitleyd2117e92001-03-10 00:51:29 +0000339# tee
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000340echo "please tee me!" | tee A B C ; cat A B C
341echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B C ; rm A B C
342
343# telnet - can't test: interactive
344
Mark Whitleyd2117e92001-03-10 00:51:29 +0000345# test
346# tftp
Mark Whitley04052f92001-05-24 17:15:33 +0000347
Mark Whitleyd2117e92001-03-10 00:51:29 +0000348# touch
Mark Whitley04052f92001-05-24 17:15:33 +0000349touch tmpfile1; ls tmpfile1; rm -f tmpfile1
350touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
351
Mark Whitleyd2117e92001-03-10 00:51:29 +0000352# tr
Mark Whitley0a4f5782001-05-24 21:24:39 +0000353# BUG: Busybox tr range handling minix style [a-z] instead of GNU # style a-z
Mark Whitley04052f92001-05-24 17:15:33 +0000354echo "cbaab" | tr abc zyx
355echo "TESTING A B C" | tr [A-Z] [a-z]
356# not GNU compatible
357echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
358echo abc[] | tr a[b AXB
359echo testing | tr -d aeiou
360
361# true
Mark Whitleyd2117e92001-03-10 00:51:29 +0000362true ; echo $?
Mark Whitley04052f92001-05-24 17:15:33 +0000363
364# false
Mark Whitleyd2117e92001-03-10 00:51:29 +0000365false ; echo $?
Mark Whitley04052f92001-05-24 17:15:33 +0000366
Mark Whitleyd2117e92001-03-10 00:51:29 +0000367# tty
368# umount
369# uname
370# uniq
371# unix2dos
372# update
373
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000374# uptime
Mark Whitley0a4f5782001-05-24 21:24:39 +0000375# BUG: doesn't print number of users
Mark Whitleyd2117e92001-03-10 00:51:29 +0000376uptime
377
378# usleep
379# uudecode
380# uuencode
381# watchdog
382
383# wc
384wc tester.sh
385wc -c tester.sh
386wc -w tester.sh
387wc -l tester.sh
388wc -L tester.sh
389
390# wget
391
392# which
393which ls
394
395# whoami
396whoami
397
398# xargs
Mark Whitley0a4f5782001-05-24 21:24:39 +0000399# XXX: Busygox xargs divides filenames with '\n' instead of ' '
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000400ls -1 ../e* | xargs
401ls -1 ../e* | xargs md5sum
Mark Whitleyd2117e92001-03-10 00:51:29 +0000402
403# yes - can't test: interactive (needs ^C)