aboutsummaryrefslogtreecommitdiff
path: root/tests/testcases
blob: 37e7412605c9760bb2a33dfc26925ac630bcdd9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# testcases
#
# This file should be filled with test cases to test applets that:
#
#  - can somehow produce output (we can't test sync or sleep)
#  - have a GNU (or other) counterpart
#  - are not interactive (don't require a ^C or anything)
#  - don't require extensive setup or cleanup (a litte setup is fine)
#  - don't have huge and possibly damaging effects (fsck, swapoff)
#
# If possible, a test case should be made that tests each option the applet
# supports. When a new option is added, a new test case should be written for
# it. When somebody reports a bug with a testcase, that testcase should be
# added here as well.
#
# Some other guidelines to follow:
#
#  - please try to keep applets alphabetized, it will make life easier
#  - use the file tester.sh or testcases when you need to do a non-destructive
#    test on a file (i.e., cat, md5sum)
#  - try to make the applet you're testing the first thing on the line (this
#    not always possible)
#  - (???) if you have to create a temporary file, call it TMPFILE
#  - pipe symbols that represent real pipes need a space in front of them
#     (so the test script can find them and add the "../busybox" after it).
#  - pipe symbols that are not used for pipes need to be shell-escaped,
#     with a double \.  See the expr test cases.


# ar

# basename
basename `pwd`

# cat
cat tester.sh
echo hello there | cat tester.sh -

# chmod
# chown
# chgrp
# chroot
# chvt - can't be tested here
# clear - can't be tested here
# cmp
# cp

# cut
echo "1234" | cut -c1
echo "1234" | cut -c 1
echo "1234567890" | cut -c2-7
echo "1234567890" | cut -c 2-7
echo "f1	f2" | cut -f2
echo "f1	f2" | cut -f 2
echo "f1	f2	f3	f4	f5" | cut -f2-4
echo "f1	f2	f3	f4	f5" | cut -f 2-4

# date
date
date -R
date -u
date +%d/%m/%y

# dc - needs an input file

# dd
# BUG: record count line goes to stdout instead of stderr
dd if=/dev/urandom of=O bs=1k count=1 ; ls -l O ; rm O

# deallocvt

# df
# XXX: minor formatting differences
df
df .
df -k
df -h
df -m

# dirname
dirname `pwd`

# dmesg (XXX: change the silly cmd business in the source)
dmesg
dmesg -n 8
dmesg -s 512
# I really don't want to do this next one
#dmesg -c

# dos2unix - needs an input file
# dpkg
# dpkg_deb

# du
# BUG: rounding behavior differs from GNU du
du
du -s
du -l
du -k
du -h
du -m

# dumpkmap - no counterprt?
# dutmp - no counterprt?

# echo
echo "foo bar baz"
echo -n "no newline"


# expr
expr 1 \\| 1
expr 1 \\| 0
expr 0 \\| 1
expr 0 \\| 0

expr 1 \\& 1
expr 1 \\& 0
expr 0 \\& 1
expr 0 \\& 0

expr 0 \\< 1
expr 1 \\< 0

expr 1 \\> 0
expr 0 \\> 1

expr 0 \\<= 1
expr 1 \\<= 0
expr 1 \\<= 1

expr 1 \\>= 0
expr 0 \\>= 1
expr 1 \\>= 1

expr 1 + 2
expr 2 - 1
expr 2 \\* 3
expr 12 / 2
expr 12 % 5

# somebody else can do all the string stuff


# fbset - can't be tested here
# fdflush
# find
find .

# free
# XXX: minor formatting differences
free

# freeramdisk
# fsck.minix - won't test
# getopt

# grep
grep -l strdup ../*utils/*.c
grep -c strdup ../*utils/*.c
grep -lc strdup ../*utils/*.c
grep -cv strdup ../*utils/*.c
grep -i null ../findutils/grep.c
grep -e strdup -e regcomp -e atexit ../findutils/grep.c

# gunzip

# gzip
# XXX: compressed output differs from gzip-1.2.4, but decompresses fine
echo testing 1 2 3 >tmpfile1; gzip tmpfile1; echo tmpfile*; md5sum tmpfile1.gz; rm tmpfile1.gz
echo testing 1 2 3 | gzip >tmpfile1.gz; md5sum tmpfile1.gz; rm tmpfile1.gz


# halt - won't test, dangerous

# head
head tester.sh
head -n 2 tester.sh

# hostid
hostid

# hostname
# XXX: minor formatting differences
hostname
hostname -s
hostname -i
hostname -d
# not going to do this next one
#hostname -F

# id
# BUG: Busybox id doesn't print supplemental groups
id
id -u
id -g
id -ur
id -un


# ifconfig
# requires CONFIG_FEATURE_IFCONFIG_STATUS
ifconfig
#ifconfig -a
#ifconfig eth0
#ifconfig lo

# init - won't test
# insmod - won't test

# kill
#kill -l
# not going to do any more

# length
# ln - see ln_tests.mk
# loadacm
# loadfont
# loadkmap
# logger
# logname

# ls
# XXX: minor formatting differences
ls ../e*
ls -l ../e*
ls -s ../e*
ls -h ../e*
ls -1 ../e*

# lsmod
lsmod

# makedevs

# md5sum
md5sum tester.sh

# mkdir
mkdir D ; ls -ld D ; rmdir D

# mkfifo
#
# we will test making one. actually testing pushing data through it requires
# more interaction than we can manage here.
# (these lines turn up an existing ls bug)
mkfifo F ; ls -l F ; rm F
mkfifo -m 0600 F ; ls -l F ; rm F

# mkfs.minix - won't test
# mknod
# mkswap - won't test
# mktemp
# more - can't test: interactive

# mount
# BUG: proc line starts with /proc instead of proc
mount
# not going to test mount with any args, can't be done safely or sanely

# mt
# mv - see mv_tests.mk
# nc
# nfsmount
# nslookup
# ping
ping -c 3 yahoo.com
# pivot_root
# poweroff - won't test
# printf
# ps - there's lotsa differences between busybox ps and any other ps

# pwd
pwd

# rdate - won't test

# readlink
ln -sf tester.sh L ; readlink L ; rm -f L

# reboot - won't test
# renice - won't test
# reset - can't test: no output

# rm
touch F ; rm F

# rmdir
# rmmod - won't test: dangerous

# route
# XXX: doesn't DNS resolve
route

# rpm2cpio

# sed - we can do some one-liners here, some testing is a little
# difficult to do in just this space (like a,i,c cmds).

# test ^$ matching
echo foo | sed -ne '/^$/p'
echo -e "foo\\n\\nbar" | sed -ne '/^$/p'

sed -e '/test$/d' testcases
sed -e '/^echo/d' testcases
sed -e '/test/s/dangerous/PELIGROSO/' testcases
sed -ne '1,/getopt/p' ../shellutils/pwd.c
sed -e '/getopt/r ../shellutils/pwd.c' ../editors/sed.c


# setkeycodes

# sh - note that we cannot test the shell interactively here
sh -c "echo a b c"
sh -c ">"
sh -c "a"
sh sh.testcases


# sleep - can't test: produces no output

# sort
sort tester.sh
sort -n tester.sh
sort -r tester.sh

# stty
# swapon - won't test: dangerous
# swapoff - won't test: dangerous
# sync - can't test: no output
# syslogd - won't test: too involved

# tail
tail tester.sh
tail -n 2  tester.sh

# tar

# tee
echo "please tee me!" | tee A B C ; cat A B C
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

# telnet - can't test: interactive

# test
# tftp

# touch
touch tmpfile1; ls tmpfile1; rm -f tmpfile1
touch -c tmpfile1; ls tmpfile1; rm -f tmpfile1

# tr
# BUG: Busybox tr range handling minix style [a-z] instead of GNU # style a-z
echo "cbaab" | tr abc zyx
echo "TESTING A B C" | tr [A-Z] [a-z]
# not GNU compatible
echo fdhrnzvfu bffvsentr | tr [a-z] [n-z][a-m]
echo abc[] | tr a[b AXB
echo testing | tr -d aeiou

# true
true ; echo $?

# false
false ; echo $?

# tty
# umount
# uname
# uniq
# unix2dos
# update

# uptime
# BUG: doesn't print number of users
uptime

# usleep
# uudecode
# uuencode
# watchdog

# wc
wc tester.sh
wc -c tester.sh
wc -w tester.sh
wc -l tester.sh
wc -L tester.sh

# wget

# which
which ls

# whoami
whoami

# xargs
# XXX: Busygox xargs divides filenames with '\n' instead of ' '
ls -1 ../e* | xargs
ls -1 ../e* | xargs md5sum

# yes - can't test: interactive (needs ^C)