]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Skip unbound-dnstap-socket unit test when not compiled with 1080/head
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Tue, 4 Jun 2024 14:59:58 +0000 (16:59 +0200)
committerYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Tue, 4 Jun 2024 14:59:58 +0000 (16:59 +0200)
  --enable-debug.

testdata/02-unittest.tdir/02-unittest.test

index e5fb0c30826e79877407017ba2ecc57989b54f03..b11ba016f2333033c635d6ecd08888b73c814e1a 100644 (file)
@@ -10,64 +10,66 @@ get_make
 (cd $PRE ; $MAKE unittest; $MAKE lock-verify; $MAKE unbound-dnstap-socket)
 
 if test -f $PRE/unbound_do_valgrind_in_test; then
-       do_valgrind=yes
+       DO_VALGRIND=yes
 else
-       do_valgrind=no
+       DO_VALGRIND=no
 fi
 VALGRIND_FLAGS="--leak-check=full --show-leak-kinds=all"
 
-## START -- Loop over unit tests
-##
-for unit_cmd in "unittest" "unbound-dnstap-socket -c"; do
-
-echo "> testing $unit_cmd"
-if test $do_valgrind = "yes"; then
-       echo "valgrind yes"
-       echo
-       tmpout=/tmp/tmpout.$$
-       if (cd $PRE; valgrind $VALGRIND_FLAGS ./$unit_cmd >$tmpout 2>&1); then
-               echo "unit test worked."
-       else
-               echo "unit test failed."
-               exit 1
-       fi
-       if grep "All heap blocks were freed -- no leaks are possible" $tmpout; then
-               :  # clean
-       else
-               cat $tmpout
-               echo "Memory leaked in unit test"
-               grep "in use at exit" $tmpout
-               exit 1
-       fi
-       if grep "ERROR SUMMARY: 0 errors from 0 contexts" $tmpout; then
-               :  # clean
-       else
-               cat $tmpout
-               echo "Errors in unit test"
-               grep "ERROR SUMMARY" $tmpout
-               exit 1
-       fi
-       rm -f $tmpout
-else
-       # without valgrind
-       if (cd $PRE; ./$unit_cmd); then
-               echo "unit test worked."
+# Run a unit test; it exits on failure
+# $1: the command to start the unit test
+run_unittest () {
+       unit_cmd=$1
+       echo "> testing $unit_cmd"
+       if test $DO_VALGRIND = "yes"; then
+               echo "valgrind yes"
+               echo
+               tmpout=/tmp/tmpout.$$
+               if (cd $PRE; valgrind $VALGRIND_FLAGS ./$unit_cmd >$tmpout 2>&1); then
+                       echo "unit test worked."
+               else
+                       echo "unit test failed."
+                       exit 1
+               fi
+               if grep "All heap blocks were freed -- no leaks are possible" $tmpout; then
+                       :  # clean
+               else
+                       cat $tmpout
+                       echo "Memory leaked in unit test"
+                       grep "in use at exit" $tmpout
+                       exit 1
+               fi
+               if grep "ERROR SUMMARY: 0 errors from 0 contexts" $tmpout; then
+                       :  # clean
+               else
+                       cat $tmpout
+                       echo "Errors in unit test"
+                       grep "ERROR SUMMARY" $tmpout
+                       exit 1
+               fi
+               rm -f $tmpout
        else
-               echo "unit test failed."
-               exit 1
+               # without valgrind
+               if (cd $PRE; ./$unit_cmd); then
+                       echo "unit test worked."
+               else
+                       echo "unit test failed."
+                       exit 1
+               fi
        fi
-fi
-if test -f $PRE/ublocktrace.0; then
-       if (cd $PRE; ./lock-verify ublocktrace.*); then
-               echo "lock-verify test worked."
-       else
-               echo "lock-verify test failed."
-               exit 1
+       if test -f $PRE/ublocktrace.0; then
+               if (cd $PRE; ./lock-verify ublocktrace.*); then
+                       echo "lock-verify test worked."
+               else
+                       echo "lock-verify test failed."
+                       exit 1
+               fi
        fi
-fi
+}
 
-done
-##
-## END -- Loop over unit tests
+run_unittest "unittest"
+if grep "define UNBOUND_DEBUG" $PRE/config.h >/dev/null;  then
+       run_unittest "unbound-dnstap-socket -c"
+fi
 
 exit 0