1#!/bin/sh
2
3out_status=0
4
5if [ -z "$srcdir" -o "$srcdir" = "." ] ; then
6    sdir=`pwd`
7elif [ -n "`echo $srcdir |grep '^/'`" ] ; then
8    sdir="$srcdir"
9else
10    sdir="`pwd`/$srcdir"
11fi
12
13if [ -z "$STP_DATA_PATH" ] ; then
14    STP_DATA_PATH="$sdir/../src/xml"
15    export STP_DATA_PATH
16fi
17
18if [ -z "$STP_MODULE_PATH" ] ; then
19    STP_MODULE_PATH="$sdir/../src/main:$sdir/../src/main/.libs"
20    export STP_MODULE_PATH
21fi
22
23valcount=0
24valgrind=
25valopts=''
26
27set_args() {
28    while true ; do
29	case "$1" in
30	    -h*|--h*) usage ;;
31	    -v|--valgrind) valopts='--tool=memcheck' ; valcount=`expr $valgrind + 1` ;;
32	    -c|--cachegrind) valopts='--tool=cachegrind'; valcount=4 ;;
33	    -g|--gdb-attach) valopts='--gdb-attach=yes' ;;
34	    -V|--verbose) quiet= ;;
35	    -q|--quiet) quiet=quiet ;;
36	    --) shift; args="$@"; return ;;
37	    *) return ;;
38	esac
39    shift
40    done
41}
42
43set_args `getopt hgvqncV "$@"`
44
45case "$valcount" in
46    1) valopts="$valopts -q --num-callers=100 --error-limit=no --leak-check=yes";;
47    2) valopts="$valopts --num-callers=100 --error-limit=no --leak-resolution=high --leak-check=yes" ;;
48    3) valopts="$valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes" ;;
49    *) ;;
50esac
51
52if [ -n "$valopts" ] ; then
53    valgrind="valgrind $valopts"
54fi
55
56$valgrind ./testdither
57