From bc097d33588cd1e5b27b2ba832026e23559bc2af Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Tue, 4 May 2021 12:58:23 +0200 Subject: [PATCH 1/2] Process core dump from named which failed to start When named failed to start and produced core dump, the core file wasn't processed by GDB because of run.sh script exiting immediately. This remedies the limitation, simplifies the surrounding code, and makes the script shellcheck clean. --- bin/tests/system/run.sh.in | 73 ++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/bin/tests/system/run.sh.in b/bin/tests/system/run.sh.in index 7d38c0e3e6..5caaced6b1 100644 --- a/bin/tests/system/run.sh.in +++ b/bin/tests/system/run.sh.in @@ -115,20 +115,14 @@ eval "$(cd "${srcdir}" && ./get_ports.sh -p "$baseport" -t "$systest")" restart=false -start_servers_failed() { - echoinfo "I:$systest:starting servers failed" - echofail "R:$systest:FAIL" - echoend "E:$systest:$(date_with_args)" - exit 1 -} - start_servers() { echoinfo "I:$systest:starting servers" if $restart; then - $PERL start.pl --restart --port "$PORT" "$systest" || start_servers_failed - else - restart=true - $PERL start.pl --port "$PORT" "$systest" || start_servers_failed + restart_opt="--restart" + fi + if ! $PERL start.pl ${restart_opt} --port "$PORT" "$systest"; then + echoinfo "I:$systest:starting servers failed" + return 1 fi } @@ -205,29 +199,38 @@ status=0 run=0 # Run the tests if [ -r "$systest/tests.sh" ]; then - start_servers - ( cd "$systest" && $SHELL tests.sh "$@" ) - status=$? - run=$((run+1)) - stop_servers || status=1 + if start_servers; then + ( cd "$systest" && $SHELL tests.sh "$@" ) + status=$? + run=$((run+1)) + stop_servers || status=1 + else + status=1 + fi fi -if [ -n "$PYTEST" ]; then - run=$((run+1)) - for test in $(cd "${systest}" && find . -name "tests*.py"); do - start_servers - rm -f "$systest/$test.status" - test_status=0 - (cd "$systest" && "$PYTEST" -v "$test" "$@" || echo "$?" > "$test.status") | SYSTESTDIR="$systest" cat_d - if [ -f "$systest/$test.status" ]; then - echo_i "FAILED" - test_status=$(cat "$systest/$test.status") - fi - status=$((status+test_status)) - stop_servers || status=1 - done -else - echoinfo "I:$systest:pytest not installed, skipping python tests" +if [ $status -eq 0 ]; then + if [ -n "$PYTEST" ]; then + run=$((run+1)) + for test in $(cd "${systest}" && find . -name "tests*.py"); do + if start_servers; then + rm -f "$systest/$test.status" + test_status=0 + (cd "$systest" && "$PYTEST" -v "$test" "$@" || echo "$?" > "$test.status") | SYSTESTDIR="$systest" cat_d + if [ -f "$systest/$test.status" ]; then + echo_i "FAILED" + test_status=$(cat "$systest/$test.status") + fi + status=$((status+test_status)) + stop_servers || status=1 + else + status=1 + break + fi + done + else + echoinfo "I:$systest:pytest not installed, skipping python tests" + fi fi if [ "$run" -eq "0" ]; then @@ -291,9 +294,9 @@ fi print_outstanding_files() { if test -d ${srcdir}/../../../.git; then git status -su --ignored "${systest}/" 2>/dev/null | \ - sed -n -e 's|^?? \(.*\)|I:'${systest}':file \1 not removed|p' \ - -e 's|^!! \(.*/named.run\)$|I:'${systest}':file \1 not removed|p' \ - -e 's|^!! \(.*/named.memstats\)$|I:'${systest}':file \1 not removed|p' + sed -n -e 's|^?? \(.*\)|I:'"${systest}"':file \1 not removed|p' \ + -e 's|^!! \(.*/named.run\)$|I:'"${systest}"':file \1 not removed|p' \ + -e 's|^!! \(.*/named.memstats\)$|I:'"${systest}"':file \1 not removed|p' fi } From a39697635b6963a8acfa1854d757fd6ca28e2a5c Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Tue, 11 May 2021 18:06:59 +0200 Subject: [PATCH 2/2] Fix handling of restart option in run.sh The support for stat.pl's --restart option was incomplete in run.sh. This change makes sure it's handled properly and that named.run file is not being removed by clean.sh when the --restart option is used. --- bin/tests/system/run.sh.in | 26 ++++++++++++++------------ bin/tests/system/start.pl | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/bin/tests/system/run.sh.in b/bin/tests/system/run.sh.in index 5caaced6b1..839bb34bf1 100644 --- a/bin/tests/system/run.sh.in +++ b/bin/tests/system/run.sh.in @@ -43,8 +43,9 @@ else fi do_run=false +restart=false log_flags="-r" -while getopts "sknp:r-:" OPT; do +while getopts "sknp:r-:t" OPT; do log_flags="$log_flags -$OPT$OPTARG" if [ "$OPT" = "-" ] && [ -n "$OPTARG" ]; then OPT="${OPTARG%%=*}" @@ -59,6 +60,7 @@ while getopts "sknp:r-:" OPT; do p | port) baseport=$OPTARG ;; r | run) do_run=true ;; s | skip) exit 77 ;; + t | restart) restart=true ;; -) break ;; *) echo "invalid option" >&2; exit 1 ;; esac @@ -113,8 +115,6 @@ fi # Determine which ports to use for this system test. eval "$(cd "${srcdir}" && ./get_ports.sh -p "$baseport" -t "$systest")" -restart=false - start_servers() { echoinfo "I:$systest:starting servers" if $restart; then @@ -173,14 +173,16 @@ else exit 0 fi -# Clean up files left from any potential previous runs -if test -f "$systest/clean.sh" -then - if ! ( cd "${systest}" && $SHELL clean.sh "$@" ); then - echowarn "I:$systest:clean.sh script failed" - echofail "R:$systest:FAIL" - echoend "E:$systest:$(date_with_args)" - exit 1 +# Clean up files left from any potential previous runs except when +# started with the --restart option. +if ! $restart; then + if test -f "$systest/clean.sh"; then + if ! ( cd "${systest}" && $SHELL clean.sh "$@" ); then + echowarn "I:$systest:clean.sh script failed" + echofail "R:$systest:FAIL" + echoend "E:$systest:$(date_with_args)" + exit 1 + fi fi fi @@ -313,7 +315,7 @@ if [ $status -ne 0 ]; then echofail "R:$systest:FAIL" else echopass "R:$systest:PASS" - if $clean; then + if $clean && ! $restart; then ( cd "${systest}" && $SHELL clean.sh "$@" ) if [ "${srcdir}" = "${builddir}" ]; then print_outstanding_files diff --git a/bin/tests/system/start.pl b/bin/tests/system/start.pl index 307fd25d5f..ea82e61500 100755 --- a/bin/tests/system/start.pl +++ b/bin/tests/system/start.pl @@ -344,7 +344,7 @@ sub construct_ans_command { if ($restart) { $command .= " >>ans.run 2>&1 &"; } else { - $command .= " >ans.run 2>&1 &"; + $command .= " >ans.run 2>&1 &"; } # get the shell to report the pid of the server ($!)