From ff2a923942bad8d193d32a985e46a1ed13d392b4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 21 Aug 2021 08:36:40 +0200 Subject: -fix trap logic --- src/cli/test_iban.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/cli/test_iban.sh b/src/cli/test_iban.sh index a7695e5..d5bceda 100755 --- a/src/cli/test_iban.sh +++ b/src/cli/test_iban.sh @@ -2,6 +2,31 @@ set -eu +# Exit, with status code "skip" (no 'real' failure) +function exit_skip() { + echo " SKIP: $1" + exit 77 +} + +# Exit, with error message (hard failure) +function exit_fail() { + echo " FAIL: $1" + exit 1 +} + +# Cleanup to run whenever we exit +function cleanup() +{ + for n in `jobs -p` + do + kill $n 2> /dev/null || true + done + wait +} + +# Install cleanup handler (except for kill -9) +trap cleanup EXIT + # Script's guidelines: #* uses 'CURRENCY=TESTKUDOS' and uses $CURRENCY for all @@ -86,8 +111,6 @@ echo "Sandbox started." #libeufin-sandbox serve &> sandbox.log & #sandbox_pid=$! # -# FIXME: not always both services get killed. -trap "echo Terminating services.; kill $nexus_pid; kill $sandbox_pid" EXIT # #curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null #curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null -- cgit v1.2.3