blob: 4708e54e24454eb49129b0d4d5035c560ac0a83b [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
Glenn L McGrathf8736d22001-06-26 01:19:34 +0000295# rpm2cpio
296
Mark Whitleyd2117e92001-03-10 00:51:29 +0000297# rpmunpack
Mark Whitley336480f2001-05-14 21:18:54 +0000298
Mark Whitley0915c4b2001-06-11 23:50:06 +0000299# sed - we can do some one-liners here, some testing is a little
300# difficult to do in just this space (like a,i,c cmds).
301
302# test ^$ matching
Mark Whitley336480f2001-05-14 21:18:54 +0000303echo foo | sed -ne '/^$/p'
Mark Whitley0915c4b2001-06-11 23:50:06 +0000304echo -e "foo\\n\\nbar" | sed -ne '/^$/p'
305
Mark Whitley336480f2001-05-14 21:18:54 +0000306sed -e '/test$/d' testcases
307sed -e '/^echo/d' testcases
308sed -e '/test/s/dangerous/PELIGROSO/' testcases
Mark Whitley0915c4b2001-06-11 23:50:06 +0000309sed -ne '1,/getopt/p' ../pwd.c
310sed -e '/getopt/r ../pwd.c' ../sed.c
311
Mark Whitley336480f2001-05-14 21:18:54 +0000312
Mark Whitleyd2117e92001-03-10 00:51:29 +0000313# setkeycodes
Mark Whitley7384d7d2001-03-15 18:19:13 +0000314
315# sh - note that we cannot test the shell interactively here
316sh -c "echo a b c"
317sh -c ">"
318sh -c "a"
Mark Whitley4f6aea82001-05-24 23:05:13 +0000319sh sh.testcases
Mark Whitley04052f92001-05-24 17:15:33 +0000320
Mark Whitley7384d7d2001-03-15 18:19:13 +0000321
Mark Whitleyd2117e92001-03-10 00:51:29 +0000322# sleep - can't test: produces no output
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000323
Mark Whitleyd2117e92001-03-10 00:51:29 +0000324# sort
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000325sort tester.sh
326sort -n tester.sh
327sort -r tester.sh
328
Mark Whitleyd2117e92001-03-10 00:51:29 +0000329# stty
330# swapon - won't test: dangerous
331# swapoff - won't test: dangerous
332# sync - can't test: no output
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000333# syslogd - won't test: too involved
Mark Whitleyd2117e92001-03-10 00:51:29 +0000334
335# tail
336tail tester.sh
337tail -n 2 tester.sh
338
339# tar
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000340
Mark Whitleyd2117e92001-03-10 00:51:29 +0000341# tee
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000342echo "please tee me!" | tee A B C ; cat A B C
343echo "please tee me!" | tee A B C ; echo "tee me too!" | tee -a A B C ; cat A B C ; rm A B C
344
345# telnet - can't test: interactive
346
Mark Whitleyd2117e92001-03-10 00:51:29 +0000347# test
348# tftp
Mark Whitley04052f92001-05-24 17:15:33 +0000349
Mark Whitleyd2117e92001-03-10 00:51:29 +0000350# touch
Mark Whitley04052f92001-05-24 17:15:33 +0000351touch tmpfile1; ls tmpfile1; rm -f tmpfile1
352touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1
353
Mark Whitleyd2117e92001-03-10 00:51:29 +0000354# tr
Mark Whitley0a4f5782001-05-24 21:24:39 +0000355# BUG: Busybox tr range handling minix style [a-z] instead of GNU # style a-z
Mark Whitley04052f92001-05-24 17:15:33 +0000356echo "cbaab" | tr abc zyx
357echo "TESTING A B C" | tr [A-Z] [a-z]
358# not GNU compatible
359echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
360echo abc[] | tr a[b AXB
361echo testing | tr -d aeiou
362
363# true
Mark Whitleyd2117e92001-03-10 00:51:29 +0000364true ; echo $?
Mark Whitley04052f92001-05-24 17:15:33 +0000365
366# false
Mark Whitleyd2117e92001-03-10 00:51:29 +0000367false ; echo $?
Mark Whitley04052f92001-05-24 17:15:33 +0000368
Mark Whitleyd2117e92001-03-10 00:51:29 +0000369# tty
370# umount
371# uname
372# uniq
373# unix2dos
374# update
375
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000376# uptime
Mark Whitley0a4f5782001-05-24 21:24:39 +0000377# BUG: doesn't print number of users
Mark Whitleyd2117e92001-03-10 00:51:29 +0000378uptime
379
380# usleep
381# uudecode
382# uuencode
383# watchdog
384
385# wc
386wc tester.sh
387wc -c tester.sh
388wc -w tester.sh
389wc -l tester.sh
390wc -L tester.sh
391
392# wget
393
394# which
395which ls
396
397# whoami
398whoami
399
400# xargs
Mark Whitley0a4f5782001-05-24 21:24:39 +0000401# XXX: Busygox xargs divides filenames with '\n' instead of ' '
Mark Whitleyc75f83d2001-03-13 23:30:18 +0000402ls -1 ../e* | xargs
403ls -1 ../e* | xargs md5sum
Mark Whitleyd2117e92001-03-10 00:51:29 +0000404
405# yes - can't test: interactive (needs ^C)
Glenn L McGrathf8736d22001-06-26 01:19:34 +0000406