Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 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 | |
Bernhard Reutner-Fischer | b47a74f | 2005-09-23 15:44:46 +0000 | [diff] [blame] | 10 | # Depends on nothing |
| 11 | _BB_CONFIG_DEP="" |
| 12 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 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 | |
Rob Landley | f6acb66 | 2005-09-05 16:27:19 +0000 | [diff] [blame] | 23 | testing "busybox --help busybox" "--help busybox" "$HELPDUMP\n\n" "" "" |
| 24 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 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 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 53 | exit $FAILCOUNT |