testvcodex revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber: vcodex test harness
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberunit=vcodex
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberinc=
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberlib=
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberfiles=
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberverbose=
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Grabercase $1 in
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber-\?) print -u2 "Usage: testvcodex [-v] [cc-options] [*.h] [*.c]"
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber exit 2
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber-v) exec 9>&2
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber shift
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber verbose=1
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber*) exec 9>/dev/null
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberesac
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberwhile : "$@" :
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberdo case $1 in
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber *.c) files="$files $1" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber */*.h) inc="$inc -I${1%/*}" ;;
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber *.h) inc="$inc -I." ;;
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber -l*) lib="$lib $1" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber -*|*,*) inc="$inc $1" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber *) base=${1##*/}
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber case $base in
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber cc.*|*.cc)
9fd38724d9cedc0ce110c8efdf6bfe2ea772d372Stéphane Graber break ;;
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber *.*) lib="$lib $1" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber *) break ;;
41670b35b0d7a11c7fa7d04e2535495dc90b76a9Stéphane Graber esac
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber ;;
3b9494bd64334d9c02a4fd2f9af04fa839830667Stéphane Graber esac
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber shift
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberdone
b0f0932a944abf6425e9f185dea9c6d9ba6e8436Stéphane Graber
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graberif test -d $unit
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graberthen source=$unit
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graberelse source=.
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graberfi
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Grabercase $inc in
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graber"") inc=-I$source ;;
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graberesac
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Grabercase $lib in
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber"") lib=-last ;;
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Graberesac
f74e080cf75f958b3e52dff9e858fd722f66301eStéphane Grabercase $files in
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber"") eval files='"' $source/*.c '"' ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberesac
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Grabercase $# in
e1adf44ef2c0828ea9031b2225b32fe543a99cdeTai Kedzierski0) set cc ;;
c586a4dcc923ce6bbe0304642bd738d7b5faff21Tai Kedzierskiesac
c586a4dcc923ce6bbe0304642bd738d7b5faff21Tai Kedzierski
c586a4dcc923ce6bbe0304642bd738d7b5faff21Tai Kedzierskicase $verbose in
c586a4dcc923ce6bbe0304642bd738d7b5faff21Tai Kedzierski'') trap 'rm -f t.exe t-*.exe xxx yyy zzz; exit 0' 0 1 2 13 15 ;;
c586a4dcc923ce6bbe0304642bd738d7b5faff21Tai Kedzierski*) inc="-DTVERBOSE $inc" ;;
c586a4dcc923ce6bbe0304642bd738d7b5faff21Tai Kedzierskiesac
4eb706b3ce9891f86ff3f9b5b5d063922df9f6b6Stéphane Graber
4eb706b3ce9891f86ff3f9b5b5d063922df9f6b6Stéphane Graberinteger tests=0 errors=0 locked=0
207bf0e475f1dc6e9a2dac2cee3a209b56427855Stéphane Graberprint -u2 "TEST $unit"
207bf0e475f1dc6e9a2dac2cee3a209b56427855Stéphane Graberprev="make test"
207bf0e475f1dc6e9a2dac2cee3a209b56427855Stéphane Graberfor v in $(dlls --info 2>/dev/null)
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberdo if [[ $v == env=* ]]
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber then v=${v#env=}
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber nameref e=$v
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber export $v=$INSTALLROOT/lib/vcodex:$INSTALLROOT/lib:$e
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber break
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber fi
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberdone
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graberfor file in $files
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graberdo (( tests = tests + 1 ))
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber test=${file%.c}
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber test=${test##*/}
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber print -u2 -f "%-15s " $test
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber test -f t.exe && {
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber rm -f t.exe || {
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber (( locked = locked + 1 ))
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber mv t.exe t-$locked.exe || {
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber print -u2 previous $prev t.exe locked
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber break 2
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber }
acabe1faee82d44db391345a8a51b9dec3dc0229Stéphane Graber }
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber }
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber prev=$file
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber # XXX compensate for nmake -lvcodex/foo => plugin #
fad967669817061cda3aafc40be04dcb712a4767Dwight Engen lcl= plugins=
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber case $file in
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber *crypt*)plugins="$plugins crypt" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber *rdb*) plugins="$plugins rdb" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber *sum*) plugins="$plugins sum" ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber esac
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber for p in $plugins
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber do set -A plugin $INSTALLROOT/lib/vcodex/*$p*
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber [[ -f ${plugin[1]} ]] && lcl="$lcl ${plugin[1]}"
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber done
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber "$@" $inc -o t.exe $file $lcl $lib >&9 2>&1
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber code=$?
fad967669817061cda3aafc40be04dcb712a4767Dwight Engen rm -f ${test}.[oO]*
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber case $code in
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber 0) if ./t.exe
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber then print -u2 passed
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber continue
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber fi
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber ;;
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber *) print -u2 compile FAILED
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber ;;
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber esac
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graber (( errors = errors + 1 ))
33aa351ac13936fb2549403f18a44fed32b2edfbStéphane Graberdone
fad967669817061cda3aafc40be04dcb712a4767Dwight Engenmsg="TEST $unit, $tests test"
fad967669817061cda3aafc40be04dcb712a4767Dwight Engencase $tests in
fad967669817061cda3aafc40be04dcb712a4767Dwight Engen1) ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber*) msg=${msg}s ;;
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graberesac
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Grabermsg="$msg, $errors error"
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Grabercase $errors in
71d3a6590fe665421d7a0026d699b0654ddfc7f6Stéphane Graber1) ;;
b0f0932a944abf6425e9f185dea9c6d9ba6e8436Stéphane Graber*) msg=${msg}s ;;
b0f0932a944abf6425e9f185dea9c6d9ba6e8436Stéphane Graberesac
b0f0932a944abf6425e9f185dea9c6d9ba6e8436Stéphane Graberprint -u2 "$msg"
b0f0932a944abf6425e9f185dea9c6d9ba6e8436Stéphane Graber