"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/unit/unittest.sh.in" (7 Sep 2020, 2743 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "unittest.sh.in": 9.16.4_vs_9.16.5.

    1 #!/bin/sh
    2 
    3 # Find the top of the BIND9 tree.
    4 export TOP=@abs_top_builddir@
    5 KYUA=@KYUA@
    6 CMOCKA_MESSAGE_OUTPUT=TAP
    7 export CMOCKA_MESSAGE_OUTPUT
    8 GDB="$(command -v gdb)"
    9 
   10 kyua_report() {
   11     ${KYUA} --logfile /dev/null report --results-file "${KYUA_RESULT:-LATEST}"
   12 }
   13 
   14 clear_kyua_work_dir() {
   15     KYUA_WORK_DIR="$(grep -i -m1 "failed" "${1}" | sed -n 's|.*\(/tmp/kyua\.[A-Za-z0-9]*\).*|\1|p')"
   16     if [ -n "${CI}" ] && [ -d "${KYUA_WORK_DIR}" ]; then
   17         find "${KYUA_WORK_DIR}" \( -name 'core*' -o -name '*.core' \) -exec mv -v {} . \;
   18         rm -rf "${KYUA_WORK_DIR}"
   19     fi
   20 }
   21 
   22 if [ -z "${KYUA}" ]; then
   23     exit 0
   24 fi
   25 
   26 echo "S:unit:$(date)"
   27 echo "T:unit:1:A"
   28 echo "I:unit tests (using kyua)"
   29 
   30 ${KYUA} -v parallelism="${TEST_PARALLEL_JOBS:-1}" --logfile kyua.log --loglevel debug test --results-file "${KYUA_RESULT:-NEW}"
   31 status=$?
   32 
   33 kyua_report
   34 
   35 clear_kyua_work_dir kyua.log
   36 
   37 # Use kyua-debug(1) facility to gather additional data on failed tests.
   38 # Some runs will just show verbose information from the run, some will
   39 # show backtrace via gdb(1).
   40 USER_ID=$(id -u)
   41 BROKEN_TESTS=$(kyua_report | awk '$2 == "->" && ( $3 == "broken:" || $3 == "failed:" ) { print $1 }')
   42 # Conditions for getting kyua debug info and GDB backtrace: runs under CI
   43 # (safety), GDB present, root privileges, failed tests.
   44 if [ -n "${CI}" ] && [ -n "${GDB}" ] && [ "${USER_ID:-1}" -eq 0 ] && [ -n "${BROKEN_TESTS}" ]; then
   45     if [ "$(uname -s)" = "Linux" ] && ! sysctl -n "kernel.core_pattern" | grep -xq "core.%p"; then
   46         echo "I:*** kernel.core_pattern is not set to 'core.%p'"
   47         echo "I:*** kyua may not be able to find core dumps for broken tests"
   48     fi
   49     if [ "$(uname -s)" = "FreeBSD" ] && ! sysctl -n "kern.corefile" | grep -xq "core.%P"; then
   50         echo "I:*** kern.corefile is not set to 'core.%P'"
   51         echo "I:*** kyua may not be able to find core dumps for broken tests"
   52     fi
   53     if grep '^#define USE_LIBTOOL 1$' "${TOP}/config.h" >/dev/null; then
   54         # kyua debug command misidentifies broken binaries when libtool
   55         # is used (see https://github.com/jmmv/kyua/issues/207).
   56         # Here we try to "trick" kyua to use our custom gdb script instead
   57         # of using gdb(1) directly. Hence this part needs to be run as root
   58         # and, for safety reasons, only in the CI.
   59         mv "${GDB}" "${GDB}.orig"
   60         cp "${TOP}/unit/gdb" "${GDB}"
   61     fi
   62     i=1
   63     for test in ${BROKEN_TESTS}; do
   64         echo
   65         echo "----- $test -----"
   66         KYUA_DEBUG_LOG="kyua.debug.log.${i}"
   67         ${KYUA} debug "${test}" 2>&1 | tee "${KYUA_DEBUG_LOG}"
   68         clear_kyua_work_dir "${KYUA_DEBUG_LOG}"
   69         i=$((i + 1))
   70     done
   71     if grep '^#define USE_LIBTOOL 1$' "${TOP}/config.h" >/dev/null; then
   72         mv "${GDB}.orig" "${GDB}"
   73     fi
   74 fi
   75 
   76 if [ "${status}" -eq 0 ]
   77 then
   78     rm -f kyua.log
   79     echo "R:PASS"
   80 else
   81     echo "R:FAIL:status:${status}"
   82 fi
   83 echo "E:unit:$(date)"
   84 
   85 exit ${status}