[fbc3a20] | 1 | #!/bin/sh |
---|
[b4fe9fb] | 2 | # |
---|
| 3 | # Survex test suite - cavern tests |
---|
[0f8216c] | 4 | # Copyright (C) 1999-2025 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] | 20 | testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'` |
---|
| 21 | |
---|
[ed34f49] | 22 | test -x "$testdir"/../src/cavern || testdir=. |
---|
| 23 | |
---|
| 24 | # Make testdir absolute, so we can cd before running cavern to get a consistent |
---|
| 25 | # path in diagnostic messages. |
---|
| 26 | testdir=`cd "$testdir" && pwd` |
---|
| 27 | |
---|
[6b8ff5b] | 28 | # allow us to run tests standalone more easily |
---|
[d4d8efe] | 29 | : ${srcdir="$testdir"} |
---|
[87fcddb] | 30 | if [ -z "$SURVEXLIB" ] ; then |
---|
| 31 | SURVEXLIB=`cd "$srcdir/../lib" && pwd` |
---|
| 32 | export SURVEXLIB |
---|
[ed34f49] | 33 | fi |
---|
[647407d] | 34 | |
---|
[64b4d1c] | 35 | # force VERBOSE if we're run on a subset of tests |
---|
| 36 | test -n "$*" && VERBOSE=1 |
---|
| 37 | |
---|
[6448891] | 38 | case `uname -a` in |
---|
| 39 | MINGW*) |
---|
| 40 | DIFF='diff --strip-trailing-cr' |
---|
| 41 | QUIET_DIFF='diff -q --strip-trailing-cr' |
---|
| 42 | ;; |
---|
| 43 | *) |
---|
| 44 | DIFF=diff |
---|
| 45 | # Use cmp when we can as a small optimisation. |
---|
| 46 | QUIET_DIFF='cmp -s' |
---|
| 47 | ;; |
---|
| 48 | esac |
---|
| 49 | |
---|
[d4d8efe] | 50 | : ${CAVERN="$testdir"/../src/cavern} |
---|
| 51 | : ${DIFFPOS="$testdir"/../src/diffpos} |
---|
[fdffa7d] | 52 | : ${DUMP3D="$testdir"/../src/dump3d} |
---|
[79b32a95] | 53 | : ${SURVEXPORT="$testdir"/../src/survexport} |
---|
[647407d] | 54 | |
---|
[f189010] | 55 | : ${TESTS=${*:-"singlefix singlereffix oneleg midpoint lollipop fixedlollipop\ |
---|
| 56 | cross firststn\ |
---|
[9918c3d] | 57 | deltastar deltastar2 deltastarhanging\ |
---|
| 58 | bug3 calibrate_tape nosurvey2 cartesian cartesian2\ |
---|
[e1cbc0d] | 59 | lengthunits angleunits cmd_alias cmd_alias_bad cmd_truncate cmd_truncate_bad\ |
---|
| 60 | cmd_case cmd_case_bad cmd_fix\ |
---|
[4772e46] | 61 | cmd_solve cmd_entrance cmd_entrance_bad cmd_sd cmd_sd_bad cmd_fix_bad cmd_set\ |
---|
[5d59477] | 62 | cmd_set_bad cmd_set_dot_in_name\ |
---|
| 63 | beginroot revcomplist break_replace_pfx bug0 bug1 bug2 bug4 bug5\ |
---|
[cfa16ef] | 64 | expobug require export export2 includecomment\ |
---|
[68f7ba4] | 65 | self_loop self_eq_loop reenterwarn cmd_default cmd_default_bad\ |
---|
| 66 | cmd_prefix cmd_prefix_bad\ |
---|
[b9c82c2] | 67 | cmd_begin_bad cmd_equate_bad cmd_export_bad\ |
---|
[cfa16ef] | 68 | singlefixerr singlereffixerr\ |
---|
| 69 | begin_no_end end_no_begin end_no_begin_nest require_fail\ |
---|
| 70 | exporterr1 exporterr2 exporterr3 exporterr4 exporterr5\ |
---|
| 71 | exporterr1b exporterr2b exporterr3b exporterr6 exporterr6b\ |
---|
[c6ff64b] | 72 | hanging_cpt badinc badinc2 badinc3 badinc4 badinc5.mak nonexistent_file ONELEG\ |
---|
[2b0cec5] | 73 | stnsurvey1 stnsurvey2\ |
---|
[0af7076] | 74 | tapelessthandepth longname chinabug chinabug2\ |
---|
[54c4612] | 75 | multinormal multinormignall multidiving multicylpolar multicartesian\ |
---|
| 76 | multinosurv multinormalbad multibug\ |
---|
[0f8216c] | 77 | cmd_team cmd_team_bad\ |
---|
[e0c7cd1] | 78 | cmd_title cmd_titlebad cmd_dummy cmd_infer cmd_date cmd_datebad cmd_datebad2\ |
---|
[4fb15a1] | 79 | cartes diving cylpolar normal normal_bad normignall nosurv cmd_flags\ |
---|
| 80 | bad_cmd_flags plumb unusedstation exportnakedbegin oldestyle bugdz\ |
---|
[9703ac5] | 81 | baddatacylpolar baddatanosurv badnewline badquantities\ |
---|
| 82 | imgoffbyone infereqtopofil 3sdfixbug\ |
---|
[5d1c60c] | 83 | omitclino back back2 bad_back\ |
---|
[a26c346] | 84 | notentranceorexport inferunknown inferexports bad_units_factor\ |
---|
[699bf50] | 85 | bad_units_qlist\ |
---|
[b4fe9fb] | 86 | percent_gradient dotinsurvey leandroclino lowsd revdir gettokennullderef\ |
---|
[d7a2cf9] | 87 | nosurveyhanging nosurveyhanging2\ |
---|
| 88 | cmd_solve_nothing cmd_solve_nothing_implicit\ |
---|
[abe7192] | 89 | cmd_cartesian cmd_cartesian_bad\ |
---|
[58edecc] | 90 | cmd_calibrate cmd_declination cmd_declination_auto cmd_declination_auto_bad\ |
---|
| 91 | cmd_declination_conv cmd_declination_conv_proj_bug\ |
---|
[850fdc4] | 92 | lech level 2fixbug dot17 3dcorner\ |
---|
[be4d0a0] | 93 | unconnected-bug\ |
---|
[1fbe9d43] | 94 | backread.dat corrections.dat depthguage.dat flags.dat karstcompat.dat\ |
---|
| 95 | lrud.dat nomeasure.dat noteam.dat\ |
---|
[ec580039] | 96 | badmak.mak\ |
---|
[d624d86] | 97 | fixfeet.mak utm.mak\ |
---|
[bf3acff] | 98 | clptest.dat clptest.clp\ |
---|
[725d3b1] | 99 | walls.srv\ |
---|
[21f084b] | 100 | badopts.srv\ |
---|
[d5a206ec] | 101 | wallsbaddatum.wpj\ |
---|
[4a0ab33] | 102 | wallsdecl.wpj\ |
---|
[ab83a74] | 103 | passage hanging_lrud equatenosuchstn surveytypo\ |
---|
[da96015] | 104 | skipafterbadomit passagebad badreadingdotplus badcalibrate calibrate_clino\ |
---|
[c092d72] | 105 | badunits badbegin anonstn anonstnbad anonstnrev doubleinc reenterlots\ |
---|
[567efed] | 106 | cs csbad csbadsdfix csfeet cslonglat omitfixaroundsolve repeatreading\ |
---|
[65b2851] | 107 | mixedeols utf8bom nonewlineateof suspectreadings cmd_data_default\ |
---|
[63ae487] | 108 | cmd_data_ignore\ |
---|
[5a0ab6a] | 109 | quadrant_bearing bad_quadrant_bearing\ |
---|
[05b9de76] | 110 | samename tabinhighlight legacytokens\ |
---|
[bf9faf6] | 111 | component_count_bug component_count_bug2\ |
---|
[ab83a74] | 112 | 3dexport \ |
---|
| 113 | dxffullcoords dxfsurfequate\ |
---|
[87f6c03] | 114 | gpxexport hpglexport jsonexport kmlexport pltexport svgexport\ |
---|
[c092d72] | 115 | "}} |
---|
[cd971de] | 116 | |
---|
[2b0cec5] | 117 | # Test file stnsurvey3.svx missing: pos=fail # We exit before the error count. |
---|
| 118 | |
---|
[cd971de] | 119 | LC_ALL=C |
---|
| 120 | export LC_ALL |
---|
[6e47b72] | 121 | SURVEXLANG=en |
---|
[cd971de] | 122 | export SURVEXLANG |
---|
[4515ba18] | 123 | |
---|
[43e8c72] | 124 | # Suppress checking for leaks on exit if we're build with lsan - we don't |
---|
| 125 | # generally waste effort to free all allocations as the OS will reclaim |
---|
| 126 | # memory on exit. |
---|
| 127 | LSAN_OPTIONS=leak_check_at_exit=0 |
---|
| 128 | export LSAN_OPTIONS |
---|
| 129 | |
---|
[b1200a6] | 130 | # Allow datestamps in 3d files (we normalise the expected output for GPX |
---|
| 131 | # etc) to allow for the datestamp not being fixed, but under SOURCE_DATE_EPOCH |
---|
| 132 | # the datestamp is omitted entirely which would break those testcases. |
---|
| 133 | unset SOURCE_DATE_EPOCH |
---|
| 134 | |
---|
[67a2822] | 135 | vg_error=123 |
---|
[9f5bcd3] | 136 | vg_log=$testdir/vg.log |
---|
[67a2822] | 137 | if [ -n "$VALGRIND" ] ; then |
---|
| 138 | rm -f "$vg_log" |
---|
| 139 | CAVERN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAVERN" |
---|
[38c4c5c] | 140 | DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS" |
---|
[fdffa7d] | 141 | DUMP3D="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DUMP3D" |
---|
[79b32a95] | 142 | SURVEXPORT="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $SURVEXPORT" |
---|
[67a2822] | 143 | fi |
---|
| 144 | |
---|
[4515ba18] | 145 | for file in $TESTS ; do |
---|
[2b0cec5] | 146 | case $file in |
---|
| 147 | nonexistent_file*|ONELEG) |
---|
| 148 | # ONELEG tests that we don't apply special handling to command line |
---|
| 149 | # arguments, only those in *include. |
---|
| 150 | realfile= ;; |
---|
[a69860f] | 151 | *.*) realfile=$srcdir/$file ;; |
---|
| 152 | *) realfile=$srcdir/$file.svx ;; |
---|
[2b0cec5] | 153 | esac |
---|
| 154 | |
---|
[858a791] | 155 | if [ x"$file" = xONELEG ] && [ -f "ONELEG.SVX" ] ; then |
---|
| 156 | echo "Case insensitive filing system - skipping ONELEG testcase" |
---|
| 157 | continue |
---|
| 158 | fi |
---|
| 159 | |
---|
[2b0cec5] | 160 | if [ -n "$realfile" ] && [ ! -r "$realfile" ] ; then |
---|
[a69860f] | 161 | echo "Don't know how to run test '$file'" |
---|
| 162 | exit 1 |
---|
[2b0cec5] | 163 | fi |
---|
| 164 | |
---|
| 165 | echo "$file" |
---|
| 166 | |
---|
[db26f60] | 167 | # how many warnings to expect (or empty not to check) |
---|
[b97d134] | 168 | warn= |
---|
[db26f60] | 169 | |
---|
| 170 | # how many errors to expect (or empty not to check) |
---|
[b97d134] | 171 | error= |
---|
[2b0cec5] | 172 | |
---|
[db26f60] | 173 | # One of: |
---|
| 174 | # yes : diffpos 3D file output with <testcase_name>.pos |
---|
| 175 | # no : Check that a 3D file is produced, but not positions in it |
---|
| 176 | # fail : Check that a 3D file is NOT produced |
---|
[371385f] | 177 | # 3d : Convert to 3D with survexport, compare dump3d to <testcase_name>.dump |
---|
[db26f60] | 178 | # dxf : Convert to DXF with survexport and compare with <testcase_name>.dxf |
---|
[aaeb71f] | 179 | # gpx : Convert to GPX with survexport and compare with <testcase_name>.gpx |
---|
[4fcdd51a] | 180 | # json : Convert to JSON with survexport and compare with <testcase_name>.json |
---|
[aaeb71f] | 181 | # kml : Convert to KML with survexport and compare with <testcase_name>.kml |
---|
[3ee5c47] | 182 | # plt : Convert to PLT with survexport and compare with <testcase_name>.plt |
---|
[8c4cefb] | 183 | # svg : Convert to SVG with survexport and compare with <testcase_name>.svg |
---|
[db26f60] | 184 | pos= |
---|
| 185 | |
---|
[0d3c93b] | 186 | case $file in |
---|
[52f46ed] | 187 | backread.dat|clptest.dat|clptest.clp|depthguage.dat|karstcompat.dat) |
---|
[fdffa7d] | 188 | pos=dump |
---|
| 189 | warn=0 |
---|
| 190 | ;; |
---|
[52f46ed] | 191 | flags.dat) |
---|
| 192 | pos=dump |
---|
| 193 | warn=1 |
---|
| 194 | ;; |
---|
[2b0cec5] | 195 | *.dat) |
---|
[838a7f4c] | 196 | # .dat files can't start with a comment. All the other .dat tests |
---|
| 197 | # have the same settings. |
---|
[2b0cec5] | 198 | pos=yes |
---|
| 199 | warn=0 |
---|
| 200 | ;; |
---|
| 201 | nonexistent_file*|ONELEG) |
---|
[3ebfd6a] | 202 | # These testcase files don't exist (or for ONELEG exist with a different |
---|
| 203 | # case). They all have the same settings. |
---|
[2b0cec5] | 204 | pos=fail |
---|
| 205 | ;; |
---|
[d5a206ec] | 206 | wallsbaddatum.wpj) |
---|
| 207 | # .wpj files can't start with a comment. |
---|
| 208 | pos=fail |
---|
| 209 | warn=0 |
---|
| 210 | err=1 |
---|
| 211 | ;; |
---|
[4a0ab33] | 212 | *.wpj) |
---|
| 213 | # .wpj files can't start with a comment. |
---|
| 214 | pos=dump |
---|
| 215 | warn=0 |
---|
| 216 | ;; |
---|
[2b0cec5] | 217 | *) |
---|
[aaeb71f] | 218 | survexportopts= |
---|
[2b0cec5] | 219 | read header < "$realfile" |
---|
| 220 | set dummy $header |
---|
[f9aaa2c] | 221 | while shift && [ -n "$1" ] ; do |
---|
[2b0cec5] | 222 | case $1 in |
---|
| 223 | pos=*) pos=`expr "$1" : 'pos=\(.*\)'` ;; |
---|
| 224 | warn=*) warn=`expr "$1" : 'warn=\(.*\)'` ;; |
---|
| 225 | error=*) error=`expr "$1" : 'error=\(.*\)'` ;; |
---|
[aaeb71f] | 226 | survexportopt=*) |
---|
| 227 | survexportopts="$survexportopts "`expr "$1" : 'survexportopt=\(.*\)'` |
---|
| 228 | ;; |
---|
[2b0cec5] | 229 | esac |
---|
| 230 | done |
---|
| 231 | ;; |
---|
[cfa16ef] | 232 | esac |
---|
[4a2bb00] | 233 | |
---|
[aba729d] | 234 | basefile=$srcdir/$file |
---|
[2b0cec5] | 235 | case $file in |
---|
| 236 | *.*) |
---|
| 237 | input="./$file" |
---|
[aba729d] | 238 | basefile=`echo "$basefile"|sed 's/\.[^.]*$//'` ;; |
---|
[2b0cec5] | 239 | *) |
---|
[aba729d] | 240 | input="./$file.svx" ;; |
---|
[2b0cec5] | 241 | esac |
---|
[aba729d] | 242 | outfile=$basefile.out |
---|
[cccc545] | 243 | outfile2=$basefile.altout |
---|
[aba729d] | 244 | posfile=$basefile.pos |
---|
[2b0cec5] | 245 | rm -f tmp.* |
---|
| 246 | pwd=`pwd` |
---|
| 247 | cd "$srcdir" |
---|
[fdffa7d] | 248 | srcdir=. SOURCE_DATE_EPOCH=1 $CAVERN "$input" --output="$pwd/tmp" > "$pwd/tmp.out" |
---|
[2b0cec5] | 249 | exitcode=$? |
---|
| 250 | cd "$pwd" |
---|
| 251 | test -n "$VERBOSE" && cat tmp.out |
---|
| 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 |
---|
| 260 | if test fail = "$pos" ; then |
---|
| 261 | # success gives 0, signal (128 + <signal number>) |
---|
| 262 | test $exitcode = 1 || exit 1 |
---|
| 263 | else |
---|
| 264 | test $exitcode = 0 || exit 1 |
---|
| 265 | fi |
---|
| 266 | if test -n "$warn" ; then |
---|
[837e8bb] | 267 | w=`sed '$!d;s/^There were \([0-9]*\).*/\1/p;d' tmp.out` |
---|
| 268 | if test x"${w:-0}" != x"$warn" ; then |
---|
[2b0cec5] | 269 | test -n "$VERBOSE" && echo "Got $w warnings, expected $warn" |
---|
| 270 | exit 1 |
---|
| 271 | fi |
---|
| 272 | fi |
---|
| 273 | if test -n "$error" ; then |
---|
[837e8bb] | 274 | e=`sed '$!d;s/^There were .* and \([0-9][0-9]*\).*/\1/p;d' tmp.out` |
---|
| 275 | if test x"${e:-0}" != x"$error" ; then |
---|
[2b0cec5] | 276 | test -n "$VERBOSE" && echo "Got $e errors, expected $error" |
---|
| 277 | exit 1 |
---|
| 278 | fi |
---|
| 279 | fi |
---|
[f5012ca] | 280 | # Fail if nan, NaN, etc in output (which might be followed by m for metres or |
---|
| 281 | # s for seconds). |
---|
| 282 | if egrep -q '(^|[^A-Za-z0-9])nan[ms]?($|[^A-Za-z0-9])' tmp.out ; then |
---|
| 283 | echo "Not-a-number appears in output" |
---|
[2b0cec5] | 284 | exit 1 |
---|
| 285 | fi |
---|
| 286 | |
---|
| 287 | case $pos in |
---|
| 288 | yes) |
---|
| 289 | if test -n "$VERBOSE" ; then |
---|
| 290 | $DIFFPOS "$posfile" tmp.3d |
---|
| 291 | exitcode=$? |
---|
| 292 | else |
---|
| 293 | $DIFFPOS "$posfile" tmp.3d > /dev/null |
---|
| 294 | exitcode=$? |
---|
| 295 | fi |
---|
[67a2822] | 296 | if [ -n "$VALGRIND" ] ; then |
---|
| 297 | if [ $exitcode = "$vg_error" ] ; then |
---|
| 298 | cat "$vg_log" |
---|
| 299 | rm "$vg_log" |
---|
| 300 | exit 1 |
---|
| 301 | fi |
---|
| 302 | rm "$vg_log" |
---|
| 303 | fi |
---|
[2b0cec5] | 304 | [ "$exitcode" = 0 ] || exit 1 |
---|
| 305 | ;; |
---|
[fdffa7d] | 306 | dump) |
---|
| 307 | expectedfile=$basefile.dump |
---|
| 308 | tmpfile=tmp.dump |
---|
| 309 | $DUMP3D --show-dates --legs tmp.3d > "$tmpfile" |
---|
| 310 | exitcode=$? |
---|
| 311 | if [ -n "$VALGRIND" ] ; then |
---|
| 312 | if [ $exitcode = "$vg_error" ] ; then |
---|
| 313 | cat "$vg_log" |
---|
| 314 | rm "$vg_log" |
---|
| 315 | exit 1 |
---|
| 316 | fi |
---|
| 317 | rm "$vg_log" |
---|
| 318 | fi |
---|
| 319 | [ "$exitcode" = 0 ] || exit 1 |
---|
| 320 | |
---|
| 321 | if test -n "$VERBOSE" ; then |
---|
[6448891] | 322 | $DIFF "$expectedfile" "$tmpfile" || exit 1 |
---|
[fdffa7d] | 323 | else |
---|
[6448891] | 324 | $QUIET_DIFF "$expectedfile" "$tmpfile" || exit 1 |
---|
[fdffa7d] | 325 | fi |
---|
| 326 | ;; |
---|
[87f6c03] | 327 | dxf|gpx|hpgl|json|kml|plt|svg) |
---|
[aaeb71f] | 328 | # $pos gives us the file extension here. |
---|
| 329 | expectedfile=$basefile.$pos |
---|
| 330 | tmpfile=tmp.$pos |
---|
[2b0cec5] | 331 | if test -n "$VERBOSE" ; then |
---|
[aaeb71f] | 332 | $SURVEXPORT --defaults$survexportopts tmp.3d "$tmpfile" |
---|
[2b0cec5] | 333 | exitcode=$? |
---|
[cfa16ef] | 334 | else |
---|
[aaeb71f] | 335 | $SURVEXPORT --defaults$survexportopts tmp.3d "$tmpfile" > /dev/null |
---|
[2b0cec5] | 336 | exitcode=$? |
---|
[cfa16ef] | 337 | fi |
---|
[2b0cec5] | 338 | if [ -n "$VALGRIND" ] ; then |
---|
| 339 | if [ $exitcode = "$vg_error" ] ; then |
---|
| 340 | cat "$vg_log" |
---|
| 341 | rm "$vg_log" |
---|
[62e7e3c] | 342 | exit 1 |
---|
| 343 | fi |
---|
[2b0cec5] | 344 | rm "$vg_log" |
---|
[cfa16ef] | 345 | fi |
---|
[2b0cec5] | 346 | [ "$exitcode" = 0 ] || exit 1 |
---|
[aaeb71f] | 347 | |
---|
| 348 | # Normalise exported file if required. |
---|
| 349 | case $pos in |
---|
[02cc72e] | 350 | dxf) |
---|
| 351 | # On x86 excess precision can result in -0.00 for some coordinates. |
---|
[0bb63448] | 352 | sed 's/^-0\.00\>/0.00/;s/ -0\.00\>/ 0.00/g' < "$tmpfile" > tmp.tmp |
---|
[02cc72e] | 353 | mv tmp.tmp "$tmpfile" |
---|
| 354 | ;; |
---|
[ea4ac75] | 355 | json) |
---|
| 356 | # On x86 excess precision can result in -0.00 for some coordinates. |
---|
| 357 | sed 's/-0\.00\>/0.00/g' < "$tmpfile" > tmp.tmp |
---|
| 358 | mv tmp.tmp "$tmpfile" |
---|
| 359 | ;; |
---|
[aaeb71f] | 360 | gpx) |
---|
[24f2d99] | 361 | sed 's,<time>[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z</time>,<time>REDACTED</time>,;s,survex [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*,survex REDACTED,' < "$tmpfile" > tmp.tmp |
---|
[aaeb71f] | 362 | mv tmp.tmp "$tmpfile" |
---|
| 363 | ;; |
---|
| 364 | esac |
---|
| 365 | |
---|
[371385f] | 366 | if test -n "$VERBOSE" ; then |
---|
| 367 | $DIFF "$expectedfile" "$tmpfile" || exit 1 |
---|
| 368 | else |
---|
| 369 | $QUIET_DIFF "$expectedfile" "$tmpfile" || exit 1 |
---|
| 370 | fi |
---|
| 371 | ;; |
---|
| 372 | 3d) |
---|
| 373 | expectedfile=$basefile.dump |
---|
| 374 | tmpfile=tmp.dump |
---|
| 375 | if test -n "$VERBOSE" ; then |
---|
| 376 | SOURCE_DATE_EPOCH=1 $SURVEXPORT --defaults$survexportopts tmp.3d "$tmpfile.3d" |
---|
| 377 | exitcode=$? |
---|
| 378 | else |
---|
| 379 | SOURCE_DATE_EPOCH=1 $SURVEXPORT --defaults$survexportopts tmp.3d "$tmpfile.3d" > /dev/null |
---|
| 380 | exitcode=$? |
---|
| 381 | fi |
---|
| 382 | $DUMP3D --show-dates --legs "$tmpfile.3d" > "$tmpfile" |
---|
| 383 | if [ -n "$VALGRIND" ] ; then |
---|
| 384 | if [ $exitcode = "$vg_error" ] ; then |
---|
| 385 | cat "$vg_log" |
---|
| 386 | rm "$vg_log" |
---|
| 387 | exit 1 |
---|
| 388 | fi |
---|
| 389 | rm "$vg_log" |
---|
| 390 | fi |
---|
| 391 | [ "$exitcode" = 0 ] || exit 1 |
---|
| 392 | |
---|
[2b0cec5] | 393 | if test -n "$VERBOSE" ; then |
---|
[6448891] | 394 | $DIFF "$expectedfile" "$tmpfile" || exit 1 |
---|
[2b0cec5] | 395 | else |
---|
[6448891] | 396 | $QUIET_DIFF "$expectedfile" "$tmpfile" || exit 1 |
---|
[aaeb71f] | 397 | fi |
---|
| 398 | ;; |
---|
[2b0cec5] | 399 | no) |
---|
| 400 | test -f tmp.3d || exit 1 ;; |
---|
| 401 | fail) |
---|
| 402 | test -f tmp.3d && exit 1 |
---|
| 403 | # Check that last line doesn't contains "Bug in program detected" |
---|
| 404 | case `tail -n 1 tmp.out` in |
---|
| 405 | *"Bug in program detected"*) exit 1 ;; |
---|
| 406 | esac ;; |
---|
| 407 | *) |
---|
| 408 | echo "Bad value for pos: '$pos'" ; exit 1 ;; |
---|
| 409 | esac |
---|
[cd971de] | 410 | |
---|
[aba729d] | 411 | if test -f "$outfile" ; then |
---|
[cccc545] | 412 | # Version and time used info from output, working around Apple's stone-age |
---|
| 413 | # sed. |
---|
| 414 | sed '1,/^Copyright/d;/^\(CPU \)*[Tt]ime used *[0-9][0-9.]*s$/d;s!.*/src/\(cavern: \)!\1!' tmp.out > tmp.out2 |
---|
| 415 | mv tmp.out2 tmp.out |
---|
| 416 | # Check output is as expected. |
---|
[6448891] | 417 | if $QUIET_DIFF "$outfile" tmp.out ; then |
---|
[cccc545] | 418 | : # Matches. |
---|
[6448891] | 419 | elif [ -f "$outfile2" ] && $QUIET_DIFF "$outfile2" tmp.out ; then |
---|
[cccc545] | 420 | : # Matches alternative output (e.g. due to older PROJ). |
---|
[2b0cec5] | 421 | else |
---|
[6448891] | 422 | test -z "$VERBOSE" || $DIFF "$outfile" tmp.out |
---|
[cccc545] | 423 | exit 1 |
---|
[cd971de] | 424 | fi |
---|
[cfa16ef] | 425 | fi |
---|
[2b0cec5] | 426 | rm -f tmp.* |
---|
[4a2bb00] | 427 | done |
---|
[cfcfd28] | 428 | test -n "$VERBOSE" && echo "Test passed" |
---|
[fbc3a20] | 429 | exit 0 |
---|