Change for testing non-existing file.
[gedcom-parse.git] / t / src / test_script
1 #!/bin/sh
2 # $Id$
3 # $Name$
4
5 options="-q"
6 extra_options=
7
8 while [ $# -gt 0 ]
9 do
10   case "$1" in
11     -*) extra_options="$extra_options $1";;
12     *)  break;;
13   esac
14   shift
15 done
16
17 file=$1
18 test_name=$2
19 expected_result=$3
20 if [ -z "$test_name" ]
21 then
22   test_name=check
23 fi
24 if [ -z "$expected_result" ]
25 then
26   expected_result=0
27 fi
28
29 # For use outside Makefile
30 if [ -z "$srcdir" ]
31 then
32   testfile=$file
33   srcdir=.
34   options=$extra_options
35 else
36   case $file in
37     ./*) testfile=$file ;;
38     *)   testfile=$srcdir/input/$file ;;
39   esac
40   options="$options $extra_options"
41 fi
42
43 outfile=$test_name.out
44 logfile=check.out
45 reffile=$srcdir/output/$test_name.ref
46 options="$options -o $outfile"
47
48 builddir=`pwd`
49 ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
50 GCONV_PATH=.:$GCONV_PATH
51 export GCONV_PATH
52 LANG=C
53 export LANG
54 ln -s $srcdir/../data/gedcom.enc .
55 ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
56 ln -s $srcdir/../iconv/glibc/gconv-modules .
57 rm -f core
58 echo "======================================================">> $logfile
59 echo "Performing test '$test_name'" >> $logfile
60 $ltcmd $GEDCOM_TESTENV $builddir/src/testgedcom $options $testfile
61 result=$?
62 rm gedcom.enc
63 rm ANSI_Z39.47.so
64 rm gconv-modules
65
66 echo "Result is $result (expected: $expected_result)" >> $logfile
67 if [ "$result" -ne "$expected_result" ]
68 then
69   exit 1
70 else
71   if [ -r core ]
72   then
73     echo "Core file generated!" >> $logfile
74     exit 1
75   else
76     if diff $outfile $reffile >/dev/null 2>>$logfile
77     then
78       echo "Output agrees with reference output" >> $logfile
79       rm $outfile
80       exit 0
81     else
82       echo "Differences with reference output detected!" >> $logfile
83       exit 1
84     fi
85   fi
86 fi