blob: 30d96f946664e34b34ca26101226ca47e03b2366 [file] [log] [blame]
Rob Landleyb766c392005-09-04 11:10:37 +00001#!/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
Rob Landleyb766c392005-09-04 11:10:37 +00007. testing.sh
8
Rob Landley4bb1b042006-03-16 15:20:45 +00009# verify the applet order is correct in applets.h, otherwise applets won't
10# be called properly.
11#sed -n -e '/^USE_^\tAPPLET/{s:.*(::;s:,.*::;s:"::g;p}'
12# ../include/applets.h > applet.order1
13#LC_ALL=C sort applet.order.current > applet.order.correct
14#diff -u applet.order.current applet.order.correct
15#FAILCOUNT=$[$FAILCOUNT+$?]
16#rm -f applet.order.current applet.order.correct
17
18
19
20
21HELPDUMP=`busybox`
Rob Landleyb766c392005-09-04 11:10:37 +000022
Rob Landley48c61572005-11-07 08:50:53 +000023# We need to test under calling the binary under other names.
Rob Landleyb766c392005-09-04 11:10:37 +000024
Rob Landleyb766c392005-09-04 11:10:37 +000025
Rob Landley4bb1b042006-03-16 15:20:45 +000026testing "busybox --help busybox" "busybox --help busybox" "$HELPDUMP\n\n" "" ""
Rob Landleyf6acb662005-09-05 16:27:19 +000027
Rob Landley4bb1b042006-03-16 15:20:45 +000028ln -s `which busybox` busybox-suffix
29for i in busybox ./busybox-suffix
Rob Landleyb766c392005-09-04 11:10:37 +000030do
31 # The gratuitous "\n"s are due to a shell idiosyncrasy:
32 # environment variables seem to strip trailing whitespace.
33
Rob Landley4bb1b042006-03-16 15:20:45 +000034 testing "" "$i" "$HELPDUMP\n\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000035
Rob Landley4bb1b042006-03-16 15:20:45 +000036 testing "$i unknown" "$i unknown 2>&1" \
Rob Landleyb766c392005-09-04 11:10:37 +000037 "unknown: applet not found\n" "" ""
38
Rob Landley4bb1b042006-03-16 15:20:45 +000039 testing "$i --help" "$i --help 2>&1" "$HELPDUMP\n\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000040
Rob Landley48c61572005-11-07 08:50:53 +000041 optional CAT
Rob Landley4bb1b042006-03-16 15:20:45 +000042 testing "" "$i cat" "moo" "" "moo"
43 testing "$i --help cat" "$i --help cat 2>&1 | grep prints" \
Rob Landleyb766c392005-09-04 11:10:37 +000044 "Concatenates FILE(s) and prints them to stdout.\n" "" ""
Rob Landley48c61572005-11-07 08:50:53 +000045 optional ""
Rob Landleyb766c392005-09-04 11:10:37 +000046
Rob Landley4bb1b042006-03-16 15:20:45 +000047 testing "$i --help unknown" "$i --help unknown 2>&1" \
Rob Landleyb766c392005-09-04 11:10:37 +000048 "unknown: applet not found\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000049done
Rob Landley4bb1b042006-03-16 15:20:45 +000050rm busybox-suffix
Rob Landleyb766c392005-09-04 11:10:37 +000051
Rob Landley4bb1b042006-03-16 15:20:45 +000052ln -s `which busybox` unknown
Rob Landleyb766c392005-09-04 11:10:37 +000053
Rob Landley4bb1b042006-03-16 15:20:45 +000054testing "busybox as unknown name" "./unknown 2>&1" \
55 "unknown: applet not found\n" "" ""
56rm unknown
Mike Frysinger23ca7252006-02-22 23:38:57 +000057
Rob Landleyb766c392005-09-04 11:10:37 +000058exit $FAILCOUNT