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