checkFunctions.sh revision 9db48b4604636bfdf03e60890fc094b7bec775dc
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder#!/usr/local/bin/bash
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel CalegarigetFirstDigits ()
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari{
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder wc -l $1 |expand|tr -s " " | cut -d " " -f1,2 | tr -d -c [0-9]
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari}
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder#parameters: progr option infile outfile set?
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maederruncheck ()
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder{
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder echo "testing $2"
ab8506c5100f101785452b5047259ec4f17ef436Daniel Calegari if [ -x $1 ] && [ -f $3 ]
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder then
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari $1 $2 $3 >& temp
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari declare -i a=`fgrep -c -i "error" temp`
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari if [ -f $4 ]
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari then
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari if diff -w temp $4 >& /dev/null
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari then echo " passed"
ab8506c5100f101785452b5047259ec4f17ef436Daniel Calegari else echo " failed diff with $4"
ab8506c5100f101785452b5047259ec4f17ef436Daniel Calegari fi
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari if [ "$5" = "set" ]
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari then cat temp > $4
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari fi
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari declare -i b=`getFirstDigits $3`
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari if [ "$a" -ne 0 -a "$a" -ne "$b" ]
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari then echo " $a errors for $b input lines"
f2c638409c8d870e5ad6edf2b064f959b0b86aa3Daniel Calegari fi
7439eb4a3269fa24aebfe522eb5be6f212e618e2Christian Maeder else
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari echo " missing comparison file $4 (newly created)"
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari cat temp > $4
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari fi
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari else
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari if [ -f $3 ]
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari then echo " missing executable $1"
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari else echo " missing file $3"
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari fi
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari fi
ab8506c5100f101785452b5047259ec4f17ef436Daniel Calegari}
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegarirunchecker ()
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari{
ab8506c5100f101785452b5047259ec4f17ef436Daniel Calegari runcheck $PA $1 $2 $3 $SET
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari}
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari#parameters: option extension
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegarirunmycheck ()
f2c638409c8d870e5ad6edf2b064f959b0b86aa3Daniel Calegari{
f2c638409c8d870e5ad6edf2b064f959b0b86aa3Daniel Calegari runchecker $1 $1.$2 $1.$2.output $SET
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari}
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegarirunwrongcheck ()
7c808aadfb7293563388dbe16d84cf3384bb5d3cDaniel Calegari{
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari runchecker $1 Wrong$1.$2 Wrong$1.$2.output $SET
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari}
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari
acc049a844d19fb294ce7f68742390dee87447dcDaniel Calegari