| [4fc93f] | 1 | # -*- shell-script -*-
 | 
|---|
 | 2 | # @configure_input@
 | 
|---|
 | 3 | # Set variables and functions to use in tests.
 | 
|---|
 | 4 | # This is copied from the TREMOLO project, credits Ralf Wildenhues, modified Frederik Heber.
 | 
|---|
 | 5 | #
 | 
|---|
 | 6 | case $VERBOSE in
 | 
|---|
 | 7 |         x*) set -x ;;
 | 
|---|
 | 8 | esac
 | 
|---|
 | 9 | 
 | 
|---|
 | 10 | pathname=$0
 | 
|---|
 | 11 | # next two lines not portable
 | 
|---|
 | 12 | basename=${pathname##*/}
 | 
|---|
 | 13 | #testdir=${basename%.test}
 | 
|---|
 | 14 | testdir=${basename%%.*}
 | 
|---|
 | 15 | need_testdir="test -d @srcdir@/$testdir"
 | 
|---|
 | 16 | testdir_exists="test -d $testdir"
 | 
|---|
 | 17 | EXEEXT=@EXEEXT@
 | 
|---|
 | 18 | # next 2 lines not portable
 | 
|---|
 | 19 | MOLECUILDER=${MOLECUILDER-"@abs_top_builddir@/src/molecuilder$EXEEXT"}
 | 
|---|
 | 20 | exec_prefix="@prefix@/bin"
 | 
|---|
 | 21 | DEBUG=${DEBUG-false}
 | 
|---|
 | 22 | CLEANUP='rm -f stderr stdout'
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 | if $need_testdir
 | 
|---|
 | 25 | then
 | 
|---|
| [bdedb1] | 26 |         if $testdir_exists; then
 | 
|---|
 | 27 |                 rm -rf $testdir
 | 
|---|
| [4fc93f] | 28 |         fi
 | 
|---|
| [bdedb1] | 29 |         mkdir $testdir
 | 
|---|
 | 30 |         CLEANUP="$CLEANUP; rm -rf $testdir"
 | 
|---|
 | 31 |         cp -r @srcdir@/$testdir/* $testdir/
 | 
|---|
| [4fc93f] | 32 |         cd $testdir
 | 
|---|
 | 33 |         CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP"
 | 
|---|
| [491876] | 34 |         CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP"
 | 
|---|
| [4fc93f] | 35 | fi
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | # debug runs should keep results
 | 
|---|
 | 38 | if $DEBUG; then :; else
 | 
|---|
 | 39 |         trap "eval \"$CLEANUP\"" 0 1 2 13 15
 | 
|---|
 | 40 | fi
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | # TREMOLO_run status [options...]
 | 
|---|
 | 43 | # Run tremolo with OPTIONS, fail if it does not exit with STATUS.
 | 
|---|
 | 44 | Tesselation_run ()
 | 
|---|
 | 45 | {
 | 
|---|
 | 46 |         # $1 is exit code
 | 
|---|
 | 47 |         # $2 is RADIUS
 | 
|---|
 | 48 |         
 | 
|---|
 | 49 |         expected_exitcode=$1
 | 
|---|
 | 50 |         mol=$testdir
 | 
|---|
 | 51 |         RADIUS=$2
 | 
|---|
 | 52 |         FILENAME="NonConvexEnvelope"
 | 
|---|
 | 53 |         exitcode=0
 | 
|---|
| [bdedb1] | 54 |         cd $RADIUS
 | 
|---|
 | 55 |         #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
 | 
|---|
| [4fc93f] | 56 |         if [ -e $mol.dbond ]; then
 | 
|---|
| [bdedb1] | 57 |                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N $RADIUS $FILENAME 2>stderr >stdout || exitcode=$?
 | 
|---|
| [4fc93f] | 58 |         else
 | 
|---|
| [bdedb1] | 59 |                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME 2>stderr >stdout || exitcode=$?
 | 
|---|
| [4fc93f] | 60 |         fi
 | 
|---|
| [bdedb1] | 61 |         #echo "Molecuilder done with exitcode $exitcode."
 | 
|---|
| [4fc93f] | 62 |         #cat stderr
 | 
|---|
 | 63 |         #cat stdout
 | 
|---|
| [12872d] | 64 |         grep -E "^[0-9]* [0-9]* [0-9]*$" ../../../../../molecuilder/tests/Tesselations/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat
 | 
|---|
 | 65 |         grep -E "^[0-9]* [0-9]* [0-9]*$" ${FILENAME}.dat | sort -n >new-triangles.dat
 | 
|---|
 | 66 |         diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?
 | 
|---|
| [bdedb1] | 67 |         #echo "Diff done with exitcode $exitcode."
 | 
|---|
 | 68 |         #cat diffstderr
 | 
|---|
 | 69 |         #cat diffstdout
 | 
|---|
 | 70 |         cd ..
 | 
|---|
| [4fc93f] | 71 |         test $exitcode = $expected_exitcode || exit 1
 | 
|---|
 | 72 | }
 | 
|---|
 | 73 | 
 | 
|---|
 | 74 | # can use $LN_S
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 | # vim:set ft=sh:
 | 
|---|