X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=testsuite%2Ftesting.sh;h=e7e64e58b6a559d5be312964a1283d8c78e79d0f;hb=b8ab4b038803df195eee9844c3597dd640c00393;hp=a57c4d68d332cabd8f4817d033da851d95defd9b;hpb=abe49fa54fbd4d13f8424532abced8c3bc9afd0c;p=oweals%2Fbusybox.git diff --git a/testsuite/testing.sh b/testsuite/testing.sh old mode 100755 new mode 100644 index a57c4d68d..e7e64e58b --- a/testsuite/testing.sh +++ b/testsuite/testing.sh @@ -1,4 +1,4 @@ -# Simple test harness infrastructurei for BusyBox +# Simple test harness infrastructure for BusyBox # # Copyright 2005 by Rob Landley # @@ -26,7 +26,7 @@ # number of failed tests. # The "optional" function is used to skip certain tests, ala: -# optional CONFIG_FEATURE_THINGY +# optional FEATURE_THINGY # # The "optional" function checks the environment variable "OPTIONFLAGS", # which is either empty (in which case it always clears SKIP) or @@ -36,18 +36,32 @@ export FAILCOUNT=0 export SKIP= +# Helper for helpers. Oh my... + +test x"$ECHO" != x"" || { + ECHO="echo" + test x"`echo -ne`" = x"" || { + # Compile and use a replacement 'echo' which understands -e -n + ECHO="$PWD/echo-ne" + test -x "$ECHO" || { + gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1 + } + } + export ECHO +} + # Helper functions optional() { - option=`echo ":$OPTIONFLAGS:" | grep ":$1:"` - # Not set? - if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] - then - SKIP= - return - fi - SKIP=1 + SKIP= + while test "$1"; do + if test x"${OPTIONFLAGS/*:$1:*/y}" != x"y"; then + SKIP=1 + return + fi + shift + done } # The testing function @@ -59,7 +73,7 @@ testing() if [ $# -ne 5 ] then - echo "Test $NAME has wrong number of arguments (must be 5) ($# $*)" >&2 + echo "Test $NAME has wrong number of arguments: $# (must be 5)" >&2 exit 1 fi @@ -73,7 +87,9 @@ testing() $ECHO -ne "$3" > expected $ECHO -ne "$4" > input - [ -z "$VERBOSE" ] || echo "echo '$5' | $2" + [ -z "$VERBOSE" ] || echo ====================== + [ -z "$VERBOSE" ] || echo "echo -ne '$4' >input" + [ -z "$VERBOSE" ] || echo "echo -ne '$5' | $2" $ECHO -ne "$5" | eval "$2" > actual RETVAL=$?