Change for testing non-existing file.
[gedcom-parse.git] / t / src / test_script
index eebe7e672005bb349431c1fc270a0ddc6909c42e..7ca4fc354a86cb3e36ebda3f603b77cf0fd4b34d 100755 (executable)
@@ -15,7 +15,12 @@ do
 done
 
 file=$1
-expected_result=$2
+test_name=$2
+expected_result=$3
+if [ -z "$test_name" ]
+then
+  test_name=check
+fi
 if [ -z "$expected_result" ]
 then
   expected_result=0
@@ -28,25 +33,54 @@ then
   srcdir=.
   options=$extra_options
 else
-  testfile=$srcdir/input/$file
+  case $file in
+    ./*) testfile=$file ;;
+    *)   testfile=$srcdir/input/$file ;;
+  esac
   options="$options $extra_options"
 fi
 
+outfile=$test_name.out
+logfile=check.out
+reffile=$srcdir/output/$test_name.ref
+options="$options -o $outfile"
+
 builddir=`pwd`
-export GCONV_PATH=.:$GCONV_PATH
-export LD_LIBRARY_PATH=$builddir/../gedcom/.libs:$LD_LIBRARY_PATH
+ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
+GCONV_PATH=.:$GCONV_PATH
+export GCONV_PATH
+LANG=C
+export LANG
 ln -s $srcdir/../data/gedcom.enc .
-ln -s $builddir/../ansel/.libs/ANSI_Z39.47.so .
-ln -s $srcdir/../ansel/gconv-modules .
+ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
+ln -s $srcdir/../iconv/glibc/gconv-modules .
 rm -f core
-$GEDCOM_TESTENV $builddir/src/testgedcom $options $testfile
+echo "======================================================">> $logfile
+echo "Performing test '$test_name'" >> $logfile
+$ltcmd $GEDCOM_TESTENV $builddir/src/testgedcom $options $testfile
 result=$?
 rm gedcom.enc
 rm ANSI_Z39.47.so
 rm gconv-modules
-if [ "$result" -eq "$expected_result" -a ! -r core ]
+
+echo "Result is $result (expected: $expected_result)" >> $logfile
+if [ "$result" -ne "$expected_result" ]
 then
-  exit 0
-else
   exit 1
+else
+  if [ -r core ]
+  then
+    echo "Core file generated!" >> $logfile
+    exit 1
+  else
+    if diff $outfile $reffile >/dev/null 2>>$logfile
+    then
+      echo "Output agrees with reference output" >> $logfile
+      rm $outfile
+      exit 0
+    else
+      echo "Differences with reference output detected!" >> $logfile
+      exit 1
+    fi
+  fi
 fi