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