source: git/trunk/tests/cavern.tst @ 7bb8184

Last change on this file since 7bb8184 was 7bb8184, checked in by Olly Betts <olly@…>, 13 years ago

Retagging 1.2.0

git-svn-id: file:///home/survex-svn/survex/tags/1.2.0@3664 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100755
File size: 8.8 KB
Line 
1#!/bin/sh
2#
3# Survex test suite - cavern tests
4# Copyright (C) 1999-2004,2005,2006,2010 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_truncate cmd_case cmd_fix cmd_solve\
37 cmd_entrance cmd_sd cmd_sd_bad cmd_fix_bad cmd_set cmd_set_bad\
38 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\
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 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 normignall nosurv cmd_flags bad_cmd_flags\
52 plumb unusedstation exportnakedbegin oldestyle bugdz baddatacylpolar\
53 badnewline badquantities imgoffbyone infereqtopofil 3sdfixbug omitclino back\
54 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"}}
59
60for file in $TESTS ; do
61  # how many warnings to expect
62  warn=
63  # how many errors to expect
64  error=
65  case $file in
66  singlefix) pos=yes ; warn=1;;
67  singlereffix) pos=yes ; warn=0 ;;
68  oneleg) pos=yes ; warn=0 ;;
69  midpoint) pos=yes ; warn=0 ;;
70  noose) pos=yes ; warn=0 ;;
71  cross) pos=yes ; warn=0 ;;
72  firststn) pos=yes ; warn=0 ;;
73  deltastar) pos=yes ; warn=0 ;;
74  deltastar2) pos=yes ; warn=0 ;;
75  bug3) pos=yes ; warn=0 ;;
76  calibrate_tape) pos=yes ; warn=0 ;;
77  nosurvey2) pos=yes ; warn=0 ;;
78  cartesian) pos=yes ; warn=0 ;;
79  cartesian2) pos=yes ; warn=0 ;;
80  lengthunits) pos=yes ; warn=0 ;;
81  angleunits) pos=yes ; warn=0 ;;
82  cmd_truncate) pos=yes ; warn=0 ;;
83  cmd_case) pos=yes ; warn=0 ;;
84  cmd_fix) pos=yes ; warn=1 ;;
85  cmd_fix_bad) pos=fail ; error=10 ;;
86  cmd_solve) pos=yes ; warn=0 ;;
87  cmd_entrance) pos=no ; warn=0 ;;
88  cmd_sd) pos=no ; warn=0 ;;
89  cmd_sd_bad) pos=fail ; error=7 ;;
90  cmd_set) pos=no ; warn=0 ;;
91  cmd_set_bad) pos=fail ; error=7 ;;
92  beginroot) pos=no ;;
93  revcomplist) pos=no ; warn=0 ;;
94  break_replace_pfx) pos=no ; warn=0 ;;
95  bug0) pos=no ; warn=0 ;;
96  bug1) pos=no ; warn=0 ;;
97  bug2) pos=no ; warn=0 ;;
98  bug4) pos=no ; warn=0 ;;
99  bug5) pos=no ; warn=0 ;;
100  expobug) pos=no ; warn=0 ;;
101  require) pos=no ; warn=0 ;;
102  export) pos=no ; warn=0 ;;
103  export2) pos=no ; warn=0 ;;
104  includecomment) pos=no ; warn=0 ;;
105  self_loop) pos=fail ; warn=0 ;;
106  self_eq_loop) pos=no ; warn=1 ;;
107  reenterwarn) pos=no ; warn=2 ;;
108  cmd_default) pos=no ; warn=3 ;;
109  singlereffixerr) pos=no ; warn=0 ;;
110  cmd_prefix) pos=no ; warn=1 ;;
111  singlefixerr) pos=no ; warn=1 ;;
112  tapelessthandepth) pos=no ; warn=1 ;;
113  chinabug2) pos=no ; warn=0 ;;
114  longname) pos=no ; warn=0 ;;
115  chinabug) pos=fail ;;
116  begin_no_end) pos=fail ;;
117  end_no_begin) pos=fail ;;
118  end_no_begin_nest) pos=fail ;;
119  require_fail) pos=fail ;;
120  exporterr1) pos=fail ;;
121  exporterr2) pos=fail ;;
122  exporterr3) pos=fail ;;
123  exporterr4) pos=fail ;;
124  exporterr5) pos=fail ;;
125  exporterr1b) pos=fail ;;
126  exporterr2b) pos=fail ;;
127  exporterr3b) pos=fail ;;
128  exporterr6) pos=fail ;;
129  exporterr6b) pos=fail ;;
130  hanging_cpt) pos=fail ;;
131  badinc) pos=fail ;;
132  badinc2) pos=fail ;;
133  non_existant_file) pos=fail ;;
134  ONELEG) pos=fail ;;
135  stnsurvey1) pos=fail ;;
136  stnsurvey2) pos=fail ;;
137  stnsurvey3) pos=fail ;;
138  multinormal) pos=yes ; warn=0 ;;
139  multinormignall) pos=yes ; warn=0 ;;
140  multidiving) pos=yes ; warn=0 ;;
141  multicylpolar) pos=yes ; warn=0 ;;
142  multicartesian) pos=yes ; warn=0 ;;
143  multinosurv) pos=yes ; warn=0 ;;
144  multinormalbad) pos=fail ;;
145  multibug) pos=no ; warn=0 ;;
146  cmd_title) pos=no ; warn=0 ;;
147  cmd_titlebad) pos=fail ; error=4 ;;
148  cmd_dummy) pos=no ; warn=0 ;;
149  cmd_infer) pos=yes ; warn=0 ;;
150  cmd_date) pos=no ; warn=4 ;;
151  cmd_datebad) pos=fail ; error=37 ;;
152  cmd_datebad2) pos=fail ; error=21 ;;
153  cartes) pos=yes ; warn=0 ;;
154  diving) pos=yes ; warn=0 ;;
155  cylpolar) pos=yes ; warn=0 ;;
156  normal) pos=yes ; warn=0 ;;
157  normignall) pos=yes ; warn=0 ;;
158  nosurv) pos=yes ; warn=0 ;;
159  cmd_flags) pos=no ; warn=0 ;;
160  bad_cmd_flags) pos=fail ; error=19 ;;
161  plumb) pos=yes ; warn=0 ;;
162  unusedstation) pos=no ; warn=2 ;;
163  oldestyle) pos=no ; warn=1 ;;
164  exportnakedbegin) pos=fail ;;
165  bugdz) pos=yes ; warn=0 ;;
166  baddatacylpolar) pos=fail ; error=1 ;;
167  badnewline) pos=fail ; error=2 ;;
168  badquantities) pos=fail ; error=11 ;;
169  imgoffbyone) pos=yes ;; # don't actually care about coords, just the names
170  infereqtopofil) pos=yes ; warn=0 ;;
171  3sdfixbug) pos=yes ; warn=0 ;;
172  omitclino) pos=yes ; warn=0 ;;
173  back) pos=yes; warn=0 ;;
174  notentranceorexport) pos=fail; warn=0 ;;
175  inferunknown) pos=fail; error=1 ;;
176  inferexports) pos=no; warn=0 ;;
177  bad_units_factor) pos=fail; error=5 ;;
178  percent_gradient) pos=yes; warn=0 ;;
179  dotinsurvey) pos=no; warn=0 ;;
180  leandroclino) pos=yes; warn=0 ;;
181  lowsd) pos=no; warn=0 ;;
182  revdir) pos=yes; warn=0 ;;
183  gettokennullderef) pos=fail ;;
184  lech) pos=no; warn=0 ;;
185  level) pos=yes; warn=0 ;;
186  2fixbug) pos=no; warn=0 ;;
187  declination.dat|ignore.dat|backread.dat) pos=yes; warn=0 ;;
188  dot17) pos=yes; warn=0 ;;
189  3dcorner) pos=yes; warn=0 ;;
190  surfequate) pos=dxf; warn=0 ;;
191  nosurveyhanging) pos=fail ;;
192  cmd_solve_hanging) pos=fail ;;
193  cmd_solve_nothing*) pos=no; warn=0 ;;
194  passage) pos=no; warn=0 ;;
195  hanging_lrud) pos=fail; error=1 ;;
196  *) echo "Warning: don't know how to run test '$file' - skipping it"
197     file='' ;;
198  esac
199
200  if test -n "$file" ; then
201    echo "$file"
202    case $file in
203    *.*)
204      input="$srcdir/$file"
205      posfile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.pos/'`
206      dxffile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.dxf/'` ;;
207    *)
208      input="$srcdir/$file.svx"
209      posfile="$srcdir/$file.pos"
210      dxffile="$srcdir/$file.dxf" ;;
211    esac
212    rm -f tmp.*
213    $CAVERN "$input" --output=tmp > tmp.out
214    exitcode=$?
215    test -n "$VERBOSE" && cat tmp.out
216    if test fail = "$pos" ; then
217      # success gives 0, signal (128 + <signal number>)
218      test $exitcode = 1 || exit 1
219    else
220      test $exitcode = 0 || exit 1
221    fi
222    if test -n "$warn" ; then
223      w=`sed '$!d;$s/^Done.*/0/;s/[^0-9]*\([0-9]*\).*/\1/' tmp.out`
224      test x"$w" = x"$warn" || exit 1
225    fi
226    if test -n "$error" ; then
227      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`
228      test x"$e" = x"$error" || exit 1
229    fi
230    nan=`sed 's/.*\<[Nn]a[Nn]m\?\>.*/x/p;d' tmp.out`
231    if test -n "$nan" ; then
232      exit 1
233    fi
234
235    case $pos in
236    yes)
237      if test -n "$VERBOSE" ; then
238        $DIFFPOS tmp.3d "$posfile" || exit 1
239      else
240        $DIFFPOS tmp.3d "$posfile" > /dev/null || exit 1
241      fi ;;
242    dxf)
243      if test -n "$VERBOSE" ; then
244        $CAD3D tmp.3d tmp.dxf || exit 1
245        diff tmp.dxf "$dxffile" || exit 1
246      else
247        $CAD3D tmp.3d tmp.dxf > /dev/null || exit 1
248        cmp -s tmp.dxf "$dxffile" || exit 1
249      fi ;;
250    no)
251      test -f tmp.3d || exit 1 ;;
252    fail)
253      test -f tmp.3d && exit 1
254      # Check that last line doesn't contains "Bug in program detected"
255      case `tail -n 1 tmp.out` in
256      *"Bug in program detected"*) exit 1 ;;
257      esac ;;
258    *)
259      echo "Bad value for pos: '$pos'" ; exit 1 ;;
260    esac
261    rm -f tmp.*
262  fi
263done
264test -n "$VERBOSE" && echo "Test passed"
265exit 0
Note: See TracBrowser for help on using the repository browser.