1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#! @BASH_SHELL@
# --------------------------------------------------------------------- #
#
# Script to run some examples through VALGRIND.
#
# Michael Hagemann <michael.hagemann@unibas.ch>
#
# modified by Lorenzo Bettini <http://www.lorenzobettini.it>
#
# this requires bash extensions
#
# --------------------------------------------------------------------- #
# Hack to run valgrind with new glibcs. Problem: new TLS (thread
# local storage)
#VG_ENV="LD_ASSUME_KERNEL=2.2.5"
# --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes --suppressions=./suppressions.supp
# --num-callers=20 --leak-resolution=high --suppressions=/home/bettini/work/src2tags/tests/suppressions.supp
VG_PRG="@VALGRIND@"
VG_ARGS="--tool=memcheck --num-callers=20 --leak-check=yes --leak-resolution=high --show-reachable=yes --suppressions=@srcdir@/suppressions.supp"
#VG_ARGS="--tool=memcheck --num-callers=20 --leak-check=yes --leak-resolution=high --suppressions=@srcdir@/suppressions.supp"
VGRIND="${VG_ENV} ${VG_PRG} ${VG_ARGS}"
if test ! -x "${VG_PRG}"; then
echo Valgrind not found! Check path.
exit 1
fi
# --------------------------------------------------------------------- #
DATE=`date +"%Y-%m-%d_%H%M"`
SUMMARY=valgrind_summary.log
TMP_LOG=valgrind_tmp.log
ERROR=0
# --------------------------------------------------------------------- #
vgrind () {
if test ! -x "$1" -o "$1" == `basename $0`; then
echo "Skipping $1."
return
fi
echo -n "Running $* ..."
tmp_err=
if [[ $1 == *.sh ]]; then
# echo "$1 ${VGRIND} >${TMP_LOG} 2>&1 ..."
eval $1 ${VGRIND} >${TMP_LOG} 2>&1;
else
# echo "${VGRIND} $* >${TMP_LOG} 2>&1 ..."
eval ${VGRIND} $* >${TMP_LOG} 2>&1
fi;
#grep -e "LEAK SUMMARY" ${TMP_LOG} >/dev/null 2>&1
grep -E "(reachable|lost): [1-9][0-9]*" ${TMP_LOG} >/dev/null 2>&1
if test "$?" == "0"; then
echo -n " LEAKS!"
echo "" >> ${SUMMARY}
echo "** $*, LEAKS" >> ${SUMMARY}
cat ${TMP_LOG} >> ${SUMMARY}
tmp_err=1
fi
grep -e "[1-9][0-9]* error" ${TMP_LOG} >/dev/null 2>&1
if test "$?" == "0"; then
echo -n " ERRORS!"
echo "" >> ${SUMMARY}
echo "** $*, ERRORS" >> ${SUMMARY}
cat ${TMP_LOG} >> ${SUMMARY}
tmp_err=1
fi
if test "x${tmp_err}" == "x"; then
echo " OK."
else
ERROR=1
echo ""
fi
rm -f ${TMP_LOG}
}
# --------------------------------------------------------------------- #
echo "Run at ${DATE}" >${SUMMARY}
vgrind $*
# --------------------------------------------------------------------- #
# cat ${SUMMARY}
exit ${ERROR}
|