]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
implement new test "style": valgrind-logfile. This dumps everything to
authorPeter Stamfest <peter@stamfest.at>
Tue, 2 Sep 2014 15:07:53 +0000 (17:07 +0200)
committerPeter Stamfest <peter@stamfest.at>
Tue, 2 Sep 2014 15:07:53 +0000 (17:07 +0200)
log files named <test>-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...

.travis.yml
tests/functions
tests/modify1

index c83d2134df0b97576fb5f71557adab965605de5d..fc2a2c3db0c42e21b819ebfefb8c090fb416077a 100644 (file)
@@ -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
index ff794c1d1b7800fff652f2f638e215d35a0b2604..3cfed51c396d0d8a0b35e5a1bab90cadeff47e94 100644 (file)
@@ -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
                ;;
index 054b3744c9f49d85a27a27dcd82c6b0ca1cbcfd8..703b4f98eef8b6f969ef0f11e0d17ce17ffb29bc 100755 (executable)
@@ -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"