3 # Survex test suite - test using img library non-hosted
4 # Copyright (C) 2020,2021 Olly Betts
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.
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.
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
20 testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'`
22 # allow us to run tests standalone more easily
23 : ${srcdir="$testdir"}
25 # force VERBOSE if we're run on a subset of tests
26 test -n "$*" && VERBOSE=1
28 test -x "$testdir"/../src/cavern || testdir=.
30 # Make testdir absolute, so we can cd before running cavern to get a consistent
31 # path in diagnostic messages.
32 testdir=`(cd "$testdir" && pwd)`
34 : ${CAVERN="$testdir"/../src/cavern}
35 : ${IMGTEST="$testdir"/../src/imgtest}
37 : ${TESTS=${*:-"simple survey"}}
39 # Suppress checking for leaks on exit if we're build with lsan - we don't
40 # generally waste effort to free all allocations as the OS will reclaim
42 LSAN_OPTIONS=leak_check_at_exit=0
46 vg_log=$testdir/vg.log
47 if [ -n "$VALGRIND" ] ; then
49 CAVERN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $CAVERN"
50 IMGTEST="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $IMGTEST"
53 for test in $TESTS ; do
56 rm -f "$file.3d" "$file.err" cavern.tmp imgtest.tmp
59 srcdir=. $CAVERN "$file.svx" --output="$pwd/$file" > "$pwd/cavern.tmp" 2>&1
62 test -n "$VERBOSE" && cat cavern.tmp
63 if [ -n "$VALGRIND" ] ; then
64 if [ $exitcode = "$vg_error" ] ; then
71 test $exitcode = 0 || exit 1
79 $IMGTEST "$file.3d" $args > imgtest.tmp 2>&1
81 if test -n "$VERBOSE" ; then
84 if [ -n "$VALGRIND" ] ; then
85 if [ $exitcode = "$vg_error" ] ; then
92 test $exitcode = 0 || exit 1
94 rm -f "$file.3d" "$file.err" cavern.tmp imgtest.tmp
96 test -n "$VERBOSE" && echo "Test passed"