diff --git a/configure.ac b/configure.ac index d9a9c528f5..dd075e65f2 100644 --- a/configure.ac +++ b/configure.ac @@ -1637,6 +1637,9 @@ AC_CONFIG_FILES([lib/isc/tests/Makefile lib/isccc/tests/Makefile lib/isccfg/tests/Makefile]) +AC_CONFIG_FILES([lib/unit-test-driver.sh], + [chmod +x lib/unit-test-driver.sh]) + # System Tests AC_CONFIG_FILES([bin/tests/Makefile diff --git a/lib/.gitignore b/lib/.gitignore index 8445734faf..9c93fd5f6b 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,3 +1,4 @@ platform.h netdb.h gen +/unit-test-driver.sh diff --git a/lib/dns/tests/Makefile.am b/lib/dns/tests/Makefile.am index 0d658db251..9f3ee80cce 100644 --- a/lib/dns/tests/Makefile.am +++ b/lib/dns/tests/Makefile.am @@ -108,3 +108,5 @@ rsa_test_CPPFLAGS = \ $(OPENSSL_CFLAGS) unit-local: check + +LOG_COMPILER = $(builddir)/../../unit-test-driver.sh diff --git a/lib/irs/tests/Makefile.am b/lib/irs/tests/Makefile.am index 0246f34cc7..6b9bb583eb 100644 --- a/lib/irs/tests/Makefile.am +++ b/lib/irs/tests/Makefile.am @@ -15,3 +15,5 @@ check_PROGRAMS = \ TESTS = $(check_PROGRAMS) unit-local: check + +LOG_COMPILER = $(builddir)/../../unit-test-driver.sh diff --git a/lib/isc/tests/Makefile.am b/lib/isc/tests/Makefile.am index c7ae206d78..3723a392de 100644 --- a/lib/isc/tests/Makefile.am +++ b/lib/isc/tests/Makefile.am @@ -65,3 +65,5 @@ random_test_LDADD = \ -lm unit-local: check + +LOG_COMPILER = $(builddir)/../../unit-test-driver.sh diff --git a/lib/isccc/tests/Makefile.am b/lib/isccc/tests/Makefile.am index a0b5abd3b8..048f2a9f0f 100644 --- a/lib/isccc/tests/Makefile.am +++ b/lib/isccc/tests/Makefile.am @@ -15,3 +15,5 @@ check_PROGRAMS = \ TESTS = $(check_PROGRAMS) unit-local: check + +LOG_COMPILER = $(builddir)/../../unit-test-driver.sh diff --git a/lib/isccfg/tests/Makefile.am b/lib/isccfg/tests/Makefile.am index 42242ad070..ce4ea0fd42 100644 --- a/lib/isccfg/tests/Makefile.am +++ b/lib/isccfg/tests/Makefile.am @@ -17,3 +17,5 @@ check_PROGRAMS = \ TESTS = $(check_PROGRAMS) unit-local: check + +LOG_COMPILER = $(builddir)/../../unit-test-driver.sh diff --git a/lib/ns/tests/Makefile.am b/lib/ns/tests/Makefile.am index c7ff73cd31..415a21ee96 100644 --- a/lib/ns/tests/Makefile.am +++ b/lib/ns/tests/Makefile.am @@ -45,3 +45,5 @@ query_test_LDFLAGS = \ endif unit-local: check + +LOG_COMPILER = $(builddir)/../../unit-test-driver.sh diff --git a/lib/unit-test-driver.sh.in b/lib/unit-test-driver.sh.in new file mode 100644 index 0000000000..4fbd84b361 --- /dev/null +++ b/lib/unit-test-driver.sh.in @@ -0,0 +1,34 @@ +#!/bin/sh + +TOP_BUILDDIR=@abs_top_builddir@ +TOP_SRCDIR=@abs_top_srcdir@ + +if [ -z "${1}" ]; then + echo "Usage: ${0} test_program" >&2 + exit 1 +fi + +TEST_PROGRAM="${1}" + +"${TEST_PROGRAM}" +STATUS=${?} + +TEST_PROGRAM_NAME=$(basename "${TEST_PROGRAM}") +TEST_PROGRAM_WORK_DIR=$(dirname "${TEST_PROGRAM}") +find "${TEST_PROGRAM_WORK_DIR}" -name 'core*' -or -name '*.core' | while read -r CORE_DUMP; do + BINARY=$(gdb --batch --core="${CORE_DUMP}" 2>/dev/null | sed -n "s/^Core was generated by \`\(.*\)'\.\$/\1/p") + if ! echo "${BINARY}" | grep -q "${TEST_PROGRAM_NAME}\$"; then + continue + fi + echo "I:${TEST_PROGRAM_NAME}:Core dump found: ${CORE_DUMP}" + echo "D:${TEST_PROGRAM_NAME}:backtrace from ${CORE_DUMP} start" + "${TOP_BUILDDIR}/libtool" --mode=execute gdb \ + --batch \ + --command="${TOP_SRCDIR}/bin/tests/system/run.gdb" \ + --core="${CORE_DUMP}" \ + -- \ + "${BINARY}" + echo "D:${TEST_PROGRAM_NAME}:backtrace from ${CORE_DUMP} end" +done + +exit ${STATUS}