X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=userapps%2Fopensource%2Fnet-snmp%2Ftesting%2Feval_oneprogram.sh;fp=userapps%2Fopensource%2Fnet-snmp%2Ftesting%2Feval_oneprogram.sh;h=45edfc0a673d8b8aaf530ce9fd1cef3e0383b60d;hb=9dffd9f7659a1b28265e0dc9497343eb3d108d02;hp=0000000000000000000000000000000000000000;hpb=e48c2529a5a7e7dbf1797bb6d1bf964bc03e78a7;p=bcm963xx.git diff --git a/userapps/opensource/net-snmp/testing/eval_oneprogram.sh b/userapps/opensource/net-snmp/testing/eval_oneprogram.sh new file mode 100755 index 00000000..45edfc0a --- /dev/null +++ b/userapps/opensource/net-snmp/testing/eval_oneprogram.sh @@ -0,0 +1,138 @@ +#!/bin/sh +# +# eval_oneprogram.sh [-h][-lk] [] +# +# CALLED BY: eval_suite.sh +# +# +# Runs and reports how many instances of the strings SUCCESS +# or FAILED occur. +# +# +# FIX Output from $PROGRAM on stderr is separated out and comes first. +# +# +USAGE_LONG=' +# +# -h Help. +# -k Save the program output in "____o". +# -l Long form. (Short form by default.) +# +# is the executable to run and collect the output of. +' + +USAGE="Usage: `basename $0` [-h][-lk] " + + + + +#------------------------------------ -o- +# Globals. +# +AWKFILE="_`basename $0`$$.awk" +SCRIPTFILE= + +dolongform=0 +dokeepoutput= + +TOTALFAILED=0 + + + +#------------------------------------ -o- +# Parse & setup. +# +while [ -n "$1" ]; do + case "$1" in + -k) dokeepoutput=true + ;; + -l) dolongform=1 + ;; + -h) echo $USAGE + cat <&2 +$USAGE_LONG +BLIK + exit 0 + ;; + *) PROGRAM="$*" + shift `expr $# - 1` + ;; + esac + + shift +done + +[ -z "$PROGRAM" ] && echo $USAGE && exit 1 + + +SCRIPTFILE="__`echo \`basename $PROGRAM\` | sed 's/ /_/g'`__$$o" + + + +#------------------------------------ -o- +# Create awk script. +# + +cat <$AWKFILE + +BEGIN { + pass = 0 + passlist[0] = "" + + fail = 0 + faillist[0] = "" + + longform = $dolongform + 0 +} + +/SUCCESS/ { + passlist[pass] = \$0 + pass += 1 +} + +/FAILED/ { + faillist[fail] = \$0 + fail += 1 +} + +END { + printf "$PROGRAM SUCCESS: %d\n", pass + printf "$PROGRAM FAILED: %d\n", fail + + if (longform) { + printf "\n" + for (i=0; i&1 ; } >$SCRIPTFILE + +awk -f $AWKFILE $SCRIPTFILE +TOTALFAILED=$? + +rm -f $AWKFILE +[ -z "$dokeepoutput" ] && rm -f $SCRIPTFILE + + + + +#------------------------------------ -o- +# Exit, cleanup. +# +exit $TOTALFAILED + +