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