From 4c24cce386d7a6be968866bfe5f9f31c86e9d110 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Wed, 3 Apr 2019 10:59:22 +0200 Subject: [PATCH 1/2] Replace tab with spaces in test.sh --- scripts/tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tests.sh b/scripts/tests.sh index 141a374fd..a2cd2d7fc 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -71,8 +71,8 @@ safe_kill() { } cleanup() { - # ensure failing commands don't cause termination during cleanup (especially within safe_kill) - set +e + # ensure failing commands don't cause termination during cleanup (especially within safe_kill) + set +e if [[ "$IPC_ENABLED" = true ]] && [[ -n "${ALETH_PID}" ]] then From 9633b285ab8c3ff5f02ebb33cae2b3924b7a4d12 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 2 Apr 2019 11:07:00 +0200 Subject: [PATCH 2/2] Log aleth output upon failure --- scripts/aleth_with_log.sh | 21 +++++++++++++++++++++ scripts/tests.sh | 19 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 scripts/aleth_with_log.sh diff --git a/scripts/aleth_with_log.sh b/scripts/aleth_with_log.sh new file mode 100755 index 000000000..e9803c846 --- /dev/null +++ b/scripts/aleth_with_log.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +ALETH_PATH=$1 +ALETH_TMP_OUT=$2 +shift +shift + + +$ALETH_PATH $@ &> >(tail -n 10000 &> "$ALETH_TMP_OUT") & + +PID=$! + +function cleanup() +{ + kill $PID +} + +trap cleanup INT TERM + +wait $PID + diff --git a/scripts/tests.sh b/scripts/tests.sh index a2cd2d7fc..3e970ee43 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -31,6 +31,8 @@ set -e REPO_ROOT="$(dirname "$0")"/.. WORKDIR=`mktemp -d` +# Will be printed in case of a test failure +ALETH_TMP_OUT=`mktemp` IPC_ENABLED=true ALETH_PID= CMDLINE_PID= @@ -85,6 +87,7 @@ cleanup() { echo "Cleaning up working directory ${WORKDIR} ..." rm -rf "$WORKDIR" || true + rm $ALETH_TMP_OUT } trap cleanup INT TERM @@ -149,7 +152,7 @@ function download_aleth() # echos the PID function run_aleth() { - $ALETH_PATH --db memorydb --test -d "${WORKDIR}" >/dev/null 2>&1 & + $REPO_ROOT/scripts/aleth_with_log.sh $ALETH_PATH $ALETH_TMP_OUT --log-verbosity 3 --db memorydb --test -d "${WORKDIR}" &> /dev/null & echo $! # Wait until the IPC endpoint is available. while [ ! -S "${WORKDIR}/geth.ipc" ] ; do sleep 1; done @@ -215,7 +218,21 @@ do fi fi + set +e "$REPO_ROOT"/build/test/soltest $progress $log -- --testpath "$REPO_ROOT"/test "$optimize" --evm-version "$vm" $SMT_FLAGS $IPC_FLAGS $force_abiv2_flag --ipcpath "${WORKDIR}/geth.ipc" + + if test "0" -ne "$?"; then + if [ -n "$log_directory" ] + then + # Need to kill aleth first so the log is written + safe_kill $ALETH_PID $ALETH_PATH + cp $ALETH_TMP_OUT $log_directory/aleth.log + printError "Some test failed, wrote aleth.log" + fi + exit 1 + fi + set -e + done done done