| [9cc3854] | 1 | #!/bin/sh |
|---|
| [b4fe9fb] | 2 | # |
|---|
| 3 | # Survex test suite - smoke tests |
|---|
| [a948c08] | 4 | # Copyright (C) 1999-2025 Olly Betts |
|---|
| [b4fe9fb] | 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 |
|---|
| [9cc3854] | 19 | |
|---|
| 20 | testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'` |
|---|
| 21 | |
|---|
| [ed34f49] | 22 | # allow us to run tests standalone more easily |
|---|
| 23 | : ${srcdir="$testdir"} |
|---|
| [87fcddb] | 24 | if [ -z "$SURVEXLIB" ] ; then |
|---|
| 25 | SURVEXLIB=`cd "$srcdir/../lib" && pwd` |
|---|
| 26 | export SURVEXLIB |
|---|
| [ed34f49] | 27 | fi |
|---|
| 28 | |
|---|
| [9cc3854] | 29 | test -x "$testdir"/../src/cavern || testdir=. |
|---|
| 30 | |
|---|
| [deea763] | 31 | # Ensure that --version and --help work without an X display. |
|---|
| 32 | DISPLAY= |
|---|
| 33 | export DISPLAY |
|---|
| 34 | |
|---|
| [79b32a95] | 35 | PROGS="cavern diffpos extend sorterr survexport aven" |
|---|
| [9cc3854] | 36 | |
|---|
| [43e8c72] | 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. |
|---|
| 40 | LSAN_OPTIONS=leak_check_at_exit=0 |
|---|
| 41 | export LSAN_OPTIONS |
|---|
| 42 | |
|---|
| [33a2d49] | 43 | vgrun= |
|---|
| 44 | vg_error=123 |
|---|
| 45 | vg_log=vg.log |
|---|
| 46 | if [ -n "$VALGRIND" ] ; then |
|---|
| 47 | rm -f "$vg_log" |
|---|
| 48 | vgrun="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error" |
|---|
| 49 | fi |
|---|
| 50 | |
|---|
| [9cc3854] | 51 | for p in ${PROGS}; do |
|---|
| [33a2d49] | 52 | echo $p |
|---|
| 53 | for o in version help ; do |
|---|
| [a948c08] | 54 | if test "$VERBOSE" = 1; then |
|---|
| 55 | $vgrun "$testdir/../src/$p" --$o > stdout.log |
|---|
| 56 | exitcode=$? |
|---|
| 57 | test $exitcode = 0 || cat stdout.log |
|---|
| 58 | rm stdout.log |
|---|
| 59 | elif test -n "$VERBOSE"; then |
|---|
| [33a2d49] | 60 | $vgrun "$testdir/../src/$p" --$o |
|---|
| 61 | exitcode=$? |
|---|
| 62 | else |
|---|
| 63 | $vgrun "$testdir/../src/$p" --$o > /dev/null |
|---|
| 64 | exitcode=$? |
|---|
| [ebce30c] | 65 | fi 2> stderr.log |
|---|
| 66 | if [ -s stderr.log ] ; then |
|---|
| 67 | echo "$p --$o produced output on stderr:" |
|---|
| 68 | cat stderr.log |
|---|
| 69 | rm stderr.log |
|---|
| 70 | exit 1 |
|---|
| [33a2d49] | 71 | fi |
|---|
| [ebce30c] | 72 | rm stderr.log |
|---|
| [33a2d49] | 73 | if [ -n "$VALGRIND" ] ; then |
|---|
| 74 | if [ $exitcode = "$vg_error" ] ; then |
|---|
| 75 | cat "$vg_log" |
|---|
| 76 | rm "$vg_log" |
|---|
| 77 | exit 1 |
|---|
| 78 | fi |
|---|
| 79 | rm "$vg_log" |
|---|
| 80 | fi |
|---|
| 81 | [ "$exitcode" = 0 ] || exit 1 |
|---|
| 82 | done |
|---|
| [9cc3854] | 83 | done |
|---|
| [b0d0ff5] | 84 | |
|---|
| [bbe0a27] | 85 | test -n "$VERBOSE" && echo "Test passed" |
|---|
| [9cc3854] | 86 | exit 0 |
|---|