blob: 04fea3ea24e2e4f0befb28ca31979787ae4c674a [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 Vlasenkoe2082792010-01-16 02:49:40 +01009HELPDUMP=`true | busybox 2>&1 | cat`
Rob Landleyb766c392005-09-04 11:10:37 +000010
Rob Landley48c61572005-11-07 08:50:53 +000011# We need to test under calling the binary under other names.
Rob Landleyb766c392005-09-04 11:10:37 +000012
Denys Vlasenkoc0211e92010-05-11 04:32:04 +020013optional FEATURE_VERBOSE_USAGE
Denys Vlasenkoe2082792010-01-16 02:49:40 +010014testing "busybox --help busybox" "true | busybox --help busybox 2>&1 | cat" "$HELPDUMP\n\n" "" ""
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020015SKIP=
Rob Landleyf6acb662005-09-05 16:27:19 +000016
Rob Landley4bb1b042006-03-16 15:20:45 +000017ln -s `which busybox` busybox-suffix
18for i in busybox ./busybox-suffix
Rob Landleyb766c392005-09-04 11:10:37 +000019do
20 # The gratuitous "\n"s are due to a shell idiosyncrasy:
21 # environment variables seem to strip trailing whitespace.
22
Rob Landley4bb1b042006-03-16 15:20:45 +000023 testing "" "$i" "$HELPDUMP\n\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000024
Rob Landley4bb1b042006-03-16 15:20:45 +000025 testing "$i unknown" "$i unknown 2>&1" \
Rob Landleyb766c392005-09-04 11:10:37 +000026 "unknown: applet not found\n" "" ""
27
Rob Landley4bb1b042006-03-16 15:20:45 +000028 testing "$i --help" "$i --help 2>&1" "$HELPDUMP\n\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000029
Denys Vlasenkoc0211e92010-05-11 04:32:04 +020030 optional FEATURE_VERBOSE_USAGE CAT
Rob Landley4bb1b042006-03-16 15:20:45 +000031 testing "" "$i cat" "moo" "" "moo"
Denys Vlasenkoe2082792010-01-16 02:49:40 +010032 testing "$i --help cat" "$i --help cat 2>&1 | grep print" \
33 "Concatenate FILEs and print them to stdout\n" "" ""
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020034 SKIP=
Rob Landleyb766c392005-09-04 11:10:37 +000035
Rob Landley4bb1b042006-03-16 15:20:45 +000036 testing "$i --help unknown" "$i --help unknown 2>&1" \
Rob Landleyb766c392005-09-04 11:10:37 +000037 "unknown: applet not found\n" "" ""
Rob Landleyb766c392005-09-04 11:10:37 +000038done
Rob Landley4bb1b042006-03-16 15:20:45 +000039rm busybox-suffix
Rob Landleyb766c392005-09-04 11:10:37 +000040
Rob Landley4bb1b042006-03-16 15:20:45 +000041ln -s `which busybox` unknown
Rob Landleyb766c392005-09-04 11:10:37 +000042
Rob Landley4bb1b042006-03-16 15:20:45 +000043testing "busybox as unknown name" "./unknown 2>&1" \
44 "unknown: applet not found\n" "" ""
45rm unknown
Mike Frysinger23ca7252006-02-22 23:38:57 +000046
Rob Landleyb766c392005-09-04 11:10:37 +000047exit $FAILCOUNT