source: git/tests/compare.tst @ db641eb

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

Check SURVEX_LIB env var for support file location

We no longer look at srcdir for this.

  • Property mode set to 100755
File size: 3.0 KB
Line 
1#!/bin/sh
2#
3# Survex test suite - compare 2 versions of cavern on a dataset
4# Copyright (C) 1999-2024 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
20testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'`
21
22# allow us to run tests standalone more easily
23: ${srcdir="$testdir"}
24if [ -z "$SURVEX_LIB" ] ; then
25  SURVEX_LIB=`cd "$srcdir/../lib" && pwd`
26  export SURVEX_LIB
27fi
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
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
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
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
59      $CAVERN_ORIG "$file" --output=tmp_orig | tee tmp_orig.out || exit 1
60      $CAVERN "$file" --output=tmp | tee tmp.out
61      exitcode=$?
62    else
63      $CAVERN_ORIG "$file" --output=tmp_orig > tmp_orig.out || exit 1
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"
74    fi
75    [ "$exitcode" = 0 ] || exit 1
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`
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
84      $DIFFPOS tmp.3d tmp_orig.3d
85      exitcode=$?
86    else
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"
97    fi
98    [ "$exitcode" = 0 ] || exit 1
99  fi
100done
101test -n "$VERBOSE" && echo "Test passed"
102exit 0
Note: See TracBrowser for help on using the repository browser.