Portability fixes.
[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 ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la -dlopen $builddir/../gom/libgedcom_gom.la"
39 GCONV_PATH=.:$GCONV_PATH
40 export GCONV_PATH
41 ln -s $srcdir/../data/gedcom.enc .
42 ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
43 ln -s $srcdir/../iconv/glibc/gconv-modules .
44 rm -f core
45 if [ "$GOM_DMALLOC_TEST" = "" ]
46 then
47   $ltcmd $GEDCOM_TESTENV $builddir/src/gomtest $options $testfile
48 else
49   $dmalloc -b -l $GOM_DMALLOC_TEST -i 100 low > $dmalloc_tmp
50   . $dmalloc_tmp
51   rm $dmalloc_tmp
52   $ltcmd $GEDCOM_TESTENV $builddir/src/gomtest_static $options $testfile
53 fi
54 result=$?
55 rm gedcom.enc
56 rm ANSI_Z39.47.so
57 rm gconv-modules
58 if [ "$result" -eq "$expected_result" -a ! -r core ]
59 then
60   exit 0
61 else
62   exit 1
63 fi