From: Peter Stamfest Date: Tue, 2 Sep 2014 15:07:53 +0000 (+0200) Subject: implement new test "style": valgrind-logfile. This dumps everything to X-Git-Tag: v1.5.0-rc1~42^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efbeb0d8764aa4c6b57870702d3ee901f5046da9;p=thirdparty%2Frrdtool-1.x.git implement new test "style": valgrind-logfile. This dumps everything to log files named -valgrind.log and only reports the LEAK SUMMARY to stderr in case of reported errors. On travis, currently the logfiles are effectively lost, but this all avoids problems with total test outputs exceeding the current travis limit of 4MB... --- diff --git a/.travis.yml b/.travis.yml index c83d2134..fc2a2c3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ script: - ./configure --prefix=/opt/rrdtool-master --disable-ruby - make CFLAGS+="-g -O0 -fprofile-arcs -ftest-coverage" LDFLAGS+="-fprofile-arcs --coverage" - make check - - make check TESTS_STYLE=valgrind + - make check TESTS_STYLE=valgrind-logfile - sudo make install - cd bindings/perl-shared && make test - /opt/rrdtool-master/bin/rrdtool diff --git a/tests/functions b/tests/functions index ff794c1d..3cfed51c 100644 --- a/tests/functions +++ b/tests/functions @@ -2,9 +2,9 @@ TZ=CET export TZ -BASEDIR=${BASEDIR:-$(dirname $0)} -BUILDDIR=${BUILDDIR:-${BASEDIR}} -TOP_BUILDDIR=${TOP_BUILDDIR:-${BASEDIR}/..} +BASEDIR="${BASEDIR:-$(dirname $0)}" +BUILDDIR="${BUILDDIR:-${BASEDIR}}" +TOP_BUILDDIR="${TOP_BUILDDIR:-${BASEDIR}/..}" # # because valgrind has trouble with glib memory handling @@ -13,6 +13,8 @@ TOP_BUILDDIR=${TOP_BUILDDIR:-${BASEDIR}/..} # we set some env. vars to work around them: function rrdtool_valgrind { + # use a sub shell, so setting environment variables only affects the current + # rrdtool run and not subsequent ones ( G_DEBUG=gc-friendly G_SLICE=all @@ -20,16 +22,38 @@ function rrdtool_valgrind { export G_DEBUG export G_SLICE + VALGRIND_OPTS= + if [ -n "$VALGRIND_LOGFILE" ] ; then + TMP_LOG="${VALGRIND_LOGFILE}.$$.tmp" + VALGRIND_OPTS=--log-file="${TMP_LOG}" + fi + libtool --mode=execute valgrind --tool=memcheck \ - --suppressions=$BASEDIR/valgrind-supressions \ + --suppressions="$BASEDIR/valgrind-supressions" \ --leak-check=full --show-reachable=yes \ --leak-resolution=high --num-callers=20 \ --error-exitcode=111 \ --track-fds=yes \ --track-origins=yes \ --free-fill=ad \ - $TOP_BUILDDIR/src/rrdtool "$@" + $VALGRIND_OPTS \ + "$TOP_BUILDDIR/src/rrdtool" "$@" + RC=$? + + if [ -n "$VALGRIND_LOGFILE" ] ; then + cat -- "${TMP_LOG}" >> "$VALGRIND_LOGFILE" + if [ $RC == 111 ] ; then + sed -n '/LEAK SUMMARY:/,$p' -- "${TMP_LOG}" >&2 + fi + rm -f -- "${TMP_LOG}" + fi + + # make sure to properly report the rrdtool exit code to the caller by: + # - first: exiting with the original exit code from the subshell and + exit $RC ) + # - second: by returning the subshell exit code to the function caller + return $? } if [ -z "$RRDTOOL" ] ; then @@ -37,7 +61,13 @@ if [ -z "$RRDTOOL" ] ; then valgrind) echo >&2 "# Note: exit code 111 indicates a valgrind detected memory problem" RRDTOOL=rrdtool_valgrind - ;; + ;; + valgrind-logfile) + echo >&2 "# Note: exit code 111 indicates a valgrind detected memory problem" + RRDTOOL=rrdtool_valgrind + VALGRIND_LOGFILE="${BASEDIR}/$(basename $0)"-valgrind.log + rm -f "$VALGRIND_LOGFILE" + ;; *) RRDTOOL=$TOP_BUILDDIR/src/rrdtool ;; diff --git a/tests/modify1 b/tests/modify1 index 054b3744..703b4f98 100755 --- a/tests/modify1 +++ b/tests/modify1 @@ -5,7 +5,8 @@ BASE=$BASEDIR/modify-test1 BUILD=$BUILDDIR/modify-test1 DIFF="diff -u" -$RRDTOOL create ${BUILD}a.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:10 RRA:AVERAGE:0.5:5:10 +$RRDTOOL create ${BUILD}a.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:10 RRA:AVERAGE:0.5:5:10 || fail create + # add 50 values to N=10 for T in $(seq 1300000020 60 1300003020) ; do @@ -13,9 +14,11 @@ for T in $(seq 1300000020 60 1300003020) ; do let N=$N+10 done -$RRDTOOL dump ${BUILD}a.rrd | $DIFF - ${BASE}.create.dump && ok "create" || fail "create" +$RRDTOOL dump ${BUILD}a.rrd | $DIFF - ${BASE}.create.dump +report "created content" # extend base RRA, refill from coarse RRA cp ${BUILD}a.rrd ${BUILD}b.rrd $RRDTOOL tune ${BUILD}b.rrd RRA#0:+10 || fail "tune" -$RRDTOOL dump ${BUILD}b.rrd | $DIFF - ${BASE}.mod1.dump && ok "extend base RRA" || fail "extend base RRA" +$RRDTOOL dump ${BUILD}b.rrd | $DIFF - ${BASE}.mod1.dump +report "extend base RRA"