From: Peter Stamfest Date: Wed, 12 Mar 2014 20:11:12 +0000 (+0100) Subject: Valgrind support for the test suite. valgrind gets used when called as "make check... X-Git-Tag: v1.5.0-rc1~117^2~2^2~19^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc10fd20868e4dbcad68358e6585620f9b94b6fa;p=thirdparty%2Frrdtool-1.x.git Valgrind support for the test suite. valgrind gets used when called as "make check TESTS_STYLE=valgrind" --- diff --git a/tests/functions b/tests/functions index 9a6802fb..2f5a13d7 100644 --- a/tests/functions +++ b/tests/functions @@ -1,14 +1,26 @@ - BASEDIR=$(dirname $0) if [ -z "$RRDTOOL" ] ; then - RRDTOOL=$BASEDIR/../src/rrdtool + case "$TESTS_STYLE" in + valgrind) + echo >&2 "# Note: exit code 111 indicates a valgrind detected memory problem" + RRDTOOL="libtool --mode=execute valgrind --tool=memcheck \ + --suppressions=$BASEDIR/valgrind-supressions \ + --leak-check=full --show-reachable=yes \ + --leak-resolution=high --num-callers=20 \ + --error-exitcode=111 --log-file=/dev/null \ + $BASEDIR/../src/rrdtool" + ;; + *) + RRDTOOL=$BASEDIR/../src/rrdtool + ;; + esac fi DIFF="diff -u" function fail { - echo >&2 "FAILED:" "$@" + echo >&2 "FAILED: (rc=$?)" "$@" if [ -n "$CONTINUE" ] ; then return fi diff --git a/tests/modify3 b/tests/modify3 index 0db4a420..c49ec10c 100755 --- a/tests/modify3 +++ b/tests/modify3 @@ -8,14 +8,14 @@ $RRDTOOL create ${BASE}a.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U DS # add 50 values to N=10 for T in $(seq 1300000020 60 1300003020) ; do - rrdtool update ${BASE}a.rrd --template a:b:c $T:$N:$((10000+$N)):$((20000+$N)) + rrdtool update ${BASE}a.rrd --template a:b:c $T:$N:$((10000+$N)):$((20000+$N)) || fail update let N=$N+10 done $RRDTOOL dump ${BASE}a.rrd | diff - $BASEDIR/modify-test3.create.dump && ok "create" || fail "create" # extend base RRA, refill from coarse RRA -$RRDTOOL modify ${BASE}a.rrd ${BASE}b.rrd DEL:a RRA#0:+10 +$RRDTOOL modify ${BASE}a.rrd ${BASE}b.rrd DEL:a RRA#0:+10 || fail modify $RRDTOOL dump ${BASE}b.rrd | diff - $BASEDIR/modify-test3.mod1.dump && ok "extend base RRA" || fail "extend base RRA" diff --git a/tests/modify4 b/tests/modify4 index 9f501d2b..a493acfc 100755 --- a/tests/modify4 +++ b/tests/modify4 @@ -10,15 +10,15 @@ BASE=$BASEDIR/modify4-test # test: add the additional RRA to the first and compare dumps -$RRDTOOL create ${BASE}a1.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 -$RRDTOOL create ${BASE}a2.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 RRA:AVERAGE:0.5:4:10 +$RRDTOOL create ${BASE}a1.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 || fail create1 +$RRDTOOL create ${BASE}a2.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 RRA:AVERAGE:0.5:4:10 || fail create2 # add 50 values - note that we do NOT add it exactly for boundary times, and # that we end at a NON CDP boundary for 5-PDP RRAs: N=10 for T in $(seq 1300000050 60 1300002990) ; do - $RRDTOOL update ${BASE}a1.rrd --template a $T:$N - $RRDTOOL update ${BASE}a2.rrd --template a $T:$N + $RRDTOOL update ${BASE}a1.rrd --template a $T:$N || fail update1 + $RRDTOOL update ${BASE}a2.rrd --template a $T:$N || fail update2 let N=$N+10 done @@ -27,12 +27,12 @@ report create 1 $RRDTOOL dump ${BASE}a2.rrd | $DIFF ${BASE}a2-create.dump - report create 2 -$RRDTOOL modify ${BASE}a2.rrd ${BASE}b2.rrd DELRRA:5 +$RRDTOOL modify ${BASE}a2.rrd ${BASE}b2.rrd DELRRA:5 || fail modify $RRDTOOL dump ${BASE}b2.rrd | $DIFF ${BASE}a1-create.dump - report "remove additional RRA from second - must then be equal original first" -$RRDTOOL modify ${BASE}a1.rrd ${BASE}b1.rrd RRA:AVERAGE:0.5:4:10 +$RRDTOOL modify ${BASE}a1.rrd ${BASE}b1.rrd RRA:AVERAGE:0.5:4:10 || fail modify $RRDTOOL dump ${BASE}b1.rrd | $DIFF ${BASE}a2-create.dump - report "add additional RRA to first - must then be equal original second" diff --git a/tests/modify5 b/tests/modify5 index bbf00dca..5a9f7b96 100755 --- a/tests/modify5 +++ b/tests/modify5 @@ -10,8 +10,8 @@ BASE=$BASEDIR/modify5-test # test: add the additional RRA to the first and compare dumps -$RRDTOOL create ${BASE}a1.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 -$RRDTOOL create ${BASE}a2.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 RRA:AVERAGE:0.5:4:10 +$RRDTOOL create ${BASE}a1.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 || fail create1 +$RRDTOOL create ${BASE}a2.rrd --start 1300000000 --step 60 DS:a:GAUGE:120:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 RRA:AVERAGE:0.5:4:10 || fail create2 # add 50 values - note that we do NOT add it exactly for boundary times, and # that we end at a NON CDP boundary for 5-PDP RRAs: @@ -21,8 +21,8 @@ for T in $(seq 1300000050 60 1300002990) ; do UPDATE_STRING="$UPDATE_STRING $T:$N" let N=$N+10 done -$RRDTOOL update ${BASE}a1.rrd --template a $UPDATE_STRING -$RRDTOOL update ${BASE}a2.rrd --template a $UPDATE_STRING +$RRDTOOL update ${BASE}a1.rrd --template a $UPDATE_STRING || fail update1 +$RRDTOOL update ${BASE}a2.rrd --template a $UPDATE_STRING || fail update2 $RRDTOOL dump ${BASE}a1.rrd | $DIFF ${BASE}a1-create.dump - report create 1