30d96f946664e34b34ca26101226ca47e03b2366
[oweals/busybox.git] / busybox.tests
1 #!/bin/sh
2
3 # Tests for busybox applet itself.
4 # Copyright 2005 by Rob Landley <rob@landley.net>
5 # Licensed under GPL v2, see file LICENSE for details.
6
7 . testing.sh
8
9 # verify the applet order is correct in applets.h, otherwise applets won't
10 # be called properly.
11 #sed -n -e '/^USE_^\tAPPLET/{s:.*(::;s:,.*::;s:"::g;p}' 
12 #       ../include/applets.h > applet.order1
13 #LC_ALL=C sort applet.order.current > applet.order.correct
14 #diff -u applet.order.current applet.order.correct
15 #FAILCOUNT=$[$FAILCOUNT+$?]
16 #rm -f applet.order.current applet.order.correct
17
18
19
20
21 HELPDUMP=`busybox`
22
23 # We need to test under calling the binary under other names.
24
25
26 testing "busybox --help busybox" "busybox --help busybox" "$HELPDUMP\n\n" "" ""
27
28 ln -s `which busybox` busybox-suffix
29 for i in busybox ./busybox-suffix
30 do
31         # The gratuitous "\n"s are due to a shell idiosyncrasy:
32         # environment variables seem to strip trailing whitespace.
33
34         testing "" "$i" "$HELPDUMP\n\n" "" ""
35
36         testing "$i unknown" "$i unknown 2>&1" \
37                 "unknown: applet not found\n" "" ""
38
39         testing "$i --help" "$i --help 2>&1" "$HELPDUMP\n\n" "" ""
40
41         optional CAT
42         testing "" "$i cat" "moo" "" "moo"
43         testing "$i --help cat" "$i --help cat 2>&1 | grep prints" \
44                 "Concatenates FILE(s) and prints them to stdout.\n" "" ""
45         optional ""
46
47         testing "$i --help unknown" "$i --help unknown 2>&1" \
48                 "unknown: applet not found\n" "" ""
49 done
50 rm busybox-suffix
51
52 ln -s `which busybox` unknown
53
54 testing "busybox as unknown name" "./unknown 2>&1" \
55         "unknown: applet not found\n" "" ""
56 rm unknown
57
58 exit $FAILCOUNT