Moved from parent directory to here.
[gedcom-parse.git] / t / src / test_gom
1 #!/bin/sh
2 # $Id$
3 # $Name$
4
5 options="-q"
6 extra_options=
7 dmalloc=`which dmalloc`
8 dmalloc_tmp=dmalloc.env
9
10 while [ $# -gt 0 ]
11 do
12   case "$1" in
13     -*) extra_options="$extra_options $1";;
14     *)  break;;
15   esac
16   shift
17 done
18
19 file=$1
20 expected_result=$2
21 if [ -z "$expected_result" ]
22 then
23   expected_result=0
24 fi
25
26 # For use outside Makefile
27 if [ -z "$srcdir" ]
28 then
29   testfile=$file
30   srcdir=.
31   options=$extra_options
32 else
33   testfile=$srcdir/input/$file
34   options="$options $extra_options"
35 fi
36
37 builddir=`pwd`
38 export GCONV_PATH=.:$GCONV_PATH
39 export LD_LIBRARY_PATH=$builddir/../gedcom/.libs:$builddir/../gom/.libs:$LD_LIBRARY_PATH
40 ln -s $srcdir/../data/gedcom.enc .
41 ln -s $builddir/../ansel/.libs/ANSI_Z39.47.so .
42 ln -s $srcdir/../ansel/gconv-modules .
43 rm -f core
44 if [ "$GOM_DMALLOC_TEST" = "" ]
45 then
46   $GEDCOM_TESTENV $builddir/src/gomtest $options $testfile
47 else
48   $dmalloc -b -l $GOM_DMALLOC_TEST -i 100 low > $dmalloc_tmp
49   . $dmalloc_tmp
50   rm $dmalloc_tmp
51   $GEDCOM_TESTENV $builddir/src/gomtest_static $options $testfile
52 fi
53 result=$?
54 rm gedcom.enc
55 rm ANSI_Z39.47.so
56 rm gconv-modules
57 if [ "$result" -eq "$expected_result" -a ! -r core ]
58 then
59   exit 0
60 else
61   exit 1
62 fi