Use portability.c to convert void* to integer.
[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   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"
47 GCONV_PATH=.:$GCONV_PATH
48 export GCONV_PATH
49 LANG=C
50 export LANG
51 ln -s $srcdir/../data/gedcom.enc .
52 ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
53 ln -s $srcdir/../iconv/glibc/gconv-modules .
54 rm -f core
55 echo "======================================================">> $logfile
56 echo "Performing test '$test_name'" >> $logfile
57 $ltcmd $GEDCOM_TESTENV $builddir/src/testgedcom $options $testfile
58 result=$?
59 rm gedcom.enc
60 rm ANSI_Z39.47.so
61 rm gconv-modules
62
63 echo "Result is $result (expected: $expected_result)" >> $logfile
64 if [ "$result" -ne "$expected_result" ]
65 then
66   exit 1
67 else
68   if [ -r core ]
69   then
70     echo "Core file generated!" >> $logfile
71     exit 1
72   else
73     if diff $outfile $reffile >/dev/null 2>>$logfile
74     then
75       echo "Output agrees with reference output" >> $logfile
76       rm $outfile
77       exit 0
78     else
79       echo "Differences with reference output detected!" >> $logfile
80       exit 1
81     fi
82   fi
83 fi