]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Factor out script to handle system test core dumps
authorTom Krizek <tkrizek@isc.org>
Tue, 20 Dec 2022 14:09:48 +0000 (15:09 +0100)
committerTom Krizek <tkrizek@isc.org>
Fri, 13 Jan 2023 16:01:30 +0000 (17:01 +0100)
Move the core dump detection functionality for system test runs into a
separate script. This enables reuse by the pytest runner. The
functionality remains the same.

bin/tests/system/get_core_dumps.sh [new file with mode: 0755]
bin/tests/system/run.sh.in

diff --git a/bin/tests/system/get_core_dumps.sh b/bin/tests/system/get_core_dumps.sh
new file mode 100755 (executable)
index 0000000..5d0255a
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+dir=$(dirname "$0")
+. "$dir/conf.sh"
+
+systest=$1
+status=0
+
+export SYSTESTDIR="${TOP_SRCDIR}/bin/tests/system/${systest}"
+
+get_core_dumps() {
+    find "$SYSTESTDIR/" \( -name 'core' -or -name 'core.*' -or -name '*.core' \) ! -name '*.gz' ! -name '*.txt' | sort
+}
+
+core_dumps=$(get_core_dumps | tr '\n' ' ')
+assertion_failures=$(find "$SYSTESTDIR/" -name named.run -exec grep "assertion failure" {} + | wc -l)
+sanitizer_summaries=$(find "$SYSTESTDIR/" -name 'tsan.*' | wc -l)
+if [ -n "$core_dumps" ]; then
+    status=1
+    echoinfo "I:$systest:Core dump(s) found: $core_dumps"
+    get_core_dumps | while read -r coredump; do
+        echoinfo "D:$systest:backtrace from $coredump:"
+        echoinfo "D:$systest:--------------------------------------------------------------------------------"
+        binary=$(gdb --batch --core="$coredump" 2>/dev/null | sed -ne "s|Core was generated by \`\([^' ]*\)[' ].*|\1|p")
+        if [ ! -f "${binary}" ]; then
+            binary=$(find "${TOP_BUILDDIR}" -path "*/.libs/${binary}" -type f)
+        fi
+        "${TOP_BUILDDIR}/libtool" --mode=execute gdb \
+                                  -batch \
+                                  -ex bt \
+                                  -core="$coredump" \
+                                  -- \
+                                  "$binary" 2>/dev/null | sed -n '/^Core was generated by/,$p' | cat_d
+        echoinfo "D:$systest:--------------------------------------------------------------------------------"
+        coredump_backtrace="${coredump}-backtrace.txt"
+        echoinfo "D:$systest:full backtrace from $coredump saved in $coredump_backtrace"
+        "${TOP_BUILDDIR}/libtool" --mode=execute gdb \
+                                  -batch \
+                                  -command=run.gdb \
+                                  -core="$coredump" \
+                                  -- \
+                                  "$binary" > "$coredump_backtrace" 2>&1
+        echoinfo "D:$systest:core dump $coredump archived as $coredump.gz"
+        gzip -1 "${coredump}"
+    done
+elif [ "$assertion_failures" -ne 0 ]; then
+    status=1
+    echoinfo "I:$systest:$assertion_failures assertion failure(s) found"
+    find "$SYSTESTDIR/" -name 'tsan.*' -exec grep "SUMMARY: " {} + | sort -u | cat_d
+elif [ "$sanitizer_summaries" -ne 0 ]; then
+    status=1
+    echoinfo "I:$systest:$sanitizer_summaries sanitizer report(s) found"
+fi
+
+exit $status
index 212e9ee4f13e12fda3f981aa4d1485d2107ff4ca..d06f587732c505fd364534e4628245bd0b3ae370 100644 (file)
@@ -113,7 +113,7 @@ if [ "${srcdir}" != "${builddir}" ]; then
         cp -a "${srcdir}/common" "${builddir}"
     fi
     # Some tests require additional files to work for out-of-tree test runs.
-    for file in ckdnsrps.sh conftest.py digcomp.pl ditch.pl fromhex.pl kasp.sh packet.pl pytest_custom_markers.py start.pl stop.pl testcrypto.sh; do
+    for file in ckdnsrps.sh conftest.py digcomp.pl ditch.pl fromhex.pl get_core_dumps.sh kasp.sh packet.pl pytest_custom_markers.py start.pl stop.pl testcrypto.sh; do
         if [ ! -r "${file}" ]; then
             cp -a "${srcdir}/${file}" "${builddir}"
         fi
@@ -265,51 +265,7 @@ else
     exit $status
 fi
 
-get_core_dumps() {
-    find "$systest/" \( -name 'core' -or -name 'core.*' -or -name '*.core' \) ! -name '*.gz' ! -name '*.txt' | sort
-}
-
-core_dumps=$(get_core_dumps | tr '\n' ' ')
-assertion_failures=$(find "$systest/" -name named.run -exec grep "assertion failure" {} + | wc -l)
-sanitizer_summaries=$(find "$systest/" -name 'tsan.*' | wc -l)
-if [ -n "$core_dumps" ]; then
-    status=1
-    echoinfo "I:$systest:Core dump(s) found: $core_dumps"
-    get_core_dumps | while read -r coredump; do
-        export SYSTESTDIR="$systest"
-        echoinfo "D:$systest:backtrace from $coredump:"
-        echoinfo "D:$systest:--------------------------------------------------------------------------------"
-        binary=$(gdb --batch --core="$coredump" 2>/dev/null | sed -ne "s|Core was generated by \`\([^' ]*\)[' ].*|\1|p")
-        if [ ! -f "${binary}" ]; then
-            binary=$(find "${top_builddir}" -path "*/.libs/${binary}" -type f)
-        fi
-        "${top_builddir}/libtool" --mode=execute gdb \
-                                  -batch \
-                                  -ex bt \
-                                  -core="$coredump" \
-                                  -- \
-                                  "$binary" 2>/dev/null | sed -n '/^Core was generated by/,$p' | cat_d
-        echoinfo "D:$systest:--------------------------------------------------------------------------------"
-        coredump_backtrace="${coredump}-backtrace.txt"
-        echoinfo "D:$systest:full backtrace from $coredump saved in $coredump_backtrace"
-        "${top_builddir}/libtool" --mode=execute gdb \
-                                  -batch \
-                                  -command=run.gdb \
-                                  -core="$coredump" \
-                                  -- \
-                                  "$binary" > "$coredump_backtrace" 2>&1
-        echoinfo "D:$systest:core dump $coredump archived as $coredump.gz"
-        gzip -1 "${coredump}"
-    done
-elif [ "$assertion_failures" -ne 0 ]; then
-    status=1
-    SYSTESTDIR="$systest"
-    echoinfo "I:$systest:$assertion_failures assertion failure(s) found"
-    find "$systest/" -name 'tsan.*' -exec grep "SUMMARY: " {} + | sort -u | cat_d
-elif [ "$sanitizer_summaries" -ne 0 ]; then
-    status=1
-    echoinfo "I:$systest:$sanitizer_summaries sanitizer report(s) found"
-fi
+$SHELL get_core_dumps.sh "$systest" || status=1
 
 print_outstanding_files() {
     if test -d ${srcdir}/../../../.git; then