| 1 |
#!@BASHREAL@ |
| 2 |
|
| 3 |
# Driver for testdither |
| 4 |
# |
| 5 |
# Copyright 2001-2008 Robert Krawitz ([email protected]) |
| 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 |
|
| 20 |
# Don't want to run this at all as part of automated test |
| 21 |
[ -n "$STP_TEST_SUITE" ] && exit 77 |
| 22 |
|
| 23 |
if [[ -n "$STP_TEST_LOG_PREFIX" ]] ; then |
| 24 |
redir="${STP_TEST_LOG_PREFIX}${0##*/}_$$.log" |
| 25 |
if [[ -n $BUILD_VERBOSE ]] ; then |
| 26 |
exec > >(tee -a "$redir" >&3) |
| 27 |
else |
| 28 |
exec 1>>"$redir" |
| 29 |
fi |
| 30 |
exec 2>&1 |
| 31 |
fi |
| 32 |
|
| 33 |
if [[ -z $srcdir || $srcdir = "." ]] ; then |
| 34 |
sdir=$(pwd) |
| 35 |
elif grep -q '^/' <<< "$srcdir" ; then |
| 36 |
sdir="$srcdir" |
| 37 |
else |
| 38 |
sdir="$(pwd)/$srcdir" |
| 39 |
fi |
| 40 |
|
| 41 |
if [ -z "$STP_DATA_PATH" ] ; then |
| 42 |
STP_DATA_PATH="$sdir/../src/xml" |
| 43 |
export STP_DATA_PATH |
| 44 |
fi |
| 45 |
|
| 46 |
if [ -z "$STP_MODULE_PATH" ] ; then |
| 47 |
STP_MODULE_PATH="$sdir/../src/main:$sdir/../src/main/.libs" |
| 48 |
export STP_MODULE_PATH |
| 49 |
fi |
| 50 |
|
| 51 |
valcount=0 |
| 52 |
valgrind= |
| 53 |
valopts='' |
| 54 |
|
| 55 |
set_args() { |
| 56 |
while true ; do |
| 57 |
case "$1" in |
| 58 |
-h*|--h*) usage ;; |
| 59 |
-v|--valgrind) valopts='--tool=memcheck' ; valcount=$((valgrind + 1)) ;; |
| 60 |
-c|--cachegrind) valopts='--tool=cachegrind'; valcount=4 ;; |
| 61 |
-g|--gdb-attach) valopts='--gdb-attach=yes' ;; |
| 62 |
-V|--verbose) quiet= ;; |
| 63 |
-q|--quiet) quiet=quiet ;; |
| 64 |
--) shift; args="$*"; return ;; |
| 65 |
*) return ;; |
| 66 |
esac |
| 67 |
shift |
| 68 |
done |
| 69 |
} |
| 70 |
|
| 71 |
set_args $(getopt hgvqncV "$@") |
| 72 |
|
| 73 |
case "$valcount" in |
| 74 |
1) valopts="$valopts $quiet --num-callers=100 --error-limit=no --leak-check=yes";; |
| 75 |
2) valopts="$valopts --num-callers=100 --error-limit=no --leak-resolution=high --leak-check=yes" ;; |
| 76 |
3) valopts="$valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes" ;; |
| 77 |
*) ;; |
| 78 |
esac |
| 79 |
|
| 80 |
if [ -n "$valopts" ] ; then |
| 81 |
valgrind="libtool --mode=execute valgrind $valopts" |
| 82 |
fi |
| 83 |
|
| 84 |
$valgrind ./testdither |