BIND 10 master, updated. 8053d85447560fa3c64f276881496513c66f4ba0 Merge branch 'work/valgrind'
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Mar 2 19:54:15 UTC 2011
The branch, master has been updated
via 8053d85447560fa3c64f276881496513c66f4ba0 (commit)
via 5d246e92aef87505e9392274cacbabbd20478d3e (commit)
via ae0b20c57c48c4932b9aff2146f5d76f9eff5a90 (commit)
via f9152fae80f751adc95c894b872204e98504dcb8 (commit)
via 40f87a0aa5e6b2e8f86346f181b5e1d785c36e67 (commit)
via 3d69f66a688c09a20083a52f2a64b9327ede70c6 (commit)
via f79cea1f5a7ce45498a7a94cb5ed9aae6dfe1a7f (commit)
via 6458b98ea487620fd4c47b0de5b5bc2e5fe97794 (commit)
via 4fa3cf5c5f623d24c357aac1d689a068528c73ce (commit)
via 923a47079606a6ba9368d94007b3c24aaa4ca7e5 (commit)
via ddd04eed61f4945303400569629d66cf685833d2 (commit)
from 0047c74393959975ffd9f75a687a60f1f1c42a9c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8053d85447560fa3c64f276881496513c66f4ba0
Merge: 0047c74393959975ffd9f75a687a60f1f1c42a9c 5d246e92aef87505e9392274cacbabbd20478d3e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed Mar 2 20:43:37 2011 +0100
Merge branch 'work/valgrind'
-----------------------------------------------------------------------
Summary of changes:
tools/README | 5 ++-
tools/tests_in_valgrind.sh | 75 ++++++++++++++++++++++++++++++++++++++++
tools/valgrind_test_cleaner.pl | 64 ++++++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 2 deletions(-)
create mode 100755 tools/tests_in_valgrind.sh
create mode 100755 tools/valgrind_test_cleaner.pl
-----------------------------------------------------------------------
diff --git a/tools/README b/tools/README
index a18b38a..ce8ddea 100644
--- a/tools/README
+++ b/tools/README
@@ -1,3 +1,4 @@
The "tools" directory contains scripts for helping the BIND 10
-developers maintain the source tree. These are not intended
-to be built nor installed by the build system.
+developers with various tasks, eg. maintaining the source tree,
+running some tests. These are not intended to be built nor
+installed by the build system.
diff --git a/tools/tests_in_valgrind.sh b/tools/tests_in_valgrind.sh
new file mode 100755
index 0000000..14e91ba
--- /dev/null
+++ b/tools/tests_in_valgrind.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+###########################################
+# This script runs all tests in valgrind. Configure and compile bind the way
+# you want it to be tested (you should use --with-gtest, however, or you get
+# no tests). Then run this script from the top build directory.
+#
+# Note that the test isn't what you would call "production quality" (it is
+# expected to be used by the bind10 developers, not end user) and might break,
+# some ways of breaking it are known.
+#
+# There are two variables that modify it's behaviour.
+# * VALGRIND_FLAGS are the flag passed to valgrind. There are some, hopefully
+# reasonable defaults which you can overwrite. Note that the variable is
+# used unmodified inside a sed pattern with # as a modifier, which can
+# easily break it. There was no motivation to fix this.
+# * VALGRIND_FILE is the file to store the output into. Default is valgrind.log
+###########################################
+
+# First, make sure the tests are up to date
+make
+
+if [ $? = 2 ] ; then
+ echo "Did you run configure? Or maybe you're running the script from the tools directory? (you need to run it from the top bind10 build directory)"
+ exit 1
+fi
+
+set -e
+
+# Some configuration
+# TODO Escape for sed, this might break
+LOGFILE="${VALGRIND_FILE:-`pwd`/valgrind.log}"
+FLAGS="${VALGRIND_FLAGS:---leak-check=full --track-fds=yes}"
+FLAGS="$FLAGS --log-file=$LOGFILE.%p"
+
+FOUND_ANY=false
+FAILED=
+
+# Find all the tests (yes, doing it by a name is a nasty hack)
+# Since the while runs in a subprocess, we need to get the assignments out, done by the eval
+eval $(find . -type f -name run_unittests -print | grep -v '\.libs/run_unittests$' | while read testname ; do
+ sed -e 's#exec "#exec valgrind '"$FLAGS"' "#' "$testname" > "$testname.valgrind"
+ chmod +x "$testname.valgrind"
+ echo "$testname" >>"$LOGFILE"
+ echo "===============" >>"$LOGFILE"
+ OLDDIR="`pwd`"
+ cd $(dirname "$testname")
+ ./run_unittests.valgrind >&2 &
+ PID="$!"
+ set +e
+ wait "$PID"
+ CODE="$?"
+ set -e
+ cd "$OLDDIR"
+ if [ "$CODE" != 0 ] ; then
+ echo 'FAILED="$FAILED
+'"$testname"'"'
+ fi
+ NAME="$LOGFILE.$PID"
+ rm "$testname.valgrind"
+ # Remove the ones from death tests
+ grep "==$PID==" "$NAME" >>"$LOGFILE"
+ rm "$NAME"
+ echo 'FOUND_ANY=true'
+done)
+
+if test -n "$FAILED"; then
+ echo "These tests failed:" >&2
+ echo "$FAILED" >&2
+fi
+
+if ! $FOUND_ANY ; then
+ echo "No test was found. It is possible you configured without --with-gtest or you run it from wrong directory" >&2
+ exit 1
+fi
diff --git a/tools/valgrind_test_cleaner.pl b/tools/valgrind_test_cleaner.pl
new file mode 100755
index 0000000..9928e9f
--- /dev/null
+++ b/tools/valgrind_test_cleaner.pl
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+# This script can be used on a valgrind output of the tests (from
+# tests_in_valgrind.sh) to remove some uninteresting error reports.
+# Since we care about the tested application not leaking/crashing, not
+# the tests itself, memory leaks that are caused only by the tests
+# (eg. unreleased test data), we don't want to have logs full of them.
+#
+# This script does some heuristics to eliminate some of such error
+# reports. Currently, the memory lost reports whose stack contains
+# no call from the real application are suppressed.
+#
+# Of course, the rest still can contain many uninteresting entries.
+
+# Yes, it's perl even when we use python. I wrote it for myself when
+# I needed to clean the outputs and after it proved useful to me, I
+# thought it might be for others too, so I just included it. It's not
+# that we would be switching to perl. If it should grow in future to
+# include more heuristics and do something more fancy, we should probably
+# rewrite it in python instead.
+
+my ($block, $blockOK);
+
+sub endBlock(_) {
+ return unless $block;
+ if ($blockOK) {
+ print @$block;
+ }
+ undef $block;
+ undef $blockOK;
+}
+
+sub startBlock(_) {
+ $block = [@_];
+}
+
+sub addToBlock(_) {
+ my ($line) = @_;
+ push @$block, $line;
+ return unless $line =~ /^==\d+==\s+(at|by) 0x[0-9A-F]+: (.*) \(.+:\d+\)$/;
+ $_ = $2;
+ return $blockOK = 1 if /^isc::/;
+ return $blockOK = 1 if /^asiolink:/;
+ return if /^main \(/;
+ return if /^testing::/;
+ return if /^\(anonymous namespace\)::/;
+ $blockOK = 1;
+}
+
+while(<>) {
+ if (/^==\d+==\s*$/) {
+ print;
+ endBlock;
+ } elsif (/^==\d+==\s+\d+bytes.*lost in loss record/) {
+ startBlock;
+ } elsif ($block) {
+ addToBlock;
+ } else {
+ print;
+ }
+}
+endBlock;
More information about the bind10-changes
mailing list