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 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 10 | HELPDUMP=`$COMMAND` |
| 11 | |
Rob Landley | 48c6157 | 2005-11-07 08:50:53 +0000 | [diff] [blame] | 12 | # We need to test under calling the binary under other names. |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 13 | |
| 14 | ln -s `which "$COMMAND"` busybox-suffix |
| 15 | ln -s `which "$COMMAND"` unknown |
| 16 | |
Rob Landley | f6acb66 | 2005-09-05 16:27:19 +0000 | [diff] [blame] | 17 | testing "busybox --help busybox" "--help busybox" "$HELPDUMP\n\n" "" "" |
| 18 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 19 | for i in busybox busybox-suffix |
| 20 | do |
| 21 | # The gratuitous "\n"s are due to a shell idiosyncrasy: |
| 22 | # environment variables seem to strip trailing whitespace. |
| 23 | |
| 24 | testing "$i" "" "$HELPDUMP\n\n" "" "" |
| 25 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 26 | testing "$i unknown" "unknown 2>&1" \ |
| 27 | "unknown: applet not found\n" "" "" |
| 28 | |
| 29 | testing "$i --help" "--help 2>&1" "$HELPDUMP\n\n" "" "" |
| 30 | |
Rob Landley | 48c6157 | 2005-11-07 08:50:53 +0000 | [diff] [blame] | 31 | optional CAT |
| 32 | testing "$i cat" "cat" "moo" "" "moo" |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 33 | testing "$i --help cat" "--help cat 2>&1 | grep prints" \ |
| 34 | "Concatenates FILE(s) and prints them to stdout.\n" "" "" |
Rob Landley | 48c6157 | 2005-11-07 08:50:53 +0000 | [diff] [blame] | 35 | optional "" |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 36 | |
| 37 | testing "$i --help unknown" "--help unknown 2>&1" \ |
| 38 | "unknown: applet not found\n" "" "" |
| 39 | |
| 40 | COMMAND=./busybox-suffix |
| 41 | done |
| 42 | |
| 43 | COMMAND="./unknown" |
| 44 | testing "busybox as unknown name" "2>&1" "unknown: applet not found\n" "" "" |
| 45 | |
| 46 | rm -f busybox-suffix unknown |
| 47 | |
Mike Frysinger | 23ca725 | 2006-02-22 23:38:57 +0000 | [diff] [blame^] | 48 | |
| 49 | # verify the applet order is correct in applets.h |
| 50 | # otherwise applets wont be called properly |
| 51 | sed -n \ |
| 52 | -e '/^\tAPPLET/{s:.*(::;s:,.*::;s:"::g;p}' \ |
| 53 | ../include/applets.h > applet.order.current |
| 54 | LC_ALL=C sort applet.order.current > applet.order.correct |
| 55 | diff -u applet.order.current applet.order.correct |
| 56 | FAILCOUNT=$[$FAILCOUNT+$?] |
| 57 | rm -f applet.order.current applet.order.correct |
| 58 | |
| 59 | |
Rob Landley | b766c39 | 2005-09-04 11:10:37 +0000 | [diff] [blame] | 60 | exit $FAILCOUNT |