source: git/tests/diffpos.tst @ 0841448

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

Use diff instead of cmp to handle DOS line endings

  • Property mode set to 100755
File size: 2.6 KB
Line 
1#!/bin/sh
2#
3# Survex test suite - diffpos tests
4# Copyright (C) 1999-2021 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"}
24
25# force VERBOSE if we're run on a subset of tests
26test -n "$*" && VERBOSE=1
27
28test -x "$testdir"/../src/cavern || testdir=.
29
30case `uname -a` in
31  MINGW*)
32    DIFF='diff --strip-trailing-cr'
33    QUIET_DIFF='diff -q --strip-trailing-cr'
34    ;;
35  *)
36    DIFF=diff
37    # Use cmp when we can as a small optimisation.
38    QUIET_DIFF='cmp -s'
39    ;;
40esac
41
42: ${DIFFPOS="$testdir"/../src/diffpos}
43
44: ${TESTS=${*:-"delatend addatend"}}
45
46SURVEXLANG=en
47export SURVEXLANG
48
49# Suppress checking for leaks on exit if we're build with lsan - we don't
50# generally waste effort to free all allocations as the OS will reclaim
51# memory on exit.
52LSAN_OPTIONS=leak_check_at_exit=0
53export LSAN_OPTIONS
54
55vg_error=123
56vg_log=vg.log
57if [ -n "$VALGRIND" ] ; then
58  rm -f "$vg_log"
59  DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS"
60fi
61
62for file in $TESTS ; do
63  echo $file
64  rm -f diffpos.tmp
65  $DIFFPOS "$srcdir/${file}a.pos" "$srcdir/${file}b.pos" > diffpos.tmp
66  exitcode=$?
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  if test -n "$VERBOSE" ; then
76    cat diffpos.tmp
77    $DIFF diffpos.tmp "$srcdir/${file}.out" || exit 1
78  else
79    $QUIET_DIFF diffpos.tmp "$srcdir/${file}.out" > /dev/null || exit 1
80  fi
81  rm -f diffpos.tmp
82done
83
84for args in '' '--survey survey' '--survey survey.xyzzy' '--survey xyzzy' ; do
85  echo "diffpos $args"
86  rm -f diffpos.tmp
87  $DIFFPOS $args "$srcdir/v0.3d" "$srcdir/v0.3d" > diffpos.tmp
88  if test -n "$VERBOSE" ; then
89    cat diffpos.tmp
90  fi
91  $QUIET_DIFF diffpos.tmp /dev/null > /dev/null || exit 1
92  rm -f diffpos.tmp
93done
94test -n "$VERBOSE" && echo "Test passed"
95exit 0
Note: See TracBrowser for help on using the repository browser.