source: git/tests/cavern.tst @ f9aaa2c

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-datawalls-data-hanging-as-warning
Last change on this file since f9aaa2c was f9aaa2c, checked in by Olly Betts <olly@…>, 8 years ago

Remove random : from after ] in cavern.tst

dash ignores this, but bash (quite reasonably) throws an error, which
means the testsuite fails if /bin/sh is bash.

  • Property mode set to 100755
File size: 7.6 KB
RevLine 
[fbc3a20]1#!/bin/sh
[b4fe9fb]2#
3# Survex test suite - cavern tests
[5d1c60c]4# Copyright (C) 1999-2004,2005,2006,2010,2012,2013,2014,2015,2016 Olly Betts
[b4fe9fb]5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
[d333899]18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
[fbc3a20]19
[d4d8efe]20testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'`
21
[6b8ff5b]22# allow us to run tests standalone more easily
[d4d8efe]23: ${srcdir="$testdir"}
[647407d]24
[64b4d1c]25# force VERBOSE if we're run on a subset of tests
26test -n "$*" && VERBOSE=1
27
[87681b8]28test -x "$testdir"/../src/cavern || testdir=.
29
[9ef8aa6]30# Make testdir absolute, so we can cd before running cavern to get a consistent
31# path in diagnostic messages.
32testdir=`(cd "$testdir" && pwd)`
33
[d4d8efe]34: ${CAVERN="$testdir"/../src/cavern}
35: ${DIFFPOS="$testdir"/../src/diffpos}
[64d37a3]36: ${CAD3D="$testdir"/../src/cad3d}
[647407d]37
[e0c8f98]38: ${TESTS=${*:-"singlefix singlereffix oneleg midpoint noose cross firststn\
[107b8bd]39 deltastar deltastar2 bug3 calibrate_tape nosurvey2 cartesian cartesian2\
[dcbcae0]40 lengthunits angleunits cmd_alias cmd_truncate cmd_case cmd_fix cmd_solve\
[4fb15a1]41 cmd_entrance cmd_entrance_bad cmd_sd cmd_sd_bad cmd_fix_bad cmd_set\
42 cmd_set_bad beginroot revcomplist break_replace_pfx bug0 bug1 bug2 bug4 bug5\
[cfa16ef]43 expobug require export export2 includecomment\
[4fb15a1]44 self_loop self_eq_loop reenterwarn cmd_default cmd_prefix cmd_prefix_bad\
[b9c82c2]45 cmd_begin_bad cmd_equate_bad cmd_export_bad\
[cfa16ef]46 singlefixerr singlereffixerr\
47 begin_no_end end_no_begin end_no_begin_nest require_fail\
48 exporterr1 exporterr2 exporterr3 exporterr4 exporterr5\
49 exporterr1b exporterr2b exporterr3b exporterr6 exporterr6b\
[2b0cec5]50 hanging_cpt badinc badinc2 badinc3 badinc4 nonexistent_file ONELEG\
51 stnsurvey1 stnsurvey2\
[0af7076]52 tapelessthandepth longname chinabug chinabug2\
[54c4612]53 multinormal multinormignall multidiving multicylpolar multicartesian\
54 multinosurv multinormalbad multibug\
[e0c7cd1]55 cmd_title cmd_titlebad cmd_dummy cmd_infer cmd_date cmd_datebad cmd_datebad2\
[4fb15a1]56 cartes diving cylpolar normal normal_bad normignall nosurv cmd_flags\
57 bad_cmd_flags plumb unusedstation exportnakedbegin oldestyle bugdz\
58 baddatacylpolar badnewline badquantities imgoffbyone infereqtopofil 3sdfixbug\
[5d1c60c]59 omitclino back back2 bad_back\
[a26c346]60 notentranceorexport inferunknown inferexports bad_units_factor\
[699bf50]61 bad_units_qlist\
[b4fe9fb]62 percent_gradient dotinsurvey leandroclino lowsd revdir gettokennullderef\
[dfe4a520]63 nosurveyhanging cmd_solve_nothing cmd_solve_nothing_implicit\
[2c17123e]64 cmd_calibrate cmd_declination cmd_declination_auto cmd_declination_conv\
[850fdc4]65 lech level 2fixbug dot17 3dcorner\
[be4d0a0]66 unconnected-bug\
[850fdc4]67 declination.dat ignore.dat backread.dat nomeasure.dat\
[e363f8b]68 surfequate passage hanging_lrud equatenosuchstn surveytypo\
[da96015]69 skipafterbadomit passagebad badreadingdotplus badcalibrate calibrate_clino\
[c092d72]70 badunits badbegin anonstn anonstnbad anonstnrev doubleinc reenterlots\
[a9c640c]71 cs csbad csbadsdfix cslonglat omitfixaroundsolve repeatreading\
[04c461e]72 mixedeols\
[c092d72]73"}}
[cd971de]74
[2b0cec5]75# Test file stnsurvey3.svx missing: pos=fail # We exit before the error count.
76
[cd971de]77LC_ALL=C
78export LC_ALL
[6e47b72]79SURVEXLANG=en
[cd971de]80export SURVEXLANG
[4515ba18]81
[67a2822]82vg_error=123
[9f5bcd3]83vg_log=$testdir/vg.log
[67a2822]84if [ -n "$VALGRIND" ] ; then
85  rm -f "$vg_log"
86  CAVERN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAVERN"
[38c4c5c]87  DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS"
[33a2d49]88  CAD3D="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAD3D"
[67a2822]89fi
90
[4515ba18]91for file in $TESTS ; do
[2b0cec5]92  case $file in
93    nonexistent_file*|ONELEG)
94      # ONELEG tests that we don't apply special handling to command line
95      # arguments, only those in *include.
96      realfile= ;;
97    *.*) realfile=$file ;;
98    *) realfile=$file.svx ;;
99  esac
100
101  if [ -n "$realfile" ] && [ ! -r "$realfile" ] ; then
102    echo "Warning: don't know how to run test '$file' - skipping it"
103    continue
104  fi
105
106  echo "$file"
107
[cfa16ef]108  # how many warnings to expect
[b97d134]109  warn=
110  # how many errors to expect
111  error=
[2b0cec5]112
[0d3c93b]113  case $file in
[2b0cec5]114    *.dat)
115      # .dat files can't start with a comment.  All the current .dat tests
116      # have the same settings.
117      pos=yes
118      warn=0
119      ;;
120    nonexistent_file*|ONELEG)
121      # We exit before the error count.
122      pos=fail
123      ;;
124    *)
125      read header < "$realfile"
126      set dummy $header
[f9aaa2c]127      while shift && [ -n "$1" ] ; do
[2b0cec5]128        case $1 in
129          pos=*) pos=`expr "$1" : 'pos=\(.*\)'` ;;
130          warn=*) warn=`expr "$1" : 'warn=\(.*\)'` ;;
131          error=*) error=`expr "$1" : 'error=\(.*\)'` ;;
132        esac
133      done
134      ;;
[cfa16ef]135  esac
[4a2bb00]136
[2b0cec5]137  case $file in
138  *.*)
139    input="./$file"
140    posfile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.pos/'`
141    dxffile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.dxf/'` ;;
142  *)
143    input="./$file.svx"
144    posfile="$srcdir/$file.pos"
145    dxffile="$srcdir/$file.dxf" ;;
146  esac
147  rm -f tmp.*
148  pwd=`pwd`
149  cd "$srcdir"
150  srcdir=. $CAVERN "$input" --output="$pwd/tmp" > "$pwd/tmp.out"
151  exitcode=$?
152  cd "$pwd"
153  test -n "$VERBOSE" && cat tmp.out
154  if [ -n "$VALGRIND" ] ; then
155    if [ $exitcode = "$vg_error" ] ; then
156      cat "$vg_log"
157      rm "$vg_log"
158      exit 1
159    fi
160    rm "$vg_log"
161  fi
162  if test fail = "$pos" ; then
163    # success gives 0, signal (128 + <signal number>)
164    test $exitcode = 1 || exit 1
165  else
166    test $exitcode = 0 || exit 1
167  fi
168  if test -n "$warn" ; then
169    w=`sed '$!d;s/^There were \([0-9]*\).*/\1/;s/^[^0-9].*$/0/' tmp.out`
170    if test x"$w" != x"$warn" ; then
171      test -n "$VERBOSE" && echo "Got $w warnings, expected $warn"
172      exit 1
173    fi
174  fi
175  if test -n "$error" ; then
176    e=`sed '$!d;s/^There were .* and \([0-9][0-9]*\).*/\1/;s/^[^0-9].*$/0/' tmp.out`
177    if test x"$e" != x"$error" ; then
178      test -n "$VERBOSE" && echo "Got $e errors, expected $error"
179      exit 1
180    fi
181  fi
182  nan=`sed 's/.*\<[Nn]a[Nn]m\?\>.*/x/p;d' tmp.out`
183  if test -n "$nan" ; then
184    exit 1
185  fi
186
187  case $pos in
188  yes)
189    if test -n "$VERBOSE" ; then
190      $DIFFPOS "$posfile" tmp.3d
191      exitcode=$?
192    else
193      $DIFFPOS "$posfile" tmp.3d > /dev/null
194      exitcode=$?
195    fi
[67a2822]196    if [ -n "$VALGRIND" ] ; then
197      if [ $exitcode = "$vg_error" ] ; then
198        cat "$vg_log"
199        rm "$vg_log"
200        exit 1
201      fi
202      rm "$vg_log"
203    fi
[2b0cec5]204    [ "$exitcode" = 0 ] || exit 1
205    ;;
206  dxf)
207    if test -n "$VERBOSE" ; then
208      $CAD3D tmp.3d tmp.dxf
209      exitcode=$?
[cfa16ef]210    else
[2b0cec5]211      $CAD3D tmp.3d tmp.dxf > /dev/null
212      exitcode=$?
[cfa16ef]213    fi
[2b0cec5]214    if [ -n "$VALGRIND" ] ; then
215      if [ $exitcode = "$vg_error" ] ; then
216        cat "$vg_log"
217        rm "$vg_log"
[62e7e3c]218        exit 1
219      fi
[2b0cec5]220      rm "$vg_log"
[cfa16ef]221    fi
[2b0cec5]222    [ "$exitcode" = 0 ] || exit 1
223    if test -n "$VERBOSE" ; then
224      diff "$dxffile" tmp.dxf || exit 1
225    else
226      cmp -s "$dxffile" tmp.dxf || exit 1
227    fi ;;
228  no)
229    test -f tmp.3d || exit 1 ;;
230  fail)
231    test -f tmp.3d && exit 1
232    # Check that last line doesn't contains "Bug in program detected"
233    case `tail -n 1 tmp.out` in
234    *"Bug in program detected"*) exit 1 ;;
235    esac ;;
236  *)
237    echo "Bad value for pos: '$pos'" ; exit 1 ;;
238  esac
[cd971de]239
[2b0cec5]240  out=$srcdir/$file.out
241  if test -f "$out" ; then
242    # Check output is as expected.
243    if test -n "$VERBOSE" ; then
244      sed '1,/^Copyright/d;/^\(CPU t\|T\)ime used  *[0-9][0-9.]*s$/d;s!.*/src/\(cavern: \)!\1!' tmp.out|diff "$out" - || exit 1
245    else
246      sed '1,/^Copyright/d;/^\(CPU t\|T\)ime used  *[0-9][0-9.]*s$/d;s!.*/src/\(cavern: \)!\1!' tmp.out|cmp -s "$out" - || exit 1
[cd971de]247    fi
[cfa16ef]248  fi
[2b0cec5]249  rm -f tmp.*
[4a2bb00]250done
[cfcfd28]251test -n "$VERBOSE" && echo "Test passed"
[fbc3a20]252exit 0
Note: See TracBrowser for help on using the repository browser.