From 32617893c9b9176048f80c04dbd14ef1d245d777 Mon Sep 17 00:00:00 2001 From: Wojciech Sipak Date: Mon, 2 Dec 2024 15:15:28 +0100 Subject: [PATCH] kill openocd and gdb after simulation is done --- .github/scripts/gdb_test.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/scripts/gdb_test.sh b/.github/scripts/gdb_test.sh index 908bfffccb7..c74e87b2ffc 100755 --- a/.github/scripts/gdb_test.sh +++ b/.github/scripts/gdb_test.sh @@ -75,8 +75,11 @@ echo -e "Simulation running and ready (pid=${SIM_PID})" # Launch OpenOCD echo -e "Launching OpenOCD..." -cd ${RV_ROOT}/.github/scripts/openocd && openocd -d2 --file board/caliptra-verilator.cfg >"${OPENOCD_LOG}" 2>&1 & +WORKDIR=$PWD +cd ${RV_ROOT}/.github/scripts/openocd +openocd -d2 --file board/caliptra-verilator.cfg > ${OPENOCD_LOG} 2>&1 & OPENOCD_PID=$! +cd $WORKDIR # Wait wait_for_phrase "${OPENOCD_LOG}" "Listening on port 3333 for gdb connections" @@ -93,23 +96,16 @@ sleep 1s # Run the test echo -e "${COLOR_WHITE}======== Running test '$@' ========${COLOR_OFF}" -bash -c "$(printf ' %q' "$@")" -EXITCODE=$? +bash -c "$(printf ' %q' "$@")" > test.log 2>&1 & +TEST_PID=$! -if [ ${EXITCODE} -eq 0 ]; then - echo -e "${COLOR_GREEN}[PASSED]${COLOR_OFF}" -else - echo -e "${COLOR_RED}[FAILED]${COLOR_OFF}" -fi - -sleep 1s +# The simulation must end naturally in order to produce coverage data. +wait ${SIM_PID} -# Terminate -echo -e "${COLOR_WHITE}Terminating...${COLOR_OFF}" -terminate_all +# OpenOCD waits endlessly for the target (Vtb_top) to reconnect. +# Kill OpenoCD and GDB in case they're stuck +kill -s SIGKILL ${OPENOCD_PID} || true +kill -s SIGKILL ${TEST_PID} || true # Display logs print_logs - -# Honor the exitcode -exit ${EXITCODE}