1#!@BASHREAL@
2
3# Driver for curve tester
4#
5# Copyright 2018 Robert Krawitz (rlk@alum.mit.edu)
6#
7# This program is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by the Free
9# Software Foundation; either version 2 of the License, or (at your option)
10# any later version.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15# for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
20if [[ -n "$STP_TEST_LOG_PREFIX" ]] ; then
21    redir="${STP_TEST_LOG_PREFIX}${0##*/}_$$.log"
22    if [[ -n $BUILD_VERBOSE ]] ; then
23	exec > >(tee -a "$redir" >&3)
24    else
25	exec 1>>"$redir"
26    fi
27    exec 2>&1
28fi
29set -e
30
31retval=0
32
33if [[ -z $srcdir || $srcdir = . ]] ; then
34    sdir=$(pwd)
35elif [[ $srcdir =~ ^/ ]] ; then
36    sdir="$srcdir"
37else
38    sdir="$(pwd)/$srcdir"
39fi
40
41export STP_DATA_PATH=${STP_DATA_PATH:-"$sdir/../src/xml"}
42export STP_MODULE_PATH=${STP_MODULE_PATH:-"$sdir/../src/main:$sdir/../src/main/.libs"}
43
44declare valgrind=0
45
46function runit() {
47    echo "================================================================"
48    echo "$@"
49    [[ -z $STP_TEST_DEBUG ]] && "$@"
50}
51
52case "$STP_TEST_PROFILE" in
53    valgrind*)
54	vg="libtool --mode=execute valgrind"
55	valgrind="$vg --num-callers=50 --leak-check=yes --error-limit=no --error-exitcode=1"
56	;;
57    *)
58	valgrind=
59	;;
60esac
61
62runit $valgrind ./curve
63