+# $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
+ test "`cat "$sav"`" = "UNDEFINED" && return 1
+ diff -u "$sav" "out/$pattern.res" > "out/$pattern.diff.sav.log"
+ if [ "$?" == 0 ]; then
+ return 1
+ fi
+ 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.sav2" "out/$pattern.res2" > "out/$pattern.diff.sav.log2"
+ if [ "$?" == 0 ]; then
+ return 2
+ else
+ return 3
+ fi
+}
+