Refactored common parts into test_prologue.sh and test_bulk.sh.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 3 Nov 2002 15:48:19 +0000 (15:48 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 3 Nov 2002 15:48:19 +0000 (15:48 +0000)
t/src/test_bulk.sh [new file with mode: 0644]
t/src/test_gom
t/src/test_intl
t/src/test_prologue.sh [new file with mode: 0644]
t/src/test_script
t/src/test_update

diff --git a/t/src/test_bulk.sh b/t/src/test_bulk.sh
new file mode 100644 (file)
index 0000000..c4f29e6
--- /dev/null
@@ -0,0 +1,41 @@
+# $Id$
+# $Name$
+# Common test part for the test scripts
+
+ltcmd="$builddir/../libtool --mode=execute"
+for lib in $test_libs
+do
+  ltcmd="$ltcmd -dlopen $lib"
+done
+
+echo "======================================================">> $logfile
+echo "Performing test '$test_name'" >> $logfile
+$ltcmd $GEDCOM_TESTENV $builddir/src/$test_program $options $test_args
+result=$?
+rm gedcom.enc
+rm new.ged
+rm ANSI_Z39.47.so
+rm gconv-modules
+
+echo "Result is $result (expected: $expected_result)" >> $logfile
+if [ "$result" -ne "$expected_result" ]
+then
+  echo "Not the expected return value!" >> $logfile
+  exit 1
+else
+  if [ -r core ]
+  then
+    echo "Core file generated!" >> $logfile
+    exit 1
+  else
+    if diff $outfile $reffile >/dev/null 2>>$logfile
+    then
+      echo "Output agrees with reference output" >> $logfile
+      rm $outfile
+      exit 0
+    else
+      echo "Differences with reference output detected!" >> $logfile
+      exit 1
+    fi
+  fi
+fi
index 90f4b4bfdb26cf5435935cf1ce182b21f3242fca..90d859c14f3cf1d0acd0ff7f6800158a293b5b41 100755 (executable)
@@ -2,86 +2,28 @@
 # $Id$
 # $Name$
 
-options="-q"
-extra_options=
-
-while [ $# -gt 0 ]
-do
-  case "$1" in
-    -*) extra_options="$extra_options $1";;
-    *)  break;;
-  esac
-  shift
-done
-
-test_name=$1
-expected_result=$2
-file=$3
-if [ -z "$test_name" ]
-then
-  test_name=check
-fi
-if [ -z "$expected_result" ]
+builddir=`pwd`
+if [ -z "$srcdir" ]
 then
-  expected_result=0
+  srcdir=.
 fi
 
-# For use outside Makefile
+. $srcdir/src/test_prologue.sh
+
+file=$1
+
 if [ -z "$srcdir" ]
 then
   testfile=$file
-  srcdir=.
-  options=$extra_options
 else
   case $file in
     ./*) testfile=$file ;;
     *)   testfile=$srcdir/input/$file ;;
   esac
-  options="$options $extra_options"
 fi
 
-outfile=$test_name.out
-logfile=check.out
-reffile=$srcdir/output/$test_name.ref
-options="$options -o $outfile"
-
-builddir=`pwd`
-ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la -dlopen $builddir/../gom/libgedcom_gom.la"
-GCONV_PATH=.:$GCONV_PATH
-export GCONV_PATH
-LANG=C
-export LANG
-ln -s $srcdir/../data/gedcom.enc .
-ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
-ln -s $srcdir/../iconv/glibc/gconv-modules .
-rm -f core
-echo "======================================================">> $logfile
-echo "Performing test '$test_name'" >> $logfile
-$ltcmd $GEDCOM_TESTENV $builddir/src/gomtest $options $testfile
-result=$?
-rm gedcom.enc
-rm ANSI_Z39.47.so
-rm gconv-modules
+test_program=gomtest
+test_libs="$builddir/../gedcom/libgedcom.la $builddir/../gom/libgedcom_gom.la"
+test_args=$testfile
 
-echo "Result is $result (expected: $expected_result)" >> $logfile
-if [ "$result" -ne "$expected_result" ]
-then
-  echo "Not the expected return value!" >> $logfile
-  exit 1
-else
-  if [ -r core ]
-  then
-    echo "Core file generated!" >> $logfile
-    exit 1
-  else
-    if diff $outfile $reffile >/dev/null 2>>$logfile
-    then
-      echo "Output agrees with reference output" >> $logfile
-      rm $outfile
-      exit 0
-    else
-      echo "Differences with reference output detected!" >> $logfile
-      exit 1
-    fi
-  fi
-fi
+. $srcdir/src/test_bulk.sh
index 6706ad9cebd167dcd2d5f97da7c9c45a73530763..c6040910204bffba7a93f45dda36f26f6a5c5647 100755 (executable)
@@ -2,80 +2,14 @@
 # $Id$
 # $Name$
 
-options="-q"
-extra_options=
-
-while [ $# -gt 0 ]
-do
-  case "$1" in
-    -*) extra_options="$extra_options $1";;
-    *)  break;;
-  esac
-  shift
-done
-
-test_name=$1
-expected_result=$2
-if [ -z "$test_name" ]
-then
-  test_name=check
-fi
-if [ -z "$expected_result" ]
-then
-  expected_result=0
-fi
-
-# For use outside Makefile
+builddir=`pwd`
 if [ -z "$srcdir" ]
 then
   srcdir=.
-  options=$extra_options
-else
-  options="$options $extra_options"
 fi
 
-outfile=$test_name.out
-logfile=check.out
-reffile=$srcdir/output/$test_name.ref
-options="$options -o $outfile"
-
-builddir=`pwd`
-ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
-GCONV_PATH=.:$GCONV_PATH
-export GCONV_PATH
-ln -s $srcdir/../data/gedcom.enc .
-ln -s $builddir/../data/new.ged .
-ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
-ln -s $srcdir/../iconv/glibc/gconv-modules .
-rm -f core
-echo "======================================================">> $logfile
-echo "Performing test '$test_name'" >> $logfile
-$ltcmd $GEDCOM_TESTENV $builddir/src/testintl $options
-result=$?
-rm gedcom.enc
-rm new.ged
-rm ANSI_Z39.47.so
-rm gconv-modules
+test_program=testintl
+test_libs=$builddir/../gedcom/libgedcom.la
 
-echo "Result is $result (expected: $expected_result)" >> $logfile
-if [ "$result" -ne "$expected_result" ]
-then
-  echo "Not the expected return value!" >> $logfile
-  exit 1
-else
-  if [ -r core ]
-  then
-    echo "Core file generated!" >> $logfile
-    exit 1
-  else
-    if diff $outfile $reffile >/dev/null 2>>$logfile
-    then
-      echo "Output agrees with reference output" >> $logfile
-      rm $outfile
-      exit 0
-    else
-      echo "Differences with reference output detected!" >> $logfile
-      exit 1
-    fi
-  fi
-fi
+. $srcdir/src/test_prologue.sh
+. $srcdir/src/test_bulk.sh
diff --git a/t/src/test_prologue.sh b/t/src/test_prologue.sh
new file mode 100644 (file)
index 0000000..dfbdb4d
--- /dev/null
@@ -0,0 +1,50 @@
+# $Id$
+# $Name$
+# Common prologue for the test scripts
+
+extra_options=
+
+while [ $# -gt 0 ]
+do
+  case "$1" in
+    -*) extra_options="$extra_options $1";;
+    *)  break;;
+  esac
+  shift
+done
+
+test_name=$1
+shift
+expected_result=$1
+shift
+if [ -z "$test_name" ]
+then
+  test_name=check
+fi
+if [ -z "$expected_result" ]
+then
+  expected_result=0
+fi
+
+# For use outside Makefile
+if [ -z "$srcdir" ]
+then
+  :
+else
+  options="-q $extra_options"
+fi
+
+outfile=$test_name.out
+logfile=check.out
+reffile=$srcdir/output/$test_name.ref
+options="$options -o $outfile"
+
+GCONV_PATH=.:$GCONV_PATH
+export GCONV_PATH
+LANG=C
+export LANG
+ln -s $srcdir/../data/gedcom.enc .
+ln -s $builddir/../data/new.ged .
+ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
+ln -s $srcdir/../iconv/glibc/gconv-modules .
+rm -f core
index 46804cb03a867b66e717dd6bdbf25175ed1b95b4..3753da40b644ded15a3319ff6a8d3c343d8ed1af 100755 (executable)
@@ -2,86 +2,28 @@
 # $Id$
 # $Name$
 
-options="-q"
-extra_options=
-
-while [ $# -gt 0 ]
-do
-  case "$1" in
-    -*) extra_options="$extra_options $1";;
-    *)  break;;
-  esac
-  shift
-done
-
-test_name=$1
-expected_result=$2
-file=$3
-if [ -z "$test_name" ]
-then
-  test_name=check
-fi
-if [ -z "$expected_result" ]
+builddir=`pwd`
+if [ -z "$srcdir" ]
 then
-  expected_result=0
+  srcdir=.
 fi
 
-# For use outside Makefile
+. $srcdir/src/test_prologue.sh
+
+file=$1
+
 if [ -z "$srcdir" ]
 then
   testfile=$file
-  srcdir=.
-  options=$extra_options
 else
   case $file in
     ./*) testfile=$file ;;
     *)   testfile=$srcdir/input/$file ;;
   esac
-  options="$options $extra_options"
 fi
 
-outfile=$test_name.out
-logfile=check.out
-reffile=$srcdir/output/$test_name.ref
-options="$options -o $outfile"
-
-builddir=`pwd`
-ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
-GCONV_PATH=.:$GCONV_PATH
-export GCONV_PATH
-LANG=C
-export LANG
-ln -s $srcdir/../data/gedcom.enc .
-ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
-ln -s $srcdir/../iconv/glibc/gconv-modules .
-rm -f core
-echo "======================================================">> $logfile
-echo "Performing test '$test_name'" >> $logfile
-$ltcmd $GEDCOM_TESTENV $builddir/src/testgedcom $options $testfile
-result=$?
-rm gedcom.enc
-rm ANSI_Z39.47.so
-rm gconv-modules
+test_program=testgedcom
+test_libs=$builddir/../gedcom/libgedcom.la
+test_args=$testfile
 
-echo "Result is $result (expected: $expected_result)" >> $logfile
-if [ "$result" -ne "$expected_result" ]
-then
-  echo "Not the expected return value!" >> $logfile
-  exit 1
-else
-  if [ -r core ]
-  then
-    echo "Core file generated!" >> $logfile
-    exit 1
-  else
-    if diff $outfile $reffile >/dev/null 2>>$logfile
-    then
-      echo "Output agrees with reference output" >> $logfile
-      rm $outfile
-      exit 0
-    else
-      echo "Differences with reference output detected!" >> $logfile
-      exit 1
-    fi
-  fi
-fi
+. $srcdir/src/test_bulk.sh
index 113f6fe3dfd86f6bad29c748229d76a9e31201a2..a4c2a9c3dc834f7aed947cec89b8163aad53165b 100755 (executable)
@@ -2,80 +2,14 @@
 # $Id$
 # $Name$
 
-options="-q"
-extra_options=
-
-while [ $# -gt 0 ]
-do
-  case "$1" in
-    -*) extra_options="$extra_options $1";;
-    *)  break;;
-  esac
-  shift
-done
-
-test_name=$1
-expected_result=$2
-if [ -z "$test_name" ]
-then
-  test_name=check
-fi
-if [ -z "$expected_result" ]
-then
-  expected_result=0
-fi
-
-# For use outside Makefile
+builddir=`pwd`
 if [ -z "$srcdir" ]
 then
   srcdir=.
-  options=$extra_options
-else
-  options="$options $extra_options"
 fi
 
-outfile=$test_name.out
-logfile=check.out
-reffile=$srcdir/output/$test_name.ref
-options="$options -o $outfile"
-
-builddir=`pwd`
-ltcmd="$builddir/../libtool --mode=execute -dlopen $builddir/../gedcom/libgedcom.la"
-GCONV_PATH=.:$GCONV_PATH
-export GCONV_PATH
-ln -s $srcdir/../data/gedcom.enc .
-ln -s $builddir/../data/new.ged .
-ln -s $builddir/../iconv/glibc/.libs/ANSI_Z39.47.so .
-ln -s $srcdir/../iconv/glibc/gconv-modules .
-rm -f core
-echo "======================================================">> $logfile
-echo "Performing test '$test_name'" >> $logfile
-$ltcmd $GEDCOM_TESTENV $builddir/src/updatetest $options
-result=$?
-rm gedcom.enc
-rm new.ged
-rm ANSI_Z39.47.so
-rm gconv-modules
+test_program=updatetest
+test_libs=$builddir/../gedcom/libgedcom.la
 
-echo "Result is $result (expected: $expected_result)" >> $logfile
-if [ "$result" -ne "$expected_result" ]
-then
-  echo "Not the expected return value!" >> $logfile
-  exit 1
-else
-  if [ -r core ]
-  then
-    echo "Core file generated!" >> $logfile
-    exit 1
-  else
-    if diff $outfile $reffile >/dev/null 2>>$logfile
-    then
-      echo "Output agrees with reference output" >> $logfile
-      rm $outfile
-      exit 0
-    else
-      echo "Differences with reference output detected!" >> $logfile
-      exit 1
-    fi
-  fi
-fi
+. $srcdir/src/test_prologue.sh
+. $srcdir/src/test_bulk.sh