source: git/tests/cavern.tst @ cd91e16

RELEASE/1.2debug-cidebug-ci-sanitisersstereowalls-data
Last change on this file since cd91e16 was cd91e16, checked in by Olly Betts <olly@…>, 11 years ago

tests/cavern.tst: Run diffpos <expected> <actual> so the reports of
'Added' and 'Deleted' stations are the more natural way round.

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