]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- unit test with valgrind
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 2 Feb 2018 09:45:13 +0000 (09:45 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 2 Feb 2018 09:45:13 +0000 (09:45 +0000)
git-svn-id: file:///svn/unbound/trunk@4493 be551aaa-1e26-0410-a405-d3ace91eadb9

testcode/testbound.c
testdata/03-testbound.tdir/03-testbound.test

index c9880cdd3625d8a92f047e31b969338372b2997b..56b89c7f0d7e17c18bb728449463968d26152cc1 100644 (file)
@@ -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
index e23151c416573037337f86ea29e9de11f1c97b3d..1998be13e9e753d4179b06e7c75d39350b3d7602 100644 (file)
@@ -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