[PATCH] testsuite: fix bashism and support !thing
Denys Vlasenko
vda.linux at googlemail.com
Fri Aug 6 07:23:00 UTC 2010
On Friday 06 August 2010 00:36, Bernhard Reutner-Fischer wrote:
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
> ---
> testsuite/testing.sh | 23 ++++++++++++++++++-----
> 1 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/testsuite/testing.sh b/testsuite/testing.sh
> index f907dea..6e90a23 100644
> --- a/testsuite/testing.sh
> +++ b/testsuite/testing.sh
> @@ -51,17 +51,30 @@ test x"$ECHO" != x"" || {
> }
>
> # Helper functions
> +# optional REQUIREDOPTION !NOTTHISOPTION BUTTHATOPTION
> +# turn off previous optionals:
> +# optional
> +# change requirements:
> +# optional REQUIREDOPTION2 !NOTTHISOPTION BUTTHATOPTION
>
> optional()
> {
> - SKIP=
> + NUMSKIPS=0
> + NUMTESTS=$#
> while test "$1"; do
> - if test x"${OPTIONFLAGS/*:$1:*/y}" != x"y"; then
> - SKIP=1
> - return
> - fi
> + OP=$(echo "x"${1} | grep -q "x!" && echo "!")
> + test "x"${OP} = "x" && FLAG=${1} || \
> + FLAG=$(printf "\b%s" ${1})
> + # XXX: undo damage of 'export OPTIONFLAGS' mangling
> + FLAG=$(echo $FLAG | sed -e 's/^CONFIG_//')
> + SET=$(echo ${OPTIONFLAGS} | grep -q ":${FLAG}:" && echo y)
> + case "${SET}${OP}" in
> + ""|"y!") ;;
> + *) NUMSKIPS=$(expr $NUMSKIPS + 1) ;;
> + esac
> shift
> done
> + test $NUMSKIPS -eq $NUMTESTS && SKIP= || SKIP=1
> }
>
> # The testing function
Bernhard, I do not see the need to have basically
custom version of test.
Yes, your patch extends it to do, say
if FOO and !BAR and BAZ
but what if next time we need something like:
if (FOO and (!BAR and BAZ)) or XYZ>=123
Therefore, I am leaning more towards removing this function,
not extending it.
--
vda
More information about the busybox
mailing list