Removed support for testing with dmalloc (valgrind is better...).
[gedcom-parse.git] / t / src / test_gom
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   testfile=$srcdir/input/$file
37   options="$options $extra_options"
38 fi
39
40 outfile=$test_name.out
41 logfile=check.out
42 reffile=$srcdir/output/$test_name.ref
43 options="$options -o $outfile"
44
45 builddir=`pwd`
46 ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la -dlopen $builddir/../gom/libgedcom_gom.la"
47 GCONV_PATH=.:$GCONV_PATH
48 export GCONV_PATH
49 ln -s $srcdir/../data/gedcom.enc .
50 ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
51 ln -s $srcdir/../iconv/glibc/gconv-modules .
52 rm -f core
53 echo "======================================================">> $logfile
54 echo "Performing test '$test_name'" >> $logfile
55 $ltcmd $GEDCOM_TESTENV $builddir/src/gomtest $options $testfile
56 result=$?
57 rm gedcom.enc
58 rm ANSI_Z39.47.so
59 rm gconv-modules
60
61 echo "Result is $result (expected: $expected_result)" >> $logfile
62 if [ "$result" -ne "$expected_result" ]
63 then
64   echo "Not the expected return value!" >> $logfile
65   exit 1
66 else
67   if [ -r core ]
68   then
69     echo "Core file generated!" >> $logfile
70     exit 1
71   else
72     if diff $outfile $reffile >/dev/null 2>>$logfile
73     then
74       echo "Output agrees with reference output" >> $logfile
75       rm $outfile
76       exit 0
77     else
78       echo "Differences with reference output detected!" >> $logfile
79       exit 1
80     fi
81   fi
82 fi