source: git/tests/compare.tst @ 0610ff1

Last change on this file since 0610ff1 was 0610ff1, checked in by Olly Betts <olly@…>, 2 months ago

compare.tst: Compare cavern runs which fail too

  • 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 "$SURVEXLIB" ] ; then
25  SURVEXLIB=`cd "$srcdir/../lib" && pwd`
26  export SURVEXLIB
27fi
28
29test -x "$testdir"/../src/cavern || testdir=.
30
31: ${CAVERN="$testdir"/../src/cavern}
32: ${CAVERN_ORIG=cavern}
33: ${DIFFPOS="$testdir"/../src/diffpos}
34
35: ${TESTS=${*-""}}
36
37# Suppress checking for leaks on exit if we're build with lsan - we don't
38# generally waste effort to free all allocations as the OS will reclaim
39# memory on exit.
40LSAN_OPTIONS=leak_check_at_exit=0
41export LSAN_OPTIONS
42
43vg_error=123
44vg_log=vg.log
45if [ -n "$VALGRIND" ] ; then
46  rm -f "$vg_log"
47  CAVERN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAVERN"
48  DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS"
49fi
50
51for file in $TESTS ; do
52  if test -n "$file" ; then
53    echo "$file"
54    rm -f tmp.* tmp_orig.*
55    if test -n "$VERBOSE" ; then
56      { $CAVERN_ORIG "$file" --output=tmp_orig ; exitcode_orig=$? ; } | tee tmp_orig.out
57      { $CAVERN "$file" --output=tmp ; exitcode=$? ; } | tee tmp.out
58    else
59      $CAVERN_ORIG "$file" --output=tmp_orig > tmp_orig.out
60      exitcode_orig=$?
61      $CAVERN "$file" --output=tmp > tmp.out
62      exitcode=$?
63    fi
64    if [ -n "$VALGRIND" ] ; then
65      if [ $exitcode = "$vg_error" ] ; then
66        cat "$vg_log"
67        rm "$vg_log"
68        exit 1
69      fi
70      rm "$vg_log"
71    fi
72    diag_orig=`sed 's/^There were \([0-9]* warning(s) and [0-9]* error(s)\).*/\1/p;d' tmp_orig.out`
73    diag=`sed 's/^There were \([0-9]* warning(s) and [0-9]* error(s)\).*/\1/p;d' tmp.out`
74    if test x"$diag_orig" != x"$diag" ; then
75      echo "  $diag_orig from $CAVERN_ORIG"
76      echo "  $diag from $CAVERN"
77      exit 1
78    fi
79    [ "$exitcode_orig:$exitcode" = "0:0" ] || exit 1
80    if test -n "$VERBOSE" ; then
81      $DIFFPOS tmp.3d tmp_orig.3d
82      exitcode=$?
83    else
84      $DIFFPOS tmp.3d tmp_orig.3d > /dev/null
85      exitcode=$?
86    fi
87    if [ -n "$VALGRIND" ] ; then
88      if [ $exitcode = "$vg_error" ] ; then
89        cat "$vg_log"
90        rm "$vg_log"
91        exit 1
92      fi
93      rm "$vg_log"
94    fi
95    [ "$exitcode" = 0 ] || exit 1
96  fi
97done
98test -n "$VERBOSE" && echo "Test passed"
99exit 0
Note: See TracBrowser for help on using the repository browser.