[PATCH] testsuite: fix bashism and support !thing

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Aug 5 22:36:13 UTC 2010


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
-- 
1.7.1



More information about the busybox mailing list