[fbc3a20] | 1 | #!/bin/sh |
---|
[d4ea980] | 2 | # |
---|
| 3 | # Survex test suite - diffpos tests |
---|
[43e8c72] | 4 | # Copyright (C) 1999-2021 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 |
---|
[6b8ff5b] | 19 | |
---|
[d4d8efe] | 20 | testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'` |
---|
| 21 | |
---|
[6b8ff5b] | 22 | # allow us to run tests standalone more easily |
---|
[d4d8efe] | 23 | : ${srcdir="$testdir"} |
---|
[647407d] | 24 | |
---|
[5476de6] | 25 | # force VERBOSE if we're run on a subset of tests |
---|
| 26 | test -n "$*" && VERBOSE=1 |
---|
| 27 | |
---|
[87681b8] | 28 | test -x "$testdir"/../src/cavern || testdir=. |
---|
| 29 | |
---|
[6448891] | 30 | case `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 | ;; |
---|
| 40 | esac |
---|
| 41 | |
---|
[d4d8efe] | 42 | : ${DIFFPOS="$testdir"/../src/diffpos} |
---|
[6b8ff5b] | 43 | |
---|
[e0c8f98] | 44 | : ${TESTS=${*:-"delatend addatend"}} |
---|
[1422c39] | 45 | |
---|
[0ebdaa6] | 46 | SURVEXLANG=en |
---|
| 47 | export SURVEXLANG |
---|
| 48 | |
---|
[43e8c72] | 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. |
---|
| 52 | LSAN_OPTIONS=leak_check_at_exit=0 |
---|
| 53 | export LSAN_OPTIONS |
---|
| 54 | |
---|
[38c4c5c] | 55 | vg_error=123 |
---|
| 56 | vg_log=vg.log |
---|
| 57 | if [ -n "$VALGRIND" ] ; then |
---|
| 58 | rm -f "$vg_log" |
---|
| 59 | DIFFPOS="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $DIFFPOS" |
---|
| 60 | fi |
---|
| 61 | |
---|
[1422c39] | 62 | for file in $TESTS ; do |
---|
[fbc3a20] | 63 | echo $file |
---|
[87681b8] | 64 | rm -f diffpos.tmp |
---|
[d4ea980] | 65 | $DIFFPOS "$srcdir/${file}a.pos" "$srcdir/${file}b.pos" > diffpos.tmp |
---|
[38c4c5c] | 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 |
---|
[d4d8efe] | 75 | if test -n "$VERBOSE" ; then |
---|
[87681b8] | 76 | cat diffpos.tmp |
---|
[6448891] | 77 | $DIFF diffpos.tmp "$srcdir/${file}.out" || exit 1 |
---|
[d4d8efe] | 78 | else |
---|
[6448891] | 79 | $QUIET_DIFF diffpos.tmp "$srcdir/${file}.out" > /dev/null || exit 1 |
---|
[d4d8efe] | 80 | fi |
---|
[87681b8] | 81 | rm -f diffpos.tmp |
---|
[fbc3a20] | 82 | done |
---|
[4d3dfdf] | 83 | |
---|
| 84 | for args in '' '--survey survey' '--survey survey.xyzzy' '--survey xyzzy' ; do |
---|
| 85 | echo "diffpos $args" |
---|
| 86 | rm -f diffpos.tmp |
---|
[d4ea980] | 87 | $DIFFPOS $args "$srcdir/v0.3d" "$srcdir/v0.3d" > diffpos.tmp |
---|
[4d3dfdf] | 88 | if test -n "$VERBOSE" ; then |
---|
| 89 | cat diffpos.tmp |
---|
| 90 | fi |
---|
[6448891] | 91 | $QUIET_DIFF diffpos.tmp /dev/null > /dev/null || exit 1 |
---|
[4d3dfdf] | 92 | rm -f diffpos.tmp |
---|
| 93 | done |
---|
[bbe0a27] | 94 | test -n "$VERBOSE" && echo "Test passed" |
---|
[fbc3a20] | 95 | exit 0 |
---|