summaryrefslogtreecommitdiff
path: root/testsuite/testing.sh
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2006-05-25 13:24:02 +0000
committerBernhard Reutner-Fischer2006-05-25 13:24:02 +0000
commit89a22ea5d9edfd3bf68316343b3f78a200703466 (patch)
tree9e4a37c51407dd9da2808f5642043b3382fd75fd /testsuite/testing.sh
parent027ea1aeaccc0640b80c5b324ff34a6e1d69bc6c (diff)
downloadbusybox-89a22ea5d9edfd3bf68316343b3f78a200703466.zip
busybox-89a22ea5d9edfd3bf68316343b3f78a200703466.tar.gz
make the testsuite a little less brittle:
- 'function fn_name\n{' breaks on older FreeBSD default shells, so use the more widely supported 'fn_name () {'. This needs more fixing.. - test for integers ought to use the proper operators - test for strings ought to use quoting of the strings to be fair to strange implementations of test(1) - make sure not to ignore return-codes != 0 from commands; Some shells exit immediately on this (much like explicitely requesting set -e in e.g. bash) TODO: *) Some older shells do not allow a space after the test-condition in an "if" statement. This doesn't work: if [ $status -ne 0 ] ; then as opposed to this: if [ $status -ne 0 ]; then or this if [ $status -ne 0 ] then *) strict spacing between commands. In some shells you have to say: foo ; bar ; baz The affected shells barf on stuff like ommitting the space, so this doesn't work: foo; bar ;baz *) $() vs. `` The former isn't really portable as opposed to the latter. *) fix frong assumption that the testsuite is run from the source-dir. This is a complete misconception and renders the testsuite completely useless. That said, i note that IMO a test-harness ought to do it's best to work in a wide variety of environments, everything else defeats it's purpose.
Diffstat (limited to 'testsuite/testing.sh')
-rwxr-xr-xtestsuite/testing.sh16
1 files changed, 10 insertions, 6 deletions
diff --git a/testsuite/testing.sh b/testsuite/testing.sh
index e253e1a..7897c16 100755
--- a/testsuite/testing.sh
+++ b/testsuite/testing.sh
@@ -37,7 +37,7 @@ export SKIP=
# Helper functions
-optional()
+optional ()
{
option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"`
# Not set?
@@ -55,6 +55,7 @@ testing ()
{
NAME="$1"
[ -z "$1" ] && NAME=$2
+ ret=0
if [ $# -ne 5 ]
then
@@ -76,12 +77,15 @@ testing ()
echo -ne "$5" | eval "$2" > actual
RETVAL=$?
- cmp expected actual > /dev/null
- if [ $? -ne 0 ]
+ cmp expected actual > /dev/null || ret=$?
+ if [ $ret -ne 0 ]
then
FAILCOUNT=$[$FAILCOUNT+1]
echo "FAIL: $NAME"
- [ -n "$VERBOSE" ] && diff -u expected actual
+ if [ -n "$VERBOSE" ]
+ then
+ diff -u expected actual || /bin/true
+ fi
else
echo "PASS: $NAME"
fi
@@ -97,7 +101,7 @@ testing ()
# the file is assumed to already be there and only its library dependencies
# are copied.
-function mkchroot
+mkchroot ()
{
[ $# -lt 2 ] && return
@@ -126,7 +130,7 @@ function mkchroot
# Needed commands listed on command line
# Script fed to stdin.
-function dochroot
+dochroot ()
{
mkdir tmpdir4chroot
mount -t ramfs tmpdir4chroot tmpdir4chroot