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.
7 if [ ${#COMMAND} -eq 0 ]; then COMMAND=busybox; fi
10 # We'll assume "cat" is built in, because we need some other command to test.
14 # The gratuitous "\n"s are due to a shell idiosyncrasy: environment variables
15 # seem to strip trailing whitespace, which makes cmp and diff unhappy.
17 ln -s `which "$COMMAND"` busybox-suffix
18 ln -s `which "$COMMAND"` unknown
20 for i in busybox busybox-suffix
22 # The gratuitous "\n"s are due to a shell idiosyncrasy:
23 # environment variables seem to strip trailing whitespace.
25 testing "$i" "" "$HELPDUMP\n\n" "" ""
27 testing "$i cat" "cat" "moo" "" "moo"
29 testing "$i unknown" "unknown 2>&1" \
30 "unknown: applet not found\n" "" ""
32 testing "$i --help" "--help 2>&1" "$HELPDUMP\n\n" "" ""
34 testing "$i --help cat" "--help cat 2>&1 | grep prints" \
35 "Concatenates FILE(s) and prints them to stdout.\n" "" ""
37 testing "$i --help unknown" "--help unknown 2>&1" \
38 "unknown: applet not found\n" "" ""
40 COMMAND=./busybox-suffix
44 testing "busybox as unknown name" "2>&1" "unknown: applet not found\n" "" ""
46 rm -f busybox-suffix unknown
50 General cleanup of command line parsing to allow "busybox" to work as a prefix.
51 (I.E. any argv[0] that starts with "busybox" winds up in busybox_main().)
59 ./busybox-walrus --help
61 ./busybox-walrus --help ls
62 ./busybox --help walrus
63 ./busybox-walrus --help walrus
73 # These tests require the full option set.
75 # Longish chunk of data re-used by the next few tests
86 testing "sort one key" "-k4,4 input" \
94 testing "sort key range with numeric option" "-k2,3n input" \
102 # Busybox is definitely doing this one wrong just now...
104 testing "sort key range with numeric option and global reverse" \
115 testing "sort key range with multiple options" "-k2,3rn input" \