source: git/tests/compare.tst @ 14f8f0c

Last change on this file since 14f8f0c was 6dc2a4c, checked in by Olly Betts <olly@…>, 2 months ago

cavern.tst: Add --help message

  • Property mode set to 100755
File size: 3.4 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
51case $TESTS in
52  ""|*--help*)
53    echo "Usage: $0 SVX_FILE..."
54    echo ""
55    echo "Process each SVX_FILE in turn with two versions of cavern and compare."
56    echo ""
57    echo "Cavern versions specified by environment variables:"
58    echo ""
59    echo "  CAVERN_ORIG (default: $CAVERN_ORIG)"
60    echo "  CAVERN (default: $CAVERN)"
61    if [ -z "$TESTS" ] ; then
62      exit 1
63    else
64      exit 0
65    fi
66    ;;
67esac
68
69for file in $TESTS ; do
70  if test -n "$file" ; then
71    echo "$file"
72    rm -f tmp.* tmp_orig.*
73    if test -n "$VERBOSE" ; then
74      { $CAVERN_ORIG "$file" --output=tmp_orig ; exitcode_orig=$? ; } | tee tmp_orig.out
75      { $CAVERN "$file" --output=tmp ; exitcode=$? ; } | tee tmp.out
76    else
77      $CAVERN_ORIG "$file" --output=tmp_orig > tmp_orig.out
78      exitcode_orig=$?
79      $CAVERN "$file" --output=tmp > tmp.out
80      exitcode=$?
81    fi
82    if [ -n "$VALGRIND" ] ; then
83      if [ $exitcode = "$vg_error" ] ; then
84        cat "$vg_log"
85        rm "$vg_log"
86        exit 1
87      fi
88      rm "$vg_log"
89    fi
90    diag_orig=`sed 's/^There were \([0-9]* warning(s) and [0-9]* error(s)\).*/\1/p;d' tmp_orig.out`
91    diag=`sed 's/^There were \([0-9]* warning(s) and [0-9]* error(s)\).*/\1/p;d' tmp.out`
92    if test x"$diag_orig" != x"$diag" ; then
93      echo "  $diag_orig from $CAVERN_ORIG"
94      echo "  $diag from $CAVERN"
95      exit 1
96    fi
97    [ "$exitcode_orig:$exitcode" = "0:0" ] || exit 1
98    if test -n "$VERBOSE" ; then
99      $DIFFPOS tmp.3d tmp_orig.3d
100      exitcode=$?
101    else
102      $DIFFPOS tmp.3d tmp_orig.3d > /dev/null
103      exitcode=$?
104    fi
105    if [ -n "$VALGRIND" ] ; then
106      if [ $exitcode = "$vg_error" ] ; then
107        cat "$vg_log"
108        rm "$vg_log"
109        exit 1
110      fi
111      rm "$vg_log"
112    fi
113    [ "$exitcode" = 0 ] || exit 1
114  fi
115done
116test -n "$VERBOSE" && echo "Test passed"
117exit 0
Note: See TracBrowser for help on using the repository browser.