svn commit: trunk/busybox/testsuite

vapier at busybox.net vapier at busybox.net
Sat Sep 24 00:52:59 UTC 2005


Author: vapier
Date: 2005-09-23 17:52:58 -0700 (Fri, 23 Sep 2005)
New Revision: 11607

Log:
cleanup option parsing

Modified:
   trunk/busybox/testsuite/testing.sh


Changeset:
Modified: trunk/busybox/testsuite/testing.sh
===================================================================
--- trunk/busybox/testsuite/testing.sh	2005-09-23 21:17:46 UTC (rev 11606)
+++ trunk/busybox/testsuite/testing.sh	2005-09-24 00:52:58 UTC (rev 11607)
@@ -19,12 +19,26 @@
 # The environment variable "FAILCOUNT" contains a cumulative total of the
 # 
 
-# The command line parsing is ugly and should be improved.
+verbose=0
+debug=0
+force=0
+for x in "$@" ; do
+	case "$x" in
+	-v|--verbose)  verbose=1; shift;;
+	-d|--debug)    debug=1; shift;;
+	-f|--force)    force=1; shift;;
+	--)            break;;
+	-*)            echo "Unknown option '$x'"; exit 1;;
+	*)             break;;
+	esac
+done
 
-if [ "$1" == "-v" ]
-then
-  verbose=1
+if [ -n "$VERBOSE" ] ; then
+	verbose=1
 fi
+if [ -n "$DEBUG" ] ; then
+	debug=1
+fi
 
 export FAILCOUNT=0
 
@@ -48,16 +62,19 @@
     exit
   fi
 
-  if [ ${force_tests:-0} -ne 1 -a -n "$_BB_CONFIG_DEP" ]
+  if [ "$debug" = "1" ] ; then
+    set -x
+  fi
+
+  if [ -n "$_BB_CONFIG_DEP" ] && [ "${force}" = "0" ]
   then
     if ! config_is_set "$_BB_CONFIG_DEP"
     then
-      echo "UNTESTED: $1"
+      echo "SKIPPED: $1"
       return 0
     fi
   fi
 
-  f=$FAILCOUNT
   echo -ne "$3" > expected
   echo -ne "$4" > input
   echo -n -e "$5" | eval "$COMMAND $2" > actual
@@ -66,9 +83,9 @@
   cmp expected actual > /dev/null
   if [ $? -ne 0 ]
   then
-	FAILCOUNT=$[$FAILCOUNT+1]
+	((FAILCOUNT++))
 	echo "FAIL: $1"
-	if [ $verbose ]
+	if [ "$verbose" = "1" ]
 	then
 		diff -u expected actual
 	fi
@@ -77,5 +94,9 @@
   fi
   rm -f input expected actual
 
+  if [ "$debug" = "1" ] ; then
+    set +x
+  fi
+
   return $RETVAL
 }




More information about the busybox-cvs mailing list