| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # Survex test suite - aven tests |
|---|
| 4 | # Copyright (C) 1999-2003,2005,2011,2012 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 | |
|---|
| 20 | testdir=`echo $0 | sed 's!/[^/]*$!!' || echo '.'` |
|---|
| 21 | |
|---|
| 22 | # allow us to run tests standalone more easily |
|---|
| 23 | : ${srcdir="$testdir"} |
|---|
| 24 | |
|---|
| 25 | test -x "$testdir"/../src/cavern || testdir=. |
|---|
| 26 | |
|---|
| 27 | : ${AVEN="$testdir"/../src/aven} |
|---|
| 28 | |
|---|
| 29 | vg_error=123 |
|---|
| 30 | vg_log=vg.log |
|---|
| 31 | if [ -n "$VALGRIND" ] ; then |
|---|
| 32 | rm -f "$vg_log" |
|---|
| 33 | AVEN="$VALGRIND --log-file=$vg_log --error-exitcode=$vg_error $AVEN" |
|---|
| 34 | fi |
|---|
| 35 | |
|---|
| 36 | # Regression test - aven in 1.2.6 segfaulted. |
|---|
| 37 | if test -n "$VERBOSE"; then |
|---|
| 38 | DISPLAY= SURVEXLANG=nosuch $AVEN |
|---|
| 39 | exitcode=$? |
|---|
| 40 | else |
|---|
| 41 | DISPLAY= SURVEXLANG=nosuch $AVEN > /dev/null 2>&1 |
|---|
| 42 | exitcode=$? |
|---|
| 43 | fi |
|---|
| 44 | if [ -n "$VALGRIND" ] ; then |
|---|
| 45 | if [ $exitcode = "$vg_error" ] ; then |
|---|
| 46 | cat "$vg_log" |
|---|
| 47 | rm "$vg_log" |
|---|
| 48 | exit 1 |
|---|
| 49 | fi |
|---|
| 50 | rm "$vg_log" |
|---|
| 51 | fi |
|---|
| 52 | [ "$exitcode" = 1 ] || exit 1 |
|---|
| 53 | |
|---|
| 54 | # Regression test - aven in 1.2.6 segfaulted. |
|---|
| 55 | if test -n "$VERBOSE"; then |
|---|
| 56 | DISPLAY= SURVEXLANG= LANG=nosuch $AVEN |
|---|
| 57 | exitcode=$? |
|---|
| 58 | else |
|---|
| 59 | DISPLAY= SURVEXLANG= LANG=nosuch $AVEN > /dev/null 2>&1 |
|---|
| 60 | exitcode=$? |
|---|
| 61 | fi |
|---|
| 62 | if [ -n "$VALGRIND" ] ; then |
|---|
| 63 | if [ $exitcode = "$vg_error" ] ; then |
|---|
| 64 | cat "$vg_log" |
|---|
| 65 | rm "$vg_log" |
|---|
| 66 | exit 1 |
|---|
| 67 | fi |
|---|
| 68 | rm "$vg_log" |
|---|
| 69 | fi |
|---|
| 70 | [ "$exitcode" = 255 ] || exit 1 |
|---|
| 71 | |
|---|
| 72 | test -n "$VERBOSE" && echo "Test passed" |
|---|
| 73 | exit 0 |
|---|