2013-07-26 14:16:47 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
LIBTOOL="$1"; shift
|
|
|
|
|
VALGRIND="$1"; shift
|
|
|
|
|
SUPPRESSIONS="$1"; shift
|
2015-02-08 11:52:22 +01:00
|
|
|
if [ "$1" = "--launch-dbus" ]; then
|
|
|
|
|
# Spawn DBus if there's none
|
|
|
|
|
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
|
|
|
|
|
eval `dbus-launch --sh-syntax`
|
|
|
|
|
trap "kill $DBUS_SESSION_BUS_PID" EXIT
|
|
|
|
|
fi
|
|
|
|
|
shift
|
|
|
|
|
fi
|
2013-07-26 14:16:47 +02:00
|
|
|
TEST="$1"; shift
|
|
|
|
|
|
2015-02-09 15:46:15 +01:00
|
|
|
if [ "$NMTST_NO_VALGRIND" != "" ]; then
|
|
|
|
|
"$TEST"
|
|
|
|
|
exit $?
|
|
|
|
|
fi
|
|
|
|
|
|
2013-07-26 14:16:47 +02:00
|
|
|
LOGFILE="valgrind-`echo "$TEST" | tr -cd '[:alpha:]-'`.log"
|
|
|
|
|
|
|
|
|
|
export G_SLICE=always-malloc
|
|
|
|
|
export G_DEBUG=gc-friendly
|
|
|
|
|
$LIBTOOL --mode=execute "$VALGRIND" \
|
|
|
|
|
--quiet \
|
|
|
|
|
--error-exitcode=1 \
|
|
|
|
|
--leak-check=full \
|
|
|
|
|
--gen-suppressions=all \
|
|
|
|
|
--suppressions="$SUPPRESSIONS" \
|
|
|
|
|
--log-file="$LOGFILE" \
|
|
|
|
|
"$TEST"
|
|
|
|
|
RESULT=$?
|
|
|
|
|
|
2015-02-08 19:28:55 +01:00
|
|
|
if [ $RESULT -eq 0 -a "$(wc -c "$LOGFILE" | awk '{print$1}')" -ne 0 ]; then
|
|
|
|
|
echo "valgrind succeeded, but log is not empty: $LOGFILE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2015-02-04 10:34:05 +01:00
|
|
|
if [ $RESULT -ne 0 -a $RESULT -ne 77 ]; then
|
2013-07-30 11:34:26 +02:00
|
|
|
echo "Don't forget to check the valgrind log at '`realpath $LOGFILE`'." >&2
|
2013-07-26 14:16:47 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit $RESULT
|