[fbc3a20] | 1 | #!/bin/sh |
---|
[d4ea980] | 2 | # |
---|
| 3 | # Survex test suite - cavern tests |
---|
[de10f8d] | 4 | # Copyright (C) 1999-2004,2005 Olly Betts |
---|
[d4ea980] | 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[fbc3a20] | 19 | |
---|
[d4d8efe] | 20 | testdir=`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 |
---|
| 26 | test -n "$*" && VERBOSE=1 |
---|
| 27 | |
---|
[87681b8] | 28 | test -x "$testdir"/../src/cavern || testdir=. |
---|
| 29 | |
---|
[d4d8efe] | 30 | : ${CAVERN="$testdir"/../src/cavern} |
---|
| 31 | : ${DIFFPOS="$testdir"/../src/diffpos} |
---|
[ce22892] | 32 | : ${CAD3D="$testdir"/../src/cad3d} |
---|
[647407d] | 33 | |
---|
[0938f88] | 34 | : ${TESTS=${*-"singlefix singlereffix oneleg midpoint noose cross firststn\ |
---|
[107b8bd] | 35 | deltastar deltastar2 bug3 calibrate_tape nosurvey2 cartesian cartesian2\ |
---|
| 36 | lengthunits angleunits cmd_truncate cmd_case cmd_fix cmd_solve\ |
---|
[11f9067] | 37 | cmd_entrance cmd_sd cmd_sd_bad cmd_fix_bad cmd_set cmd_set_bad\ |
---|
[cfa16ef] | 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\ |
---|
[f4b609d] | 45 | hanging_cpt badinc badinc2 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\ |
---|
| 50 | cmd_title cmd_titlebad cmd_dummy cmd_infer\ |
---|
| 51 | cartes diving cylpolar normal normignall nosurv cmd_flags bad_cmd_flags\ |
---|
[11e919a] | 52 | plumb unusedstation exportnakedbegin oldestyle bugdz baddatacylpolar\ |
---|
[8781a97] | 53 | badnewline badquantities imgoffbyone infereqtopofil 3sdfixbug omitclino back\ |
---|
[fa42426] | 54 | notentranceorexport inferunknown inferexports bad_units_factor\ |
---|
[a49b4493] | 55 | percent_gradient dotinsurvey leandroclino lowsd revdir gettokennullderef\ |
---|
[db1f26e] | 56 | nosurveyhanging datapassage\ |
---|
[ce22892] | 57 | lech level 2fixbug declination.dat ignore.dat dot17 3dcorner surfequate"}} |
---|
[4515ba18] | 58 | |
---|
| 59 | for file in $TESTS ; do |
---|
[cfa16ef] | 60 | # how many warnings to expect |
---|
[b97d134] | 61 | warn= |
---|
| 62 | # how many errors to expect |
---|
| 63 | error= |
---|
[de10f8d] | 64 | case $file in |
---|
[b97d134] | 65 | singlefix) pos=yes ; warn=1;; |
---|
| 66 | singlereffix) pos=yes ; warn=0 ;; |
---|
| 67 | oneleg) pos=yes ; warn=0 ;; |
---|
| 68 | midpoint) pos=yes ; warn=0 ;; |
---|
| 69 | noose) pos=yes ; warn=0 ;; |
---|
| 70 | cross) pos=yes ; warn=0 ;; |
---|
| 71 | firststn) pos=yes ; warn=0 ;; |
---|
| 72 | deltastar) pos=yes ; warn=0 ;; |
---|
| 73 | deltastar2) pos=yes ; warn=0 ;; |
---|
| 74 | bug3) pos=yes ; warn=0 ;; |
---|
| 75 | calibrate_tape) pos=yes ; warn=0 ;; |
---|
| 76 | nosurvey2) pos=yes ; warn=0 ;; |
---|
| 77 | cartesian) pos=yes ; warn=0 ;; |
---|
[107b8bd] | 78 | cartesian2) pos=yes ; warn=0 ;; |
---|
[b97d134] | 79 | lengthunits) pos=yes ; warn=0 ;; |
---|
| 80 | angleunits) pos=yes ; warn=0 ;; |
---|
| 81 | cmd_truncate) pos=yes ; warn=0 ;; |
---|
| 82 | cmd_case) pos=yes ; warn=0 ;; |
---|
| 83 | cmd_fix) pos=yes ; warn=1 ;; |
---|
[c80bd34] | 84 | cmd_fix_bad) pos=fail ; error=10 ;; |
---|
[b97d134] | 85 | cmd_solve) pos=yes ; warn=0 ;; |
---|
| 86 | cmd_entrance) pos=no ; warn=0 ;; |
---|
[3a33d12] | 87 | cmd_sd) pos=no ; warn=0 ;; |
---|
[fa42426] | 88 | cmd_sd_bad) pos=fail ; error=7 ;; |
---|
[11f9067] | 89 | cmd_set) pos=no ; warn=0 ;; |
---|
| 90 | cmd_set_bad) pos=fail ; error=7 ;; |
---|
[cfa16ef] | 91 | beginroot) pos=no ;; |
---|
[b97d134] | 92 | revcomplist) pos=no ; warn=0 ;; |
---|
| 93 | break_replace_pfx) pos=no ; warn=0 ;; |
---|
| 94 | bug0) pos=no ; warn=0 ;; |
---|
| 95 | bug1) pos=no ; warn=0 ;; |
---|
| 96 | bug2) pos=no ; warn=0 ;; |
---|
| 97 | bug4) pos=no ; warn=0 ;; |
---|
| 98 | bug5) pos=no ; warn=0 ;; |
---|
| 99 | expobug) pos=no ; warn=0 ;; |
---|
| 100 | require) pos=no ; warn=0 ;; |
---|
| 101 | export) pos=no ; warn=0 ;; |
---|
| 102 | export2) pos=no ; warn=0 ;; |
---|
| 103 | includecomment) pos=no ; warn=0 ;; |
---|
| 104 | self_loop) pos=fail ; warn=0 ;; |
---|
| 105 | self_eq_loop) pos=no ; warn=1 ;; |
---|
| 106 | reenterwarn) pos=no ; warn=2 ;; |
---|
| 107 | cmd_default) pos=no ; warn=3 ;; |
---|
| 108 | singlereffixerr) pos=no ; warn=0 ;; |
---|
| 109 | cmd_prefix) pos=no ; warn=1 ;; |
---|
| 110 | singlefixerr) pos=no ; warn=1 ;; |
---|
| 111 | tapelessthandepth) pos=no ; warn=1 ;; |
---|
| 112 | chinabug2) pos=no ; warn=0 ;; |
---|
| 113 | longname) pos=no ; warn=0 ;; |
---|
[097c0b1] | 114 | chinabug) pos=fail ;; |
---|
[cfa16ef] | 115 | begin_no_end) pos=fail ;; |
---|
| 116 | end_no_begin) pos=fail ;; |
---|
| 117 | end_no_begin_nest) pos=fail ;; |
---|
| 118 | require_fail) pos=fail ;; |
---|
| 119 | exporterr1) pos=fail ;; |
---|
| 120 | exporterr2) pos=fail ;; |
---|
| 121 | exporterr3) pos=fail ;; |
---|
| 122 | exporterr4) pos=fail ;; |
---|
| 123 | exporterr5) pos=fail ;; |
---|
| 124 | exporterr1b) pos=fail ;; |
---|
| 125 | exporterr2b) pos=fail ;; |
---|
| 126 | exporterr3b) pos=fail ;; |
---|
| 127 | exporterr6) pos=fail ;; |
---|
| 128 | exporterr6b) pos=fail ;; |
---|
| 129 | hanging_cpt) pos=fail ;; |
---|
| 130 | badinc) pos=fail ;; |
---|
| 131 | badinc2) pos=fail ;; |
---|
| 132 | non_existant_file) pos=fail ;; |
---|
[f4b609d] | 133 | ONELEG) pos=fail ;; |
---|
[cfa16ef] | 134 | stnsurvey1) pos=fail ;; |
---|
| 135 | stnsurvey2) pos=fail ;; |
---|
[52ec967] | 136 | stnsurvey3) pos=fail ;; |
---|
[b97d134] | 137 | multinormal) pos=yes ; warn=0 ;; |
---|
| 138 | multinormignall) pos=yes ; warn=0 ;; |
---|
| 139 | multidiving) pos=yes ; warn=0 ;; |
---|
[54c4612] | 140 | multicylpolar) pos=yes ; warn=0 ;; |
---|
[b97d134] | 141 | multicartesian) pos=yes ; warn=0 ;; |
---|
| 142 | multinosurv) pos=yes ; warn=0 ;; |
---|
[eef4d8c] | 143 | multinormalbad) pos=fail ;; |
---|
[b97d134] | 144 | multibug) pos=no ; warn=0 ;; |
---|
| 145 | cmd_title) pos=no ; warn=0 ;; |
---|
[457a390] | 146 | cmd_titlebad) pos=fail ; error=4 ;; |
---|
[52b6220] | 147 | cmd_dummy) pos=no ; warn=0 ;; |
---|
[f964a20] | 148 | cmd_infer) pos=yes ; warn=0 ;; |
---|
[7b25479] | 149 | cartes) pos=yes ; warn=0 ;; |
---|
| 150 | diving) pos=yes ; warn=0 ;; |
---|
[54c4612] | 151 | cylpolar) pos=yes ; warn=0 ;; |
---|
[7b25479] | 152 | normal) pos=yes ; warn=0 ;; |
---|
| 153 | normignall) pos=yes ; warn=0 ;; |
---|
| 154 | nosurv) pos=yes ; warn=0 ;; |
---|
[9881759] | 155 | cmd_flags) pos=no ; warn=0 ;; |
---|
| 156 | bad_cmd_flags) pos=fail ; error=19 ;; |
---|
[26a805f] | 157 | plumb) pos=yes ; warn=0 ;; |
---|
[7d86d87] | 158 | unusedstation) pos=no ; warn=2 ;; |
---|
[d6d3576] | 159 | oldestyle) pos=no ; warn=1 ;; |
---|
[4dcd3af] | 160 | exportnakedbegin) pos=fail ;; |
---|
[a6d094f] | 161 | bugdz) pos=yes ; warn=0 ;; |
---|
| 162 | baddatacylpolar) pos=fail ; error=1 ;; |
---|
[6114207] | 163 | badnewline) pos=fail ; error=2 ;; |
---|
[4b156b3] | 164 | badquantities) pos=fail ; error=11 ;; |
---|
| 165 | imgoffbyone) pos=yes ;; # don't actually care about coords, just the names |
---|
[107b8bd] | 166 | infereqtopofil) pos=yes ; warn=0 ;; |
---|
[a9e3f6c] | 167 | 3sdfixbug) pos=yes ; warn=0 ;; |
---|
[5b7c1b7] | 168 | omitclino) pos=yes ; warn=0 ;; |
---|
[0b71cfc] | 169 | back) pos=yes; warn=0 ;; |
---|
[b14f44f] | 170 | notentranceorexport) pos=fail; warn=0 ;; |
---|
[c00c74a9] | 171 | inferunknown) pos=fail; error=1 ;; |
---|
| 172 | inferexports) pos=no; warn=0 ;; |
---|
[fa42426] | 173 | bad_units_factor) pos=fail; error=5 ;; |
---|
[cfcfd28] | 174 | percent_gradient) pos=yes; warn=0 ;; |
---|
| 175 | dotinsurvey) pos=no; warn=0 ;; |
---|
[fbafe28] | 176 | leandroclino) pos=yes; warn=0 ;; |
---|
[cc6857f] | 177 | lowsd) pos=no; warn=0 ;; |
---|
[defb715] | 178 | revdir) pos=yes; warn=0 ;; |
---|
[22b85ce6] | 179 | gettokennullderef) pos=fail ;; |
---|
[a49b4493] | 180 | lech) pos=no; warn=0 ;; |
---|
[34afc2d] | 181 | level) pos=yes; warn=0 ;; |
---|
[b91bdce] | 182 | 2fixbug) pos=no; warn=0 ;; |
---|
[8781a97] | 183 | declination.dat|ignore.dat) pos=yes; warn=0 ;; |
---|
[c46952f] | 184 | dot17) pos=yes; warn=0 ;; |
---|
| 185 | 3dcorner) pos=yes; warn=0 ;; |
---|
[ce22892] | 186 | surfequate) pos=dxf; warn=0 ;; |
---|
[fbae3de] | 187 | nosurveyhanging) pos=fail ;; |
---|
[db1f26e] | 188 | datapassage) pos=no; warn=0 ;; |
---|
[8781a97] | 189 | *) echo "Warning: don't know how to run test '$file' - skipping it" |
---|
| 190 | file='' ;; |
---|
[cfa16ef] | 191 | esac |
---|
[4a2bb00] | 192 | |
---|
[cfcfd28] | 193 | if test -n "$file" ; then |
---|
| 194 | echo "$file" |
---|
[de10f8d] | 195 | case $file in |
---|
[d4ea980] | 196 | *.*) |
---|
| 197 | input="$srcdir/$file" |
---|
[de10f8d] | 198 | posfile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.pos/'` |
---|
| 199 | dxffile="$srcdir"/`echo "$file"|sed 's/\.[^.]*$/.dxf/'` ;; |
---|
[d4ea980] | 200 | *) |
---|
| 201 | input="$srcdir/$file.svx" |
---|
[ce22892] | 202 | posfile="$srcdir/$file.pos" |
---|
| 203 | dxffile="$srcdir/$file.dxf" ;; |
---|
[d4ea980] | 204 | esac |
---|
[87681b8] | 205 | rm -f tmp.* |
---|
[b91bdce] | 206 | $CAVERN "$input" --output=tmp > tmp.out |
---|
| 207 | exitcode=$? |
---|
| 208 | test -n "$VERBOSE" && cat tmp.out |
---|
| 209 | if test fail = "$pos" ; then |
---|
| 210 | # success gives 0, signal (128 + <signal number>) |
---|
| 211 | test $exitcode = 1 || exit 1 |
---|
[cfa16ef] | 212 | else |
---|
[b91bdce] | 213 | test $exitcode = 0 || exit 1 |
---|
[cfa16ef] | 214 | fi |
---|
[b97d134] | 215 | if test -n "$warn" ; then |
---|
[87681b8] | 216 | w=`sed '$!d;$s/^Done.*/0/;s/[^0-9]*\([0-9]*\).*/\1/' tmp.out` |
---|
[b97d134] | 217 | test x"$w" = x"$warn" || exit 1 |
---|
| 218 | fi |
---|
| 219 | if test -n "$error" ; then |
---|
[87681b8] | 220 | 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] | 221 | test x"$e" = x"$error" || exit 1 |
---|
[cfa16ef] | 222 | fi |
---|
[b91bdce] | 223 | nan=`sed 's/.*\<[Nn]a[Nn]m\?\>.*/x/p;d' tmp.out` |
---|
| 224 | if test -n "$nan" ; then |
---|
| 225 | exit 1 |
---|
| 226 | fi |
---|
[b97d134] | 227 | |
---|
[de10f8d] | 228 | case $pos in |
---|
[cfa16ef] | 229 | yes) |
---|
| 230 | if test -n "$VERBOSE" ; then |
---|
[d4ea980] | 231 | $DIFFPOS tmp.3d "$posfile" || exit 1 |
---|
[cfa16ef] | 232 | else |
---|
[d4ea980] | 233 | $DIFFPOS tmp.3d "$posfile" > /dev/null || exit 1 |
---|
[cfa16ef] | 234 | fi ;; |
---|
[ce22892] | 235 | dxf) |
---|
| 236 | if test -n "$VERBOSE" ; then |
---|
| 237 | $CAD3D tmp.3d tmp.dxf || exit 1 |
---|
| 238 | diff tmp.dxf "$dxffile" || exit 1 |
---|
| 239 | else |
---|
| 240 | $CAD3D tmp.3d tmp.dxf > /dev/null || exit 1 |
---|
| 241 | cmp -s tmp.dxf "$dxffile" || exit 1 |
---|
| 242 | fi ;; |
---|
[cfa16ef] | 243 | no) |
---|
[87681b8] | 244 | test -f tmp.3d || exit 1 ;; |
---|
[cfa16ef] | 245 | fail) |
---|
[87681b8] | 246 | test -f tmp.3d && exit 1 ;; |
---|
[097c0b1] | 247 | *) |
---|
[cfcfd28] | 248 | echo "Bad value for pos: '$pos'" ; exit 1 ;; |
---|
[cfa16ef] | 249 | esac |
---|
[87681b8] | 250 | rm -f tmp.* |
---|
[cfa16ef] | 251 | fi |
---|
[4a2bb00] | 252 | done |
---|
[cfcfd28] | 253 | test -n "$VERBOSE" && echo "Test passed" |
---|
[fbc3a20] | 254 | exit 0 |
---|