1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#!/bin/sh
if [ $# -lt 5 ] ; then
echo "tests/tests.sh: a subshell invoked by default to perform testing run."
exit 1
fi
DIFF="diff -b -B"
Compare() {
if [ -e $1$2 ]; then
File=`basename $1$2 .log`.oracle
Dir=`dirname $1`
Dir=`dirname $Dir`
File="$Dir/oracle/$File"
if [ -e ${File} ]; then
if ! ${DIFF} --brief $1$2 ${File} >/dev/null
then
echo ". KO: ${DIFF} $1$2 ${File}"
fi
else
echo ". NO oracle ${File}"
fi
fi
}
# input file
Src=$1
shift
# prefix for the out files
PreFix=$1
shift
# extension for out files issued from stdout
PostFix1=$1
shift
# extension for out files issued from stderr
PostFix2=$1
shift
# command running the test
Cmd=$1
shift
# check the compilation of the source code.
gcc -c ${Src} -o ${PreFix}.o 2> /dev/null
Res=$?
rm -f ${PreFix}.o
if [ "${Res}" != 0 ] ; then
echo "# compilation problem with: gcc -c ${Src} -o ${PreFix}.o"
fi
# run the test on the input file
echo "${Cmd} $* ${Src}"
${Cmd} $* ${Src} > ${PreFix}${PostFix1} 2> ${PreFix}${PostFix2}
Res=$?
if [ "${Res}" != 0 ] ; then
exit ${Res}
fi
Compare ${PreFix} ${PostFix1} stdout
Compare ${PreFix} ${PostFix2} stderr
|