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 | |
| 10 | # We'll assume "cat" is built in, because we need some other command to test. |
| 11 | |
| 12 | HELPDUMP=`$COMMAND` |
| 13 | |
| 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. |
| 16 | |
| 17 | ln -s `which "$COMMAND"` busybox-suffix |
| 18 | ln -s `which "$COMMAND"` unknown |
| 19 | |
Rob Landley | f6acb66 | 2005-09-05 16:27:19 +0000 | [diff] [blame] | 20 | testing "busybox --help busybox" "--help busybox" "$HELPDUMP\n\n" "" "" |
| 21 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 22 | for i in busybox busybox-suffix |
| 23 | do |
| 24 | # The gratuitous "\n"s are due to a shell idiosyncrasy: |
| 25 | # environment variables seem to strip trailing whitespace. |
| 26 | |
| 27 | testing "$i" "" "$HELPDUMP\n\n" "" "" |
| 28 | |
| 29 | testing "$i cat" "cat" "moo" "" "moo" |
| 30 | |
| 31 | testing "$i unknown" "unknown 2>&1" \ |
| 32 | "unknown: applet not found\n" "" "" |
| 33 | |
| 34 | testing "$i --help" "--help 2>&1" "$HELPDUMP\n\n" "" "" |
| 35 | |
| 36 | testing "$i --help cat" "--help cat 2>&1 | grep prints" \ |
| 37 | "Concatenates FILE(s) and prints them to stdout.\n" "" "" |
| 38 | |
| 39 | testing "$i --help unknown" "--help unknown 2>&1" \ |
| 40 | "unknown: applet not found\n" "" "" |
| 41 | |
| 42 | COMMAND=./busybox-suffix |
| 43 | done |
| 44 | |
| 45 | COMMAND="./unknown" |
| 46 | testing "busybox as unknown name" "2>&1" "unknown: applet not found\n" "" "" |
| 47 | |
| 48 | rm -f busybox-suffix unknown |
| 49 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 50 | exit $FAILCOUNT |