From: Michael Chase-S. <mc...@us...> - 2013-04-16 22:33:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "sfcb - Small Footprint CIM Broker". The branch, master has been updated via b8c8845469d2159bdf30b986ada1b46d4a418e54 (commit) from 0401ce8a163b3ccc2f398237da70cbdfaf02c9be (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 b8c8845469d2159bdf30b986ada1b46d4a418e54 Author: Michael Chase-Salerno <br...@li...> Date: Tue Apr 16 18:31:55 2013 -0400 [sfcb-tix:#40] Add valgrind test implemented only for the "none" init script at this time ----------------------------------------------------------------------- Summary of changes: Makefile.am | 4 ++- configure.ac | 14 +++++++++++++ sfcb.init-none.in | 10 ++++---- test/finaltest/Makefile.am | 5 ++++ test/finaltest/parseVG.pl | 45 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 63bcaba..044a7b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -460,7 +460,9 @@ endif sfcb: sfcb.$(INIT_STYLE) sblim-sfcb.service sed -e s?$$\{prefix\}?$(prefix)?g \ - -e s?$$\{exec_prefix\}?$(prefix)?g $< > $@ + -e s?$$\{exec_prefix\}?$(prefix)?g \ + -e s?KILLEXEC?"$(KILLEXEC)"?g \ + -e s?PROFILER?"$(PROFILER)"?g $< > $@ sblim-sfcb.service: sblim-sfcb.service.pre sed -e s?$$\{exec_prefix\}?$(prefix)?g $< > $@ diff --git a/configure.ac b/configure.ac index 692d9ef..bd07712 100644 --- a/configure.ac +++ b/configure.ac @@ -229,6 +229,8 @@ do test_cimrs=yes;; commands|command|cmd|cmds) test_cmd=yes;; + valgrind) + test_valgrind=yes;; slp) if test "$enable_slp" == "yes"; then test_slp=yes @@ -256,6 +258,8 @@ AM_CONDITIONAL(CMDTEST,[test "$test_cmd" == "yes"]) AM_CONDITIONAL(SLPTEST,[test "$test_slp" == "yes"]) AM_CONDITIONAL(PROVTEST,[test "$test_providers" == "yes"]) AM_CONDITIONAL(PROVTEST,[test "$test_local" == "yes"]) +AM_CONDITIONAL(VALGRIND,[test "$test_valgrind"]) + if [test "$enable_tests"]; then # The order of TEST_SUBDIRS determines test # execution order. @@ -309,8 +313,18 @@ if [test "$enable_tests"]; then AC_CONFIG_FILES([test/localtests/Makefile]) fi + if [test "$test_valgrind" == "yes"]; then + PROFILER="$PROFILER valgrind --leak-check=full --xml=yes --xml-file=/tmp/sfcb-vgout.xml --child-silent-after-fork=yes" + AC_SUBST(PROFILER) + KILLEXEC="-r memcheck.*" + AC_SUBST(KILLEXEC) + fi + TEST_SUBDIRS="$TEST_SUBDIRS finaltest" AC_SUBST(TEST_SUBDIRS) +else + KILLEXEC="sfcbd" + AC_SUBST(KILLEXEC) fi if [test "$test_gcov" == "yes"]; then diff --git a/sfcb.init-none.in b/sfcb.init-none.in index 8499c87..3f6cf8a 100644 --- a/sfcb.init-none.in +++ b/sfcb.init-none.in @@ -14,18 +14,18 @@ fi start() { echo -n "Starting sfcb: " - @sbindir@/sfcbd -d && echo "done." && return 0 || + PROFILER @sbindir@/sfcbd -d && echo "done." && return 0 || echo "failed." return 1 } stop() { echo -n "Shutting down sfcb: " - if killall sfcbd + if killall KILLEXEC then sleep 3 # If it hasn't died gracefully, kill it - if killall -KILL sfcbd 2>/dev/null + if killall -KILL KILLEXEC 2>/dev/null then # In this case, it needed to be killed echo "failed(killed)." @@ -44,7 +44,7 @@ stop() { reload() { echo -n "Reloading sfcb configuration: " - killall -HUP sfcbd && echo "done." && return 0 || + killall -HUP KILLEXEC && echo "done." && return 0 || echo "failed." return 1 } @@ -58,7 +58,7 @@ case "$1" in ;; status) echo -n "Checking SFCB status: " - ps --noheaders -C sfcbd || echo "stopped." + ps --noheaders -C KILLEXEC || echo "stopped." ;; restart) stop diff --git a/test/finaltest/Makefile.am b/test/finaltest/Makefile.am index 3b558ec..b8831d3 100644 --- a/test/finaltest/Makefile.am +++ b/test/finaltest/Makefile.am @@ -22,5 +22,10 @@ MAINTAINERCLEANFILES = Makefile.in +if VALGRIND +TESTS = parseVG.pl finalcheck.sh +else TESTS = finalcheck.sh +endif + diff --git a/test/finaltest/parseVG.pl b/test/finaltest/parseVG.pl new file mode 100755 index 0000000..0942265 --- /dev/null +++ b/test/finaltest/parseVG.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +use XML::Parser; +use XML::LibXML; + +my $xmlfile="/tmp/sfcb-vgoutbad.xml"; + +open XML, '<', $xmlfile or die "Can't open input file"; +my @contents = <XML>; +close XML; + +@contents = grep(!/\/valgrindoutput/,@contents); +push(@contents,"</valgrindoutput>"); + +# Slurp and parse the valgrind xml output +#$dom = XML::LibXML->load_xml(@contents); +$dom = XML::LibXML->load_xml( +# location => "/tmp/sfcb-vgout.xml" + string => join(' ',@contents) + ); +#Prep the output file +my $leakfile="./sfcbLeaks.xml"; +open(LEAKFILE,">$leakfile"); + +# Spin through the xml output looking for definite leaks +my $defCount=0; +foreach my $ele ($dom->findnodes('/valgrindoutput/error')) { + my($kind) = $ele->findnodes('./kind'); + if ($kind =~ m/Leak_DefinitelyLost/) { + print LEAKFILE "$ele\n"; + $defCount++; + } + } + +# If we had any, note it and return bad +if ($defCount) { + close(LEAKFILE); + print(" FAILED $defCount definite leaks. See $leakfile\n"); + exit($defCount); +} + +# If no leaks, cleanup +unlink($leakfile); +close(LEAKFILE); +exit(0); hooks/post-receive -- sfcb - Small Footprint CIM Broker |