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
|
2015-05-14 14:39:23 +02:00
|
|
|
# Spawn DBus
|
|
|
|
|
eval `dbus-launch --sh-syntax`
|
|
|
|
|
trap "kill $DBUS_SESSION_BUS_PID" EXIT
|
2015-02-08 11:52:22 +01:00
|
|
|
shift
|
|
|
|
|
fi
|
2015-05-14 14:45:57 +02:00
|
|
|
TEST="$1"
|
2013-07-26 14:16:47 +02:00
|
|
|
|
2015-02-09 15:46:15 +01:00
|
|
|
if [ "$NMTST_NO_VALGRIND" != "" ]; then
|
2015-05-26 15:34:03 +02:00
|
|
|
"$@"
|
2015-02-09 15:46:15 +01:00
|
|
|
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" \
|
2015-06-04 12:26:25 +02:00
|
|
|
--num-callers=100 \
|
2013-07-26 14:16:47 +02:00
|
|
|
--log-file="$LOGFILE" \
|
2015-05-14 14:45:57 +02:00
|
|
|
"$@"
|
2013-07-26 14:16:47 +02:00
|
|
|
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
|
2015-05-25 17:15:33 +02:00
|
|
|
echo "valgrind failed! Check the log at '`realpath $LOGFILE`'." >&2
|
|
|
|
|
UNRESOLVED=$(awk -F: '/obj:\// {print $NF}' "$LOGFILE" | sort | uniq)
|
|
|
|
|
if [ -n "$UNRESOLVED" ]; then
|
|
|
|
|
echo Some addresses could not be resolved into symbols. >&2
|
|
|
|
|
echo The errors might get suppressed when you install the debuging symbols. >&2
|
|
|
|
|
if [ -x /usr/bin/dnf ]; then
|
|
|
|
|
echo Hint: dnf debuginfo-install $UNRESOLVED >&2
|
|
|
|
|
elif [ -x /usr/bin/debuginfo-install ]; then
|
|
|
|
|
echo Hint: debuginfo-install $UNRESOLVED >&2
|
|
|
|
|
else
|
|
|
|
|
echo Files without debugging symbols: $UNRESOLVED >&2
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2013-07-26 14:16:47 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit $RESULT
|