#!/bin/bash echo "Starting Regression/Unit Tests" pushd . >/dev/null TESTDIR=$(dirname $0) cd $TESTDIR TESTNUM=0 OK=0 FAILED=0 declare -a TESTLIST[] declare -a RESULTLIST[] esc=`echo -en "\033"` extd="${esc}[1m" warn="${esc}[1;31m" done="${esc}[1;36m" attn="${esc}[1;33m" norm=`echo -en "${esc}[m\017"` #stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[10D"` res_ok="${stat}[${done}OK${norm}]" res_failed="${stat}[${warn}failed${norm}]" function filter_once { FILE=$1 FILTER=$2 if [[ "$FILTER" =~ "ADR" ]] then # echo "ADR FILTER" sed -i "s/0x[0-9A-Fa-f]\+/0x/g" $FILE fi if [[ "$FILTER" =~ "VER" ]] then # echo "VER FILTER" sed -i 's/[0-9]\+\./../g' $FILE fi if [[ "$FILTER" =~ "HOMEDIR" ]] then # echo "HOMEDIR FILTER" sed -i 's/\/home\/[^/]*//g' $FILE fi if [[ "$FILTER" =~ "CRASH" ]] then # sed -i '/gxx_personality/d' $FILE sed -i 's/\/tls//' $FILE fi } function filter_output { BIN=$1 FILTER=$2 OUTOUT="$BIN.stdout.out" ERROUT="$BIN.stderr.out" filter_once $OUTOUT "$FILTER" filter_once $ERROUT "$FILTER" } function check_test { BIN=$1 OUTEXP="$BIN.stdout.exp" ERREXP="$BIN.stderr.exp" OUTOUT="$BIN.stdout.out" ERROUT="$BIN.stderr.out" ERRDIF="$BIN.stderr.dif" OUTDIF="$BIN.stdout.dif" if [ -f $OUTEXP ] then diff -C1 $OUTEXP $OUTOUT > $OUTDIF fi if [ -f $ERREXP ] then diff -C1 $ERREXP $ERROUT > $ERRDIF fi if [ -s $OUTDIF ] then return 1 fi if [ -s $ERRDIF ] then return 1 fi return 0 } function do_test { TESTNUM=$(($TESTNUM+1)) BIN=$1 BINARY=$BIN if [ "$VALGRIND" == "true" ] then BINARY="valgrind --tool=memcheck --leak-check=full --log-file=$BIN.log ./$BIN" else BINARY="./$BIN" fi FILT=$2 TESTLIST[$TESTNUM]=$BIN { $BINARY 1>$BIN.stdout.out 2>$BIN.stderr.out; } &>/dev/null filter_output $BIN "$FILT" check_test $BIN RET=$? if [ $(echo $BIN|wc -c) -lt 8 ] then echo -en "$BIN\t\t\t" else echo -en "$BIN\t\t" fi if [ "$RET" -gt 0 ] then FAILED=$(($FAILED+1)) RESULTLIST[$TESTNUM]="failed" echo $res_failed else OK=$(($OK+1)) RESULTLIST[$TESTNUM]="ok" echo $res_ok fi } function output_results { TST=1 MAX=${#TESTLIST[@]} echo -e "Did ${MAX} tests, $OK ok, $FAILED failed" echo if [ $FAILED -gt 0 ] then echo "Failed tests follow:" else echo "Perfect !" fi for((;TST <= MAX;TST++)); do if [ "${RESULTLIST[$TST]}" == "failed" ] then echo ${TESTLIST[$TST]} fi done } do_test crash "ADR VER HOMEDIR CRASH" do_test uid "" do_test ini_test "" do_test scope "" do_test debugstream "" do_test i18n "" output_results popd >/dev/null