]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Skip the unit tests when kyua is not available
authorOndřej Surý <ondrej@isc.org>
Wed, 17 Jun 2020 10:17:51 +0000 (12:17 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 17 Jun 2020 13:31:44 +0000 (15:31 +0200)
The unittest.sh script tried to execute the unit tests when cmocka
development libraries was available, but kyua, the execution engine,
was not.  Now, both need to be installed in the system.

(cherry picked from commit 762a3c866e61428ae2772440889db67ac7429d3d)

configure
configure.ac
unit/unittest.sh.in

index 9c8ef4f508dd43f94950e556f505f3845dd175ff..887787faefb3070de200b8bfc90e23ef35e3424d 100755 (executable)
--- a/configure
+++ b/configure
@@ -678,8 +678,8 @@ BIND9_ISCCC_BUILDINCLUDE
 BIND9_ISC_BUILDINCLUDE
 BIND9_TOP_BUILDDIR
 LD_WRAP_TESTS
-KYUA
 UNITTESTS
+KYUA
 CMOCKA_LIBS
 CMOCKA_CFLAGS
 LIBIDN2_LIBS
@@ -23767,7 +23767,6 @@ $as_echo "yes" >&6; }
 $as_echo "#define HAVE_CMOCKA 1" >>confdefs.h
 
 fi
-            UNITTESTS=tests
              ;; #(
   *) :
 
@@ -23849,7 +23848,6 @@ if test "$ac_res" != no; then :
 
                               CMOCKA_CFLAGS="-Iwith_cmocka/include"
                               CMOCKA_LIBS="-L$with_cmocka/lib -lcmocka"
-                               UNITTESTS=tests
 
 $as_echo "#define HAVE_CMOCKA 1" >>confdefs.h
 
@@ -23865,7 +23863,6 @@ esac
 
 
 
-
 #
 # Check for kyua execution engine if CMocka was requested
 # and bail out if execution engine was not found
@@ -23920,6 +23917,8 @@ done
        if test -z "$KYUA"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: kyua test execution engine not found" >&5
 $as_echo "$as_me: WARNING: kyua test execution engine not found" >&2;}
+else
+  UNITTESTS=tests
 fi
 fi
 
index 1905d88f7995b4e948be8f0bac40387dcfd8d968..33bd76ac3bad52a9f91a72446eaab4049051e954 100644 (file)
@@ -4797,7 +4797,6 @@ AS_CASE([$with_cmocka],
        [yes],[
             PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.0.0],
                              [AC_DEFINE([HAVE_CMOCKA], [1], [Use cmocka])])
-            UNITTESTS=tests
             ],
        [*],[
            save_CFLAGS="$CFLAGS"
@@ -4816,14 +4815,12 @@ AS_CASE([$with_cmocka],
                           [
                               CMOCKA_CFLAGS="-Iwith_cmocka/include"
                               CMOCKA_LIBS="-L$with_cmocka/lib -lcmocka"
-                               UNITTESTS=tests
                               AC_DEFINE([HAVE_CMOCKA], [1], [Use cmocka])
                           ],
                           [AC_MSG_ERROR([cmocka unit testing framework not found in $with_cmocka path])])
            ])
 AC_SUBST([CMOCKA_CFLAGS])
 AC_SUBST([CMOCKA_LIBS])
-AC_SUBST(UNITTESTS)
 
 #
 # Check for kyua execution engine if CMocka was requested
@@ -4833,9 +4830,10 @@ AC_ARG_VAR([KYUA], [path to kyua execution engine])
 AS_IF([test "$with_cmocka" != "no"],
       [AC_PATH_PROGS([KYUA], [kyua], [])
        AS_IF([test -z "$KYUA"],
-            [AC_MSG_WARN([kyua test execution engine not found])])])
-
+             [AC_MSG_WARN([kyua test execution engine not found])],
+             [UNITTESTS=tests])])
 AC_SUBST([KYUA])
+AC_SUBST([UNITTESTS])
 
 #
 # Check for -Wl,--wrap= support
index 656b4612313741ceccbee443fcc8e113b7775871..35df57774c639c7999616cf5839c84e7ab25c3ec 100755 (executable)
@@ -3,7 +3,6 @@
 # Find the top of the BIND9 tree.
 export TOP=@abs_top_builddir@
 KYUA=@KYUA@
-UNITTESTS=@UNITTESTS@
 CMOCKA_MESSAGE_OUTPUT=TAP
 export CMOCKA_MESSAGE_OUTPUT
 GDB="$(command -v gdb)"
@@ -20,66 +19,67 @@ clear_kyua_work_dir() {
        fi
 }
 
-status=0
-if [ -n "${UNITTESTS}" ] && [ -f Kyuafile ]
-then
-       echo "S:unit:$(date)"
-       echo "T:unit:1:A"
-       echo "I:unit tests (using kyua)"
+if [ -z "${KYUA}" ]; then
+       exit 0
+fi
 
-       ${KYUA} -v parallelism="${TEST_PARALLEL_JOBS:-1}" --logfile kyua.log --loglevel debug test --results-file "${KYUA_RESULT:-NEW}"
-       status=$?
+echo "S:unit:$(date)"
+echo "T:unit:1:A"
+echo "I:unit tests (using kyua)"
 
-       kyua_report
+${KYUA} -v parallelism="${TEST_PARALLEL_JOBS:-1}" --logfile kyua.log --loglevel debug test --results-file "${KYUA_RESULT:-NEW}"
+status=$?
 
-       clear_kyua_work_dir kyua.log
+kyua_report
 
-       # Use kyua-debug(1) facility to gather additional data on failed tests.
-       # Some runs will just show verbose information from the run, some will
-       # show backtrace via gdb(1).
-       USER_ID=$(id -u)
-       BROKEN_TESTS=$(kyua_report | awk '$2 == "->" && ( $3 == "broken:" || $3 == "failed:" ) { print $1 }')
-       # Conditions for getting kyua debug info and GDB backtrace: runs under CI
-       # (safety), GDB present, root privileges, failed tests.
-       if [ -n "${CI}" ] && [ -n "${GDB}" ] && [ "${USER_ID:-1}" -eq 0 ] && [ -n "${BROKEN_TESTS}" ]; then
-               if [ "$(uname -s)" = "Linux" ] && ! sysctl -n "kernel.core_pattern" | grep -xq "core.%p"; then
-                       echo "I:*** kernel.core_pattern is not set to 'core.%p'"
-                       echo "I:*** kyua may not be able to find core dumps for broken tests"
-               fi
-               if [ "$(uname -s)" = "FreeBSD" ] && ! sysctl -n "kern.corefile" | grep -xq "core.%P"; then
-                       echo "I:*** kern.corefile is not set to 'core.%P'"
-                       echo "I:*** kyua may not be able to find core dumps for broken tests"
-               fi
-               if grep '^#define USE_LIBTOOL 1$' "${TOP}/config.h" >/dev/null; then
-                       # kyua debug command misidentifies broken binaries when libtool
-                       # is used (see https://github.com/jmmv/kyua/issues/207).
-                       # Here we try to "trick" kyua to use our custom gdb script instead
-                       # of using gdb(1) directly. Hence this part needs to be run as root
-                       # and, for safety reasons, only in the CI.
-                       mv "${GDB}" "${GDB}.orig"
-                       cp "${TOP}/unit/gdb" "${GDB}"
-               fi
-               i=1
-               for test in ${BROKEN_TESTS}; do
-                       echo
-                       echo "----- $test -----"
-                       KYUA_DEBUG_LOG="kyua.debug.log.${i}"
-                       ${KYUA} debug "${test}" 2>&1 | tee "${KYUA_DEBUG_LOG}"
-                       clear_kyua_work_dir "${KYUA_DEBUG_LOG}"
-                       i=$((i + 1))
-               done
-               if grep '^#define USE_LIBTOOL 1$' "${TOP}/config.h" >/dev/null; then
-                       mv "${GDB}.orig" "${GDB}"
-               fi
-       fi
+clear_kyua_work_dir kyua.log
 
-       if [ "${status}" -eq 0 ]
-       then
-               rm -f kyua.log
-               echo "R:PASS"
-       else
-               echo "R:FAIL:status:${status}"
+# Use kyua-debug(1) facility to gather additional data on failed tests.
+# Some runs will just show verbose information from the run, some will
+# show backtrace via gdb(1).
+USER_ID=$(id -u)
+BROKEN_TESTS=$(kyua_report | awk '$2 == "->" && ( $3 == "broken:" || $3 == "failed:" ) { print $1 }')
+# Conditions for getting kyua debug info and GDB backtrace: runs under CI
+# (safety), GDB present, root privileges, failed tests.
+if [ -n "${CI}" ] && [ -n "${GDB}" ] && [ "${USER_ID:-1}" -eq 0 ] && [ -n "${BROKEN_TESTS}" ]; then
+       if [ "$(uname -s)" = "Linux" ] && ! sysctl -n "kernel.core_pattern" | grep -xq "core.%p"; then
+               echo "I:*** kernel.core_pattern is not set to 'core.%p'"
+               echo "I:*** kyua may not be able to find core dumps for broken tests"
+       fi
+       if [ "$(uname -s)" = "FreeBSD" ] && ! sysctl -n "kern.corefile" | grep -xq "core.%P"; then
+               echo "I:*** kern.corefile is not set to 'core.%P'"
+               echo "I:*** kyua may not be able to find core dumps for broken tests"
+       fi
+       if grep '^#define USE_LIBTOOL 1$' "${TOP}/config.h" >/dev/null; then
+               # kyua debug command misidentifies broken binaries when libtool
+               # is used (see https://github.com/jmmv/kyua/issues/207).
+               # Here we try to "trick" kyua to use our custom gdb script instead
+               # of using gdb(1) directly. Hence this part needs to be run as root
+               # and, for safety reasons, only in the CI.
+               mv "${GDB}" "${GDB}.orig"
+               cp "${TOP}/unit/gdb" "${GDB}"
+       fi
+       i=1
+       for test in ${BROKEN_TESTS}; do
+               echo
+               echo "----- $test -----"
+               KYUA_DEBUG_LOG="kyua.debug.log.${i}"
+               ${KYUA} debug "${test}" 2>&1 | tee "${KYUA_DEBUG_LOG}"
+               clear_kyua_work_dir "${KYUA_DEBUG_LOG}"
+               i=$((i + 1))
+       done
+       if grep '^#define USE_LIBTOOL 1$' "${TOP}/config.h" >/dev/null; then
+               mv "${GDB}.orig" "${GDB}"
        fi
-       echo "E:unit:$(date)"
 fi
+
+if [ "${status}" -eq 0 ]
+then
+       rm -f kyua.log
+       echo "R:PASS"
+else
+       echo "R:FAIL:status:${status}"
+fi
+echo "E:unit:$(date)"
+
 exit ${status}