source: git/tests/cavern.tst@ a4fb8d0

RELEASE/1.2 debug-ci debug-ci-sanitisers faster-cavernlog log-select main stereo stereo-2025 walls-data walls-data-hanging-as-warning warn-only-for-hanging-survey
Last change on this file since a4fb8d0 was a4fb8d0, checked in by Olly Betts <olly@…>, 12 years ago

tests/bad_units_factor.svx,tests/cavern.tst: Test that "*units
backclino 0 percent" gives an error about the factor being zero.
tests/Makefile.am,tests/bad_units_factor.out: Add expected output
to make sure we're getting the errors we expect, not just the
expected number of errors.

  • 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\
[b4fe9fb]55 percent_gradient dotinsurvey leandroclino lowsd revdir gettokennullderef\
[dfe4a520]56 nosurveyhanging cmd_solve_nothing cmd_solve_nothing_implicit\
[fb94b6a8]57 lech level 2fixbug declination.dat ignore.dat backread.dat dot17 3dcorner\
[e363f8b]58 surfequate passage hanging_lrud equatenosuchstn surveytypo\
[da96015]59 skipafterbadomit passagebad badreadingdotplus badcalibrate calibrate_clino\
[dcbcae0]60 badunits badbegin anonstn anonstnbad anonstnrev"}}
[cd971de]61
62LC_ALL=C
63export LC_ALL
[6e47b72]64SURVEXLANG=en
[cd971de]65export SURVEXLANG
[4515ba18]66
[67a2822]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"
[38c4c5c]72 DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS"
[33a2d49]73 CAD3D="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAD3D"
[67a2822]74fi
75
[4515ba18]76for file in $TESTS ; do
[cfa16ef]77 # how many warnings to expect
[b97d134]78 warn=
79 # how many errors to expect
80 error=
[0d3c93b]81 case $file in
[b97d134]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 ;;
[107b8bd]95 cartesian2) pos=yes ; warn=0 ;;
[b97d134]96 lengthunits) pos=yes ; warn=0 ;;
97 angleunits) pos=yes ; warn=0 ;;
[dcbcae0]98 cmd_alias) pos=yes ;;
[b97d134]99 cmd_truncate) pos=yes ; warn=0 ;;
100 cmd_case) pos=yes ; warn=0 ;;
101 cmd_fix) pos=yes ; warn=1 ;;
[c80bd34]102 cmd_fix_bad) pos=fail ; error=10 ;;
[b97d134]103 cmd_solve) pos=yes ; warn=0 ;;
104 cmd_entrance) pos=no ; warn=0 ;;
[4fb15a1]105 cmd_entrance_bad) pos=fail ; warn=0 ;;
[3a33d12]106 cmd_sd) pos=no ; warn=0 ;;
[fa42426]107 cmd_sd_bad) pos=fail ; error=7 ;;
[11f9067]108 cmd_set) pos=no ; warn=0 ;;
[da96015]109 cmd_set_bad) pos=fail ; error=8 ;;
[cfa16ef]110 beginroot) pos=no ;;
[b97d134]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 ;;
[4fb15a1]129 cmd_prefix_bad) pos=fail ; warn=1 ;;
[b97d134]130 singlefixerr) pos=no ; warn=1 ;;
131 tapelessthandepth) pos=no ; warn=1 ;;
132 chinabug2) pos=no ; warn=0 ;;
133 longname) pos=no ; warn=0 ;;
[097c0b1]134 chinabug) pos=fail ;;
[cfa16ef]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 ;;
[53e0bd1]152 badinc3) pos=fail ;;
153 badinc4) pos=fail ;;
[cfa16ef]154 non_existant_file) pos=fail ;;
[f4b609d]155 ONELEG) pos=fail ;;
[cfa16ef]156 stnsurvey1) pos=fail ;;
157 stnsurvey2) pos=fail ;;
[52ec967]158 stnsurvey3) pos=fail ;;
[b97d134]159 multinormal) pos=yes ; warn=0 ;;
160 multinormignall) pos=yes ; warn=0 ;;
161 multidiving) pos=yes ; warn=0 ;;
[54c4612]162 multicylpolar) pos=yes ; warn=0 ;;
[b97d134]163 multicartesian) pos=yes ; warn=0 ;;
164 multinosurv) pos=yes ; warn=0 ;;
[eef4d8c]165 multinormalbad) pos=fail ;;
[b97d134]166 multibug) pos=no ; warn=0 ;;
167 cmd_title) pos=no ; warn=0 ;;
[457a390]168 cmd_titlebad) pos=fail ; error=4 ;;
[52b6220]169 cmd_dummy) pos=no ; warn=0 ;;
[f964a20]170 cmd_infer) pos=yes ; warn=0 ;;
[1ee204e]171 cmd_date) pos=no ; warn=4 ;;
[ce8f81c]172 cmd_datebad) pos=no ; warn=37 ;;
173 cmd_datebad2) pos=fail ; warn=20 ; error=2 ;;
[7b25479]174 cartes) pos=yes ; warn=0 ;;
175 diving) pos=yes ; warn=0 ;;
[54c4612]176 cylpolar) pos=yes ; warn=0 ;;
[7b25479]177 normal) pos=yes ; warn=0 ;;
[4fb15a1]178 normal_bad) pos=fail ; warn=0 ;;
[7b25479]179 normignall) pos=yes ; warn=0 ;;
180 nosurv) pos=yes ; warn=0 ;;
[9881759]181 cmd_flags) pos=no ; warn=0 ;;
182 bad_cmd_flags) pos=fail ; error=19 ;;
[26a805f]183 plumb) pos=yes ; warn=0 ;;
[7d86d87]184 unusedstation) pos=no ; warn=2 ;;
[d6d3576]185 oldestyle) pos=no ; warn=1 ;;
[4dcd3af]186 exportnakedbegin) pos=fail ;;
[a6d094f]187 bugdz) pos=yes ; warn=0 ;;
188 baddatacylpolar) pos=fail ; error=1 ;;
[6114207]189 badnewline) pos=fail ; error=2 ;;
[4b156b3]190 badquantities) pos=fail ; error=11 ;;
191 imgoffbyone) pos=yes ;; # don't actually care about coords, just the names
[107b8bd]192 infereqtopofil) pos=yes ; warn=0 ;;
[a9e3f6c]193 3sdfixbug) pos=yes ; warn=0 ;;
[5b7c1b7]194 omitclino) pos=yes ; warn=0 ;;
[0b71cfc]195 back) pos=yes; warn=0 ;;
[b14f44f]196 notentranceorexport) pos=fail; warn=0 ;;
[c00c74a9]197 inferunknown) pos=fail; error=1 ;;
198 inferexports) pos=no; warn=0 ;;
[a4fb8d0]199 bad_units_factor) pos=fail; error=6 ;;
[cfcfd28]200 percent_gradient) pos=yes; warn=0 ;;
[0fa7aac]201 dotinsurvey) pos=no; warn=2 ;;
[21c226e]202 leandroclino) pos=yes; warn=0 ;;
[42d23c5]203 lowsd) pos=no; warn=0 ;;
[e7576f6]204 revdir) pos=yes; warn=0 ;;
[b4fe9fb]205 gettokennullderef) pos=fail ;;
206 lech) pos=no; warn=0 ;;
207 level) pos=yes; warn=0 ;;
208 2fixbug) pos=no; warn=0 ;;
[396eb21]209 declination.dat|ignore.dat|backread.dat) pos=yes; warn=0 ;;
[64d37a3]210 dot17) pos=yes; warn=0 ;;
211 3dcorner) pos=yes; warn=0 ;;
212 surfequate) pos=dxf; warn=0 ;;
[1fa9b83]213 nosurveyhanging) pos=fail ;;
[f5627353]214 cmd_solve_hanging) pos=fail ;;
[dfe4a520]215 cmd_solve_nothing*) pos=no; warn=0 ;;
[fb94b6a8]216 passage) pos=no; warn=0 ;;
[d333899]217 hanging_lrud) pos=fail; error=1 ;;
[cd971de]218 equatenosuchstn) pos=fail; error=1 ;;
[335f37a]219 surveytypo) pos=fail ;; # Actually, 2 errors, but we exit before the error count.
[e363f8b]220 skipafterbadomit) pos=fail; error=1 ;;
[4bc4d58]221 passagebad) pos=fail; error=3 ;;
[17c1dcd]222 badreadingdotplus) pos=fail ;;
[4b14118]223 badcalibrate) pos=fail; error=3 ;;
[93935c7]224 calibrate_clino) pos=yes; warn=8 ;;
[da96015]225 badunits) pos=fail; error=12 ;;
226 badbegin) pos=fail; error=2 ;;
[710ecc1]227 anonstn) pos=yes; warn=0; error=0 ;;
[dcbcae0]228 anonstnbad) pos=fail; warn=1; error=6 ;;
[a2c33ae]229 anonstnrev) pos=yes; warn=0; error=0 ;;
[f0b3334]230 *) echo "Warning: don't know how to run test '$file' - skipping it"
231 file='' ;;
[cfa16ef]232 esac
[4a2bb00]233
[cfcfd28]234 if test -n "$file" ; then
235 echo "$file"
[0d3c93b]236 case $file in
[b4fe9fb]237 *.*)
238 input="$srcdir/$file"
[0d3c93b]239 posfile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.pos/'`
240 dxffile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.dxf/'` ;;
[b4fe9fb]241 *)
242 input="$srcdir/$file.svx"
[64d37a3]243 posfile="$srcdir/$file.pos"
244 dxffile="$srcdir/$file.dxf" ;;
[b4fe9fb]245 esac
[87681b8]246 rm -f tmp.*
[b4fe9fb]247 $CAVERN "$input" --output=tmp > tmp.out
248 exitcode=$?
249 test -n "$VERBOSE" && cat tmp.out
[67a2822]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
[b4fe9fb]258 if test fail = "$pos" ; then
259 # success gives 0, signal (128 + <signal number>)
260 test $exitcode = 1 || exit 1
[cfa16ef]261 else
[b4fe9fb]262 test $exitcode = 0 || exit 1
[cfa16ef]263 fi
[b97d134]264 if test -n "$warn" ; then
[87681b8]265 w=`sed '$!d;$s/^Done.*/0/;s/[^0-9]*\([0-9]*\).*/\1/' tmp.out`
[b97d134]266 test x"$w" = x"$warn" || exit 1
267 fi
268 if test -n "$error" ; then
[87681b8]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`
[b97d134]270 test x"$e" = x"$error" || exit 1
[cfa16ef]271 fi
[b4fe9fb]272 nan=`sed 's/.*\<[Nn]a[Nn]m\?\>.*/x/p;d' tmp.out`
273 if test -n "$nan" ; then
274 exit 1
275 fi
[b97d134]276
[0d3c93b]277 case $pos in
[cfa16ef]278 yes)
279 if test -n "$VERBOSE" ; then
[cd91e16]280 $DIFFPOS "$posfile" tmp.3d
[38c4c5c]281 exitcode=$?
[cfa16ef]282 else
[cd91e16]283 $DIFFPOS "$posfile" tmp.3d > /dev/null
[38c4c5c]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 ;;
[64d37a3]296 dxf)
297 if test -n "$VERBOSE" ; then
[33a2d49]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
[64d37a3]314 diff tmp.dxf "$dxffile" || exit 1
315 else
316 cmp -s tmp.dxf "$dxffile" || exit 1
317 fi ;;
[cfa16ef]318 no)
[87681b8]319 test -f tmp.3d || exit 1 ;;
[cfa16ef]320 fail)
[f5627353]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 ;;
[097c0b1]326 *)
[cfcfd28]327 echo "Bad value for pos: '$pos'" ; exit 1 ;;
[cfa16ef]328 esac
[cd971de]329
330 if test -f "$file.out" ; then
331 # Check output is as expected.
332 if test -n "$VERBOSE" ; then
[075c051]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
[cd971de]334 else
[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" > /dev/null || exit 1
[cd971de]336 fi
337 fi
[87681b8]338 rm -f tmp.*
[cfa16ef]339 fi
[4a2bb00]340done
[cfcfd28]341test -n "$VERBOSE" && echo "Test passed"
[fbc3a20]342exit 0
Note: See TracBrowser for help on using the repository browser.