From fdd1199cb13ae11565263b138d43df3dd182de72 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 2 Feb 2018 09:45:13 +0000 Subject: [PATCH] - unit test with valgrind git-svn-id: file:///svn/unbound/trunk@4493 be551aaa-1e26-0410-a405-d3ace91eadb9 --- testcode/testbound.c | 4 +++ testdata/03-testbound.tdir/03-testbound.test | 27 +++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/testcode/testbound.c b/testcode/testbound.c index c9880cdd3..56b89c7f0 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -354,6 +354,10 @@ main(int argc, char* argv[]) case 's': free(pass_argv[1]); testbound_selftest(); + checklock_stop(); + if(log_get_lock()) { + lock_quick_destroy((lock_quick_type*)log_get_lock()); + } exit(0); case '1': #ifdef USE_SHA1 diff --git a/testdata/03-testbound.tdir/03-testbound.test b/testdata/03-testbound.tdir/03-testbound.test index e23151c41..1998be13e 100644 --- a/testdata/03-testbound.tdir/03-testbound.test +++ b/testdata/03-testbound.tdir/03-testbound.test @@ -12,6 +12,7 @@ exitval=0 # quiet="" to make verbose do_valgrind=no +VALGRIND_FLAGS="--leak-check=full --show-leak-kinds=all" # valgrind mode for debug #if grep "staticexe=-static" $PRE/Makefile >/dev/null 2>&1; then # if test -x "`which valgrind`"; then @@ -21,19 +22,28 @@ do_valgrind=no # self-test (unit test of testbound) if test $do_valgrind = "yes"; then - if (valgrind $PRE/testbound -s >tmpout 2>&1;); then + if (valgrind $VALGRIND_FLAGS $PRE/testbound -s >tmpout 2>&1;); then echo "selftest OK " else echo "selftest FAILED" exit 1 fi - if grep "All heap blocks were freed -- no leaks are possible." tmpout >/dev/null 2>&1; then + if grep "All heap blocks were freed -- no leaks are possible" tmpout >/dev/null 2>&1; then : # clean else + cat tmpout echo "Memory leaked in selftest" grep "in use at exit" tmpout exit 1 fi + if grep "ERROR SUMMARY: 0 errors from 0 contexts" tmpout >/dev/null 2>&1; then + : # clean + else + cat tmpout + echo "Errors in selftest" + grep "ERROR SUMMARY" tmpout + exit 1 + fi else if ($PRE/testbound -s >/dev/null 2>&1;); then echo "selftest OK " @@ -88,19 +98,28 @@ for input in $PRE/testdata/*.rpl $PRE/testdata/*.crpl; do fi if test $do_valgrind = "yes"; then - if (valgrind $PRE/testbound -p $input >tmpout 2>&1;); then + if (valgrind $VALGRIND_FLAGS $PRE/testbound -p $input >tmpout 2>&1;); then echo " OK $cleaninput: $header" else echo "FAILED $cleaninput: $header" exitval=1 fi - if grep "All heap blocks were freed -- no leaks are possible." tmpout >/dev/null 2>&1; then + if grep "All heap blocks were freed -- no leaks are possible" tmpout >/dev/null 2>&1; then : # clean else + cat tmpout echo "Memory leaked in $cleaninput" grep "in use at exit" tmpout exitval=1 fi + if grep "ERROR SUMMARY: 0 errors from 0 contexts" tmpout >/dev/null 2>&1; then + : # clean + else + grep "^==" tmpout + echo "Errors in $cleaninput" + grep "ERROR SUMMARY" tmpout + exitval=1 + fi else # do valgrind=no if ($PRE/testbound -p $input >/dev/null 2>&1;); then -- 2.47.3