+# $1 is the pattern of the test
+# $2 is the file to compare to
+# the result is:
+# 0: if the file to compare to do not exists
+# 1: if the file match
+# 2: if the file match with soso
+# 3: if the file do not match
+function compare_to_result()
+{
+ local pattern="$1"
+ local sav="$2"
+ if [ ! -r "$sav" ]; then return 0; fi
+ diff -u "out/$pattern.res" "$sav" > "out/$pattern.diff.sav.log"
+ if [ "$?" == 0 ]; then
+ return 1
+ fi
+ [ -z "$soso" ] && return 3
+ sed '/[Ww]arning/d;/[Ee]rror/d' "out/$pattern.res" > "out/$pattern.res2"
+ sed '/[Ww]arning/d;/[Ee]rror/d' "$sav" > "out/$pattern.sav2"
+ grep '[Ee]rror' "out/$pattern.res" >/dev/null && echo "Error" >> "out/$pattern.res2"
+ grep '[Ee]rror' "$sav" >/dev/null && echo "Error" >> "out/$pattern.sav2"
+ diff -u "out/$pattern.res2" "out/$pattern.sav2" > "out/$pattern.diff.sav2.log"
+ if [ "$?" == 0 ]; then
+ return 2
+ else
+ return 3
+ fi
+}
+
+# As argument: the pattern used for the file
+function process_result()
+{
+ ((tapcount=tapcount+1))
+ # Result
+ pattern=$1
+ description=$2
+ SAV=""
+ NSAV=""
+ FIXME=""
+ NFIXME=""
+ SOSO=""
+ NSOSO=""
+ SOSOF=""
+ NSOSOF=""
+ for sav in "sav/$engine/$pattern.res" "sav/$pattern.res" "sav/$pattern.sav"; do
+ compare_to_result "$pattern" "$sav"
+ case "$?" in
+ 0)
+ ;; # no file
+ 1)
+ SAV="$sav" ;;
+ 2)
+ SOSO="$sav" ;;
+ 3)
+ NSAV="$sav";;
+ esac
+ done
+ for sav in "sav/$engine/fixme/$pattern.res" "sav/fixme/$pattern.res" "sav/$pattern.fail"; do
+ compare_to_result "$pattern" "$sav"
+ case "$?" in
+ 0)
+ ;; # no file
+ 1)
+ FIXME="$sav" ;;
+ 2)
+ SOSOF="$sav" ;;
+ 3)
+ NFIXME="$sav";;
+ esac
+ done
+ grep 'NOT YET IMPLEMENTED' "out/$pattern.res" >/dev/null
+ NYI="$?"
+ if [ -n "$SAV" ]; then
+ if [ -n "$tap" ]; then
+ echo "ok - $description"
+ elif [ -z "$FIXME" ]; then
+ echo "[ok] out/$pattern.res $SAV"
+ else
+ echo "[ok] out/$pattern.res $SAV - but $FIXME remains!"
+ fi
+ ok="$ok $pattern"
+ elif [ -n "$FIXME" ]; then
+ if [ -n "$tap" ]; then
+ echo "not ok - $description # TODO expected failure"
+ else
+ echo "[fixme] out/$pattern.res $FIXME"
+ fi
+ todos="$todos $pattern"
+ elif [ -n "$SOSO" ]; then
+ if [ -n "$tap" ]; then
+ echo "ok - $description # SOSO"
+ else
+ echo "[soso] out/$pattern.res $SOSO"
+ fi
+ ok="$ok $pattern"
+ elif [ "x$NYI" = "x0" ]; then
+ if [ -n "$tap" ]; then
+ echo "not ok - $description # TODO not yet implemented"
+ else
+ echo "[todo] out/$pattern.res -> not yet implemented"
+ fi
+ todos="$todos $pattern"
+ elif [ -n "$SOSOF" ]; then
+ if [ -n "$tap" ]; then
+ echo "not ok - $description # TODO SOSO expected failure"
+ else
+ echo "[fixme soso] out/$pattern.res $SOSOF"
+ fi
+ todos="$todos $pattern"
+ elif [ -n "$NSAV" ]; then
+ if [ -n "$tap" ]; then
+ echo "not ok - $description"
+ else
+ echo "[======= fail out/$pattern.res $NSAV =======]"
+ fi
+ nok="$nok $pattern"
+ echo "$ii" >> "$ERRLIST"
+ elif [ -n "$NFIXME" ]; then
+ if [ -n "$tap" ]; then
+ echo "not ok - $description"
+ else
+ echo "[======= changed out/$pattern.res $NFIXME ======]"
+ fi
+ nok="$nok $pattern"
+ echo "$ii" >> "$ERRLIST"
+ else
+ if [ -n "$tap" ]; then
+ echo "ok - $description # skip no sav"
+ else
+ echo "[=== no sav ===] out/$pattern.res"
+ fi
+ nos="$nos $pattern"
+ fi
+}
+
+need_skip()
+{
+ test "$noskip" = true && return 1
+ if echo "$1" | grep -f "$engine.skip" >/dev/null 2>&1; then
+ ((tapcount=tapcount+1))
+ if [ -n "$tap" ]; then
+ echo "ok - $2 # skip"
+ else
+ echo "=> $2: [skip]"
+ fi
+ return 0
+ fi
+ return 1
+}
+
+find_nitc()
+{
+ ((tapcount=tapcount+1))
+ name="$enginebinname"
+ recent=`ls -t ../src/$name ../src/$name_[0-9] ../bin/$name ../c_src/$name 2>/dev/null | head -1`
+ if [[ "x$recent" == "x" ]]; then
+ if [ -n "$tap" ]; then
+ echo "not ok - find engine $name"
+ echo "Bail out! Could not find engine $name, aborting"
+ else
+ echo "Could not find engine $name, aborting"
+ fi
+ exit 1
+ fi
+ if [ -n "$tap" ]; then
+ echo "ok - find engine $name: $recent"
+ else
+ echo "Using engine $name from: $recent"
+ fi
+ NITC=$recent
+}
+