7595d061fdeaea9414b8c18a1842db6027745a78
[oweals/busybox.git] / testsuite / 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 if [ ${#COMMAND} -eq 0 ]; then COMMAND=busybox; fi
8 . testing.sh
9
10 # Depends on nothing
11 _BB_CONFIG_DEP=""
12
13 # We'll assume "cat" is built in, because we need some other command to test.
14
15 HELPDUMP=`$COMMAND`
16
17 # The gratuitous "\n"s are due to a shell idiosyncrasy: environment variables
18 # seem to strip trailing whitespace, which makes cmp and diff unhappy.
19
20 ln -s `which "$COMMAND"` busybox-suffix
21 ln -s `which "$COMMAND"` unknown
22
23 testing "busybox --help busybox" "--help busybox" "$HELPDUMP\n\n" "" ""
24
25 for i in busybox busybox-suffix
26 do
27         # The gratuitous "\n"s are due to a shell idiosyncrasy:
28         # environment variables seem to strip trailing whitespace.
29
30         testing "$i" "" "$HELPDUMP\n\n" "" ""
31
32         testing "$i cat" "cat" "moo" "" "moo"
33
34         testing "$i unknown" "unknown 2>&1" \
35                 "unknown: applet not found\n" "" ""
36
37         testing "$i --help" "--help 2>&1" "$HELPDUMP\n\n" "" ""
38
39         testing "$i --help cat" "--help cat 2>&1 | grep prints" \
40                 "Concatenates FILE(s) and prints them to stdout.\n" "" ""
41
42         testing "$i --help unknown" "--help unknown 2>&1" \
43                 "unknown: applet not found\n" "" ""
44
45         COMMAND=./busybox-suffix
46 done
47
48 COMMAND="./unknown"
49 testing "busybox as unknown name" "2>&1" "unknown: applet not found\n" "" ""
50
51 rm -f busybox-suffix unknown
52
53 exit $FAILCOUNT