source: git/tests/compare.tst @ f5e6be8

stereo-2025warn-only-for-hanging-survey
Last change on this file since f5e6be8 was 87fcddb, checked in by Olly Betts <olly@…>, 12 months ago

Check SURVEXLIB instead of SURVEX_LIB

Better to be consistent with the existing environmental variable
SURVEXLANG.

  • Property mode set to 100755
File size: 3.0 KB
RevLine 
[6ae626d]1#!/bin/sh
[d4ea980]2#
3# Survex test suite - compare 2 versions of cavern on a dataset
[ed34f49]4# Copyright (C) 1999-2024 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
[cc49471]18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
[6ae626d]19
20testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'`
21
22# allow us to run tests standalone more easily
23: ${srcdir="$testdir"}
[87fcddb]24if [ -z "$SURVEXLIB" ] ; then
25  SURVEXLIB=`cd "$srcdir/../lib" && pwd`
26  export SURVEXLIB
[ed34f49]27fi
[6ae626d]28
29# force VERBOSE if we're run on a subset of tests
30#test -n "$*" && VERBOSE=1
31
32test -x "$testdir"/../src/cavern || testdir=.
33
34: ${CAVERN="$testdir"/../src/cavern}
35: ${CAVERN_ORIG=cavern}
36: ${DIFFPOS="$testdir"/../src/diffpos}
37
38: ${TESTS=${*-""}}
39
[43e8c72]40# Suppress checking for leaks on exit if we're build with lsan - we don't
41# generally waste effort to free all allocations as the OS will reclaim
42# memory on exit.
43LSAN_OPTIONS=leak_check_at_exit=0
44export LSAN_OPTIONS
45
[38c4c5c]46vg_error=123
47vg_log=vg.log
48if [ -n "$VALGRIND" ] ; then
49  rm -f "$vg_log"
50  CAVERN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAVERN"
51  DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS"
52fi
53
[6ae626d]54for file in $TESTS ; do
55  if test -n "$file" ; then
56    echo "$file"
57    rm -f tmp.* tmp_orig.*
58    if test -n "$VERBOSE" ; then
[d4ea980]59      $CAVERN_ORIG "$file" --output=tmp_orig | tee tmp_orig.out || exit 1
[38c4c5c]60      $CAVERN "$file" --output=tmp | tee tmp.out
61      exitcode=$?
[6ae626d]62    else
[d4ea980]63      $CAVERN_ORIG "$file" --output=tmp_orig > tmp_orig.out || exit 1
[38c4c5c]64      $CAVERN "$file" --output=tmp > tmp.out
65      exitcode=$?
66    fi
67    if [ -n "$VALGRIND" ] ; then
68      if [ $exitcode = "$vg_error" ] ; then
69        cat "$vg_log"
70        rm "$vg_log"
71        exit 1
72      fi
73      rm "$vg_log"
[6ae626d]74    fi
[38c4c5c]75    [ "$exitcode" = 0 ] || exit 1
[62e7e3c]76    warn_orig=`sed '$!d;s/^There were \([0-9]*\).*/\1/;s/^[^0-9].*$/0/' tmp_orig.out
77    warn=`sed '$!d;s/^There were \([0-9]*\).*/\1/;s/^[^0-9].*$/0/' tmp.out`
[6ae626d]78    if test x"$warn_orig" != x"$warn" ; then
79      echo "$CAVERN_ORIG gave $warn_orig warning(s)"
80      echo "$CAVERN gave $warn warning(s)"
81      exit 1
82    fi
83    if test -n "$VERBOSE" ; then
[38c4c5c]84      $DIFFPOS tmp.3d tmp_orig.3d
85      exitcode=$?
[6ae626d]86    else
[38c4c5c]87      $DIFFPOS tmp.3d tmp_orig.3d > /dev/null
88      exitcode=$?
89    fi
90    if [ -n "$VALGRIND" ] ; then
91      if [ $exitcode = "$vg_error" ] ; then
92        cat "$vg_log"
93        rm "$vg_log"
94        exit 1
95      fi
96      rm "$vg_log"
[6ae626d]97    fi
[38c4c5c]98    [ "$exitcode" = 0 ] || exit 1
[6ae626d]99  fi
100done
101test -n "$VERBOSE" && echo "Test passed"
102exit 0
Note: See TracBrowser for help on using the repository browser.