blob: 545cad5c0aad181efe90666156bacd38ca4002a3 [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>
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005# Licensed under GPLv2, see file LICENSE in this source tree.
Rob Landleyb766c392005-09-04 11:10:37 +00006
Mike Frysingercaa79402009-11-04 18:41:22 -05007. ./testing.sh
Rob Landleyb766c392005-09-04 11:10:37 +00008
Denys Vlasenko015db582016-06-19 18:15:33 +02009ln -s `which busybox` unknown
10
11testing "busybox as unknown name" "./unknown 2>&1" \
12 "unknown: applet not found\n" "" ""
13rm unknown
14
15# We need busybox --help to be enabled for the rest of tests
16test x"$CONFIG_BUSYBOX" = x"y" \
17|| { echo "SKIPPED: busybox --help"; exit 0; }
18
Denys Vlasenkoe2082792010-01-16 02:49:40 +010019HELPDUMP=`true | busybox 2>&1 | cat`
Rob Landleyb766c392005-09-04 11:10:37 +000020
Rob Landley48c61572005-11-07 08:50:53 +000021# We need to test under calling the binary under other names.
Rob Landleyb766c392005-09-04 11:10:37 +000022
Denys Vlasenkoc0211e92010-05-11 04:32:04 +020023optional FEATURE_VERBOSE_USAGE
Denys Vlasenkoe2082792010-01-16 02:49:40 +010024testing "busybox --help busybox" "true | busybox --help busybox 2>&1 | cat" "$HELPDUMP\n\n" "" ""
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020025SKIP=
Rob Landleyf6acb662005-09-05 16:27:19 +000026
Rob Landley4bb1b042006-03-16 15:20:45 +000027ln -s `which busybox` busybox-suffix
28for i in busybox ./busybox-suffix
Rob Landleyb766c392005-09-04 11:10:37 +000029do
30 # The gratuitous "\n"s are due to a shell idiosyncrasy:
31 # environment variables seem to strip trailing whitespace.
32
Rob Landley4bb1b042006-03-16 15:20:45 +000033 testing "" "$i" "$HELPDUMP\n\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000034
Rob Landley4bb1b042006-03-16 15:20:45 +000035 testing "$i unknown" "$i unknown 2>&1" \
Rob Landleyb766c392005-09-04 11:10:37 +000036 "unknown: applet not found\n" "" ""
37
Rob Landley4bb1b042006-03-16 15:20:45 +000038 testing "$i --help" "$i --help 2>&1" "$HELPDUMP\n\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000039
Denys Vlasenkoc0211e92010-05-11 04:32:04 +020040 optional FEATURE_VERBOSE_USAGE CAT
Rob Landley4bb1b042006-03-16 15:20:45 +000041 testing "" "$i cat" "moo" "" "moo"
Denys Vlasenkoe2082792010-01-16 02:49:40 +010042 testing "$i --help cat" "$i --help cat 2>&1 | grep print" \
43 "Concatenate FILEs and print them to stdout\n" "" ""
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020044 SKIP=
Rob Landleyb766c392005-09-04 11:10:37 +000045
Rob Landley4bb1b042006-03-16 15:20:45 +000046 testing "$i --help unknown" "$i --help unknown 2>&1" \
Rob Landleyb766c392005-09-04 11:10:37 +000047 "unknown: applet not found\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000048done
Rob Landley4bb1b042006-03-16 15:20:45 +000049rm busybox-suffix
Rob Landleyb766c392005-09-04 11:10:37 +000050
Rob Landleyb766c392005-09-04 11:10:37 +000051exit $FAILCOUNT