source: git/tests/cavern.tst @ b5283af

RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereostereo-2025walls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change on this file since b5283af was 699bf50, checked in by Olly Betts <olly@…>, 11 years ago

src/commands.c: If *units is used to set units for LEVEL, PLUMB, or
POSITION, give an error rather than quietly ignore the attempt.
tests/: New regression testcase bad_units_qlist.

  • Property mode set to 100755
File size: 11.0 KB
RevLine 
[fbc3a20]1#!/bin/sh
[b4fe9fb]2#
3# Survex test suite - cavern tests
[a4fb8d0]4# Copyright (C) 1999-2004,2005,2006,2010,2012,2013,2014 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
[d4d8efe]30: ${CAVERN="$testdir"/../src/cavern}
31: ${DIFFPOS="$testdir"/../src/diffpos}
[64d37a3]32: ${CAD3D="$testdir"/../src/cad3d}
[647407d]33
[e0c8f98]34: ${TESTS=${*:-"singlefix singlereffix oneleg midpoint noose cross firststn\
[107b8bd]35 deltastar deltastar2 bug3 calibrate_tape nosurvey2 cartesian cartesian2\
[dcbcae0]36 lengthunits angleunits cmd_alias cmd_truncate cmd_case cmd_fix cmd_solve\
[4fb15a1]37 cmd_entrance cmd_entrance_bad cmd_sd cmd_sd_bad cmd_fix_bad cmd_set\
38 cmd_set_bad beginroot revcomplist break_replace_pfx bug0 bug1 bug2 bug4 bug5\
[cfa16ef]39 expobug require export export2 includecomment\
[4fb15a1]40 self_loop self_eq_loop reenterwarn cmd_default cmd_prefix cmd_prefix_bad\
[cfa16ef]41 singlefixerr singlereffixerr\
42 begin_no_end end_no_begin end_no_begin_nest require_fail\
43 exporterr1 exporterr2 exporterr3 exporterr4 exporterr5\
44 exporterr1b exporterr2b exporterr3b exporterr6 exporterr6b\
[53e0bd1]45 hanging_cpt badinc badinc2 badinc3 badinc4 non_existant_file ONELEG\
[52ec967]46 stnsurvey1 stnsurvey2 stnsurvey3\
[0af7076]47 tapelessthandepth longname chinabug chinabug2\
[54c4612]48 multinormal multinormignall multidiving multicylpolar multicartesian\
49 multinosurv multinormalbad multibug\
[e0c7cd1]50 cmd_title cmd_titlebad cmd_dummy cmd_infer cmd_date cmd_datebad cmd_datebad2\
[4fb15a1]51 cartes diving cylpolar normal normal_bad normignall nosurv cmd_flags\
52 bad_cmd_flags plumb unusedstation exportnakedbegin oldestyle bugdz\
53 baddatacylpolar badnewline badquantities imgoffbyone infereqtopofil 3sdfixbug\
54 omitclino back notentranceorexport inferunknown inferexports bad_units_factor\
[699bf50]55 bad_units_qlist\
[b4fe9fb]56 percent_gradient dotinsurvey leandroclino lowsd revdir gettokennullderef\
[dfe4a520]57 nosurveyhanging cmd_solve_nothing cmd_solve_nothing_implicit\
[fb94b6a8]58 lech level 2fixbug declination.dat ignore.dat backread.dat dot17 3dcorner\
[e363f8b]59 surfequate passage hanging_lrud equatenosuchstn surveytypo\
[da96015]60 skipafterbadomit passagebad badreadingdotplus badcalibrate calibrate_clino\
[dcbcae0]61 badunits badbegin anonstn anonstnbad anonstnrev"}}
[cd971de]62
63LC_ALL=C
64export LC_ALL
[6e47b72]65SURVEXLANG=en
[cd971de]66export SURVEXLANG
[4515ba18]67
[67a2822]68vg_error=123
69vg_log=vg.log
70if [ -n "$VALGRIND" ] ; then
71  rm -f "$vg_log"
72  CAVERN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAVERN"
[38c4c5c]73  DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS"
[33a2d49]74  CAD3D="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAD3D"
[67a2822]75fi
76
[4515ba18]77for file in $TESTS ; do
[cfa16ef]78  # how many warnings to expect
[b97d134]79  warn=
80  # how many errors to expect
81  error=
[0d3c93b]82  case $file in
[b97d134]83  singlefix) pos=yes ; warn=1;;
84  singlereffix) pos=yes ; warn=0 ;;
85  oneleg) pos=yes ; warn=0 ;;
86  midpoint) pos=yes ; warn=0 ;;
87  noose) pos=yes ; warn=0 ;;
88  cross) pos=yes ; warn=0 ;;
89  firststn) pos=yes ; warn=0 ;;
90  deltastar) pos=yes ; warn=0 ;;
91  deltastar2) pos=yes ; warn=0 ;;
92  bug3) pos=yes ; warn=0 ;;
93  calibrate_tape) pos=yes ; warn=0 ;;
94  nosurvey2) pos=yes ; warn=0 ;;
95  cartesian) pos=yes ; warn=0 ;;
[107b8bd]96  cartesian2) pos=yes ; warn=0 ;;
[b97d134]97  lengthunits) pos=yes ; warn=0 ;;
98  angleunits) pos=yes ; warn=0 ;;
[dcbcae0]99  cmd_alias) pos=yes ;;
[b97d134]100  cmd_truncate) pos=yes ; warn=0 ;;
101  cmd_case) pos=yes ; warn=0 ;;
102  cmd_fix) pos=yes ; warn=1 ;;
[c80bd34]103  cmd_fix_bad) pos=fail ; error=10 ;;
[b97d134]104  cmd_solve) pos=yes ; warn=0 ;;
105  cmd_entrance) pos=no ; warn=0 ;;
[4fb15a1]106  cmd_entrance_bad) pos=fail ; warn=0 ;;
[3a33d12]107  cmd_sd) pos=no ; warn=0 ;;
[fa42426]108  cmd_sd_bad) pos=fail ; error=7 ;;
[11f9067]109  cmd_set) pos=no ; warn=0 ;;
[da96015]110  cmd_set_bad) pos=fail ; error=8 ;;
[cfa16ef]111  beginroot) pos=no ;;
[b97d134]112  revcomplist) pos=no ; warn=0 ;;
113  break_replace_pfx) pos=no ; warn=0 ;;
114  bug0) pos=no ; warn=0 ;;
115  bug1) pos=no ; warn=0 ;;
116  bug2) pos=no ; warn=0 ;;
117  bug4) pos=no ; warn=0 ;;
118  bug5) pos=no ; warn=0 ;;
119  expobug) pos=no ; warn=0 ;;
120  require) pos=no ; warn=0 ;;
121  export) pos=no ; warn=0 ;;
122  export2) pos=no ; warn=0 ;;
123  includecomment) pos=no ; warn=0 ;;
124  self_loop) pos=fail ; warn=0 ;;
125  self_eq_loop) pos=no ; warn=1 ;;
126  reenterwarn) pos=no ; warn=2 ;;
127  cmd_default) pos=no ; warn=3 ;;
128  singlereffixerr) pos=no ; warn=0 ;;
129  cmd_prefix) pos=no ; warn=1 ;;
[4fb15a1]130  cmd_prefix_bad) pos=fail ; warn=1 ;;
[b97d134]131  singlefixerr) pos=no ; warn=1 ;;
132  tapelessthandepth) pos=no ; warn=1 ;;
133  chinabug2) pos=no ; warn=0 ;;
134  longname) pos=no ; warn=0 ;;
[097c0b1]135  chinabug) pos=fail ;;
[cfa16ef]136  begin_no_end) pos=fail ;;
137  end_no_begin) pos=fail ;;
138  end_no_begin_nest) pos=fail ;;
139  require_fail) pos=fail ;;
140  exporterr1) pos=fail ;;
141  exporterr2) pos=fail ;;
142  exporterr3) pos=fail ;;
143  exporterr4) pos=fail ;;
144  exporterr5) pos=fail ;;
145  exporterr1b) pos=fail ;;
146  exporterr2b) pos=fail ;;
147  exporterr3b) pos=fail ;;
148  exporterr6) pos=fail ;;
149  exporterr6b) pos=fail ;;
150  hanging_cpt) pos=fail ;;
151  badinc) pos=fail ;;
152  badinc2) pos=fail ;;
[53e0bd1]153  badinc3) pos=fail ;;
154  badinc4) pos=fail ;;
[cfa16ef]155  non_existant_file) pos=fail ;;
[f4b609d]156  ONELEG) pos=fail ;;
[cfa16ef]157  stnsurvey1) pos=fail ;;
158  stnsurvey2) pos=fail ;;
[52ec967]159  stnsurvey3) pos=fail ;;
[b97d134]160  multinormal) pos=yes ; warn=0 ;;
161  multinormignall) pos=yes ; warn=0 ;;
162  multidiving) pos=yes ; warn=0 ;;
[54c4612]163  multicylpolar) pos=yes ; warn=0 ;;
[b97d134]164  multicartesian) pos=yes ; warn=0 ;;
165  multinosurv) pos=yes ; warn=0 ;;
[eef4d8c]166  multinormalbad) pos=fail ;;
[b97d134]167  multibug) pos=no ; warn=0 ;;
168  cmd_title) pos=no ; warn=0 ;;
[457a390]169  cmd_titlebad) pos=fail ; error=4 ;;
[52b6220]170  cmd_dummy) pos=no ; warn=0 ;;
[f964a20]171  cmd_infer) pos=yes ; warn=0 ;;
[1ee204e]172  cmd_date) pos=no ; warn=4 ;;
[ce8f81c]173  cmd_datebad) pos=no ; warn=37 ;;
174  cmd_datebad2) pos=fail ; warn=20 ; error=2 ;;
[7b25479]175  cartes) pos=yes ; warn=0 ;;
176  diving) pos=yes ; warn=0 ;;
[54c4612]177  cylpolar) pos=yes ; warn=0 ;;
[7b25479]178  normal) pos=yes ; warn=0 ;;
[4fb15a1]179  normal_bad) pos=fail ; warn=0 ;;
[7b25479]180  normignall) pos=yes ; warn=0 ;;
181  nosurv) pos=yes ; warn=0 ;;
[9881759]182  cmd_flags) pos=no ; warn=0 ;;
183  bad_cmd_flags) pos=fail ; error=19 ;;
[26a805f]184  plumb) pos=yes ; warn=0 ;;
[7d86d87]185  unusedstation) pos=no ; warn=2 ;;
[d6d3576]186  oldestyle) pos=no ; warn=1 ;;
[4dcd3af]187  exportnakedbegin) pos=fail ;;
[a6d094f]188  bugdz) pos=yes ; warn=0 ;;
189  baddatacylpolar) pos=fail ; error=1 ;;
[6114207]190  badnewline) pos=fail ; error=2 ;;
[4b156b3]191  badquantities) pos=fail ; error=11 ;;
192  imgoffbyone) pos=yes ;; # don't actually care about coords, just the names
[107b8bd]193  infereqtopofil) pos=yes ; warn=0 ;;
[a9e3f6c]194  3sdfixbug) pos=yes ; warn=0 ;;
[5b7c1b7]195  omitclino) pos=yes ; warn=0 ;;
[0b71cfc]196  back) pos=yes; warn=0 ;;
[b14f44f]197  notentranceorexport) pos=fail; warn=0 ;;
[c00c74a9]198  inferunknown) pos=fail; error=1 ;;
199  inferexports) pos=no; warn=0 ;;
[a4fb8d0]200  bad_units_factor) pos=fail; error=6 ;;
[699bf50]201  bad_units_qlist) pos=fail; error=3 ;;
[cfcfd28]202  percent_gradient) pos=yes; warn=0 ;;
[0fa7aac]203  dotinsurvey) pos=no; warn=2 ;;
[21c226e]204  leandroclino) pos=yes; warn=0 ;;
[42d23c5]205  lowsd) pos=no; warn=0 ;;
[e7576f6]206  revdir) pos=yes; warn=0 ;;
[b4fe9fb]207  gettokennullderef) pos=fail ;;
208  lech) pos=no; warn=0 ;;
209  level) pos=yes; warn=0 ;;
210  2fixbug) pos=no; warn=0 ;;
[396eb21]211  declination.dat|ignore.dat|backread.dat) pos=yes; warn=0 ;;
[64d37a3]212  dot17) pos=yes; warn=0 ;;
213  3dcorner) pos=yes; warn=0 ;;
214  surfequate) pos=dxf; warn=0 ;;
[1fa9b83]215  nosurveyhanging) pos=fail ;;
[f5627353]216  cmd_solve_hanging) pos=fail ;;
[dfe4a520]217  cmd_solve_nothing*) pos=no; warn=0 ;;
[fb94b6a8]218  passage) pos=no; warn=0 ;;
[d333899]219  hanging_lrud) pos=fail; error=1 ;;
[cd971de]220  equatenosuchstn) pos=fail; error=1 ;;
[335f37a]221  surveytypo) pos=fail ;; # Actually, 2 errors, but we exit before the error count.
[e363f8b]222  skipafterbadomit) pos=fail; error=1 ;;
[4bc4d58]223  passagebad) pos=fail; error=3 ;;
[17c1dcd]224  badreadingdotplus) pos=fail ;;
[4b14118]225  badcalibrate) pos=fail; error=3 ;;
[93935c7]226  calibrate_clino) pos=yes; warn=8 ;;
[da96015]227  badunits) pos=fail; error=12 ;;
228  badbegin) pos=fail; error=2 ;;
[710ecc1]229  anonstn) pos=yes; warn=0; error=0 ;;
[dcbcae0]230  anonstnbad) pos=fail; warn=1; error=6 ;;
[a2c33ae]231  anonstnrev) pos=yes; warn=0; error=0 ;;
[f0b3334]232  *) echo "Warning: don't know how to run test '$file' - skipping it"
233     file='' ;;
[cfa16ef]234  esac
[4a2bb00]235
[cfcfd28]236  if test -n "$file" ; then
237    echo "$file"
[0d3c93b]238    case $file in
[b4fe9fb]239    *.*)
240      input="$srcdir/$file"
[0d3c93b]241      posfile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.pos/'`
242      dxffile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.dxf/'` ;;
[b4fe9fb]243    *)
244      input="$srcdir/$file.svx"
[64d37a3]245      posfile="$srcdir/$file.pos"
246      dxffile="$srcdir/$file.dxf" ;;
[b4fe9fb]247    esac
[87681b8]248    rm -f tmp.*
[b4fe9fb]249    $CAVERN "$input" --output=tmp > tmp.out
250    exitcode=$?
251    test -n "$VERBOSE" && cat tmp.out
[67a2822]252    if [ -n "$VALGRIND" ] ; then
253      if [ $exitcode = "$vg_error" ] ; then
254        cat "$vg_log"
255        rm "$vg_log"
256        exit 1
257      fi
258      rm "$vg_log"
259    fi
[b4fe9fb]260    if test fail = "$pos" ; then
261      # success gives 0, signal (128 + <signal number>)
262      test $exitcode = 1 || exit 1
[cfa16ef]263    else
[b4fe9fb]264      test $exitcode = 0 || exit 1
[cfa16ef]265    fi
[b97d134]266    if test -n "$warn" ; then
[87681b8]267      w=`sed '$!d;$s/^Done.*/0/;s/[^0-9]*\([0-9]*\).*/\1/' tmp.out`
[b97d134]268      test x"$w" = x"$warn" || exit 1
269    fi
270    if test -n "$error" ; then
[87681b8]271      e=`sed '$!d;$s/^Done.*/0/;s/[^0-9]*[0-9][0-9]*[^0-9][^0-9]*\([0-9][0-9]*\).*/\1/;s/\(.*[^0-9].*\)/0/' tmp.out`
[b97d134]272      test x"$e" = x"$error" || exit 1
[cfa16ef]273    fi
[b4fe9fb]274    nan=`sed 's/.*\<[Nn]a[Nn]m\?\>.*/x/p;d' tmp.out`
275    if test -n "$nan" ; then
276      exit 1
277    fi
[b97d134]278
[0d3c93b]279    case $pos in
[cfa16ef]280    yes)
281      if test -n "$VERBOSE" ; then
[cd91e16]282        $DIFFPOS "$posfile" tmp.3d
[38c4c5c]283        exitcode=$?
[cfa16ef]284      else
[cd91e16]285        $DIFFPOS "$posfile" tmp.3d > /dev/null
[38c4c5c]286        exitcode=$?
287      fi
288      if [ -n "$VALGRIND" ] ; then
289        if [ $exitcode = "$vg_error" ] ; then
290          cat "$vg_log"
291          rm "$vg_log"
292          exit 1
293        fi
294        rm "$vg_log"
295      fi
296      [ "$exitcode" = 0 ] || exit 1
297      ;;
[64d37a3]298    dxf)
299      if test -n "$VERBOSE" ; then
[33a2d49]300        $CAD3D tmp.3d tmp.dxf
301        exitcode=$?
302      else
303        $CAD3D tmp.3d tmp.dxf > /dev/null
304        exitcode=$?
305      fi
306      if [ -n "$VALGRIND" ] ; then
307        if [ $exitcode = "$vg_error" ] ; then
308          cat "$vg_log"
309          rm "$vg_log"
310          exit 1
311        fi
312        rm "$vg_log"
313      fi
314      [ "$exitcode" = 0 ] || exit 1
315      if test -n "$VERBOSE" ; then
[64d37a3]316        diff tmp.dxf "$dxffile" || exit 1
317      else
318        cmp -s tmp.dxf "$dxffile" || exit 1
319      fi ;;
[cfa16ef]320    no)
[87681b8]321      test -f tmp.3d || exit 1 ;;
[cfa16ef]322    fail)
[f5627353]323      test -f tmp.3d && exit 1
324      # Check that last line doesn't contains "Bug in program detected"
325      case `tail -n 1 tmp.out` in
326      *"Bug in program detected"*) exit 1 ;;
327      esac ;;
[097c0b1]328    *)
[cfcfd28]329      echo "Bad value for pos: '$pos'" ; exit 1 ;;
[cfa16ef]330    esac
[cd971de]331
332    if test -f "$file.out" ; then
333      # Check output is as expected.
334      if test -n "$VERBOSE" ; then
[075c051]335        sed '1,/^Copyright/d;/^\(CPU t\|T\)ime used  *[0-9][0-9.]*s$/d;s!.*/src/\(cavern: \)!\1!' tmp.out|diff - "$file.out" || exit 1
[cd971de]336      else
[075c051]337        sed '1,/^Copyright/d;/^\(CPU t\|T\)ime used  *[0-9][0-9.]*s$/d;s!.*/src/\(cavern: \)!\1!' tmp.out|diff - "$file.out" > /dev/null || exit 1
[cd971de]338      fi
339    fi
[87681b8]340    rm -f tmp.*
[cfa16ef]341  fi
[4a2bb00]342done
[cfcfd28]343test -n "$VERBOSE" && echo "Test passed"
[fbc3a20]344exit 0
Note: See TracBrowser for help on using the repository browser.