2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Merge branch '2579-enforce-a-run-time-limit-on-unit-test-binaries' into 'main'

Enforce a run time limit on unit test binaries

Closes #2579

See merge request isc-projects/bind9!4802
This commit is contained in:
Michał Kępień
2021-04-07 09:46:40 +00:00

View File

@@ -9,9 +9,24 @@ if [ -z "${1}" ]; then
fi
TEST_PROGRAM="${1}"
TIMEOUT=300
"${TEST_PROGRAM}"
STATUS=${?}
"${TEST_PROGRAM}" &
TEST_PROGRAM_PID=${!}
STATUS=124
while [ ${TIMEOUT} -gt 0 ]; do
if ! kill -0 "${TEST_PROGRAM_PID}" 2>/dev/null; then
wait "${TEST_PROGRAM_PID}"
STATUS=${?}
break
fi
sleep 1
TIMEOUT=$((TIMEOUT - 1))
done
if [ ${TIMEOUT} -eq 0 ]; then
echo "PID ${TEST_PROGRAM_PID} exceeded run time limit, sending SIGKILL" >&2
kill -KILL "${TEST_PROGRAM_PID}" 2>/dev/null
fi
TEST_PROGRAM_NAME=$(basename "${TEST_PROGRAM}")
TEST_PROGRAM_WORK_DIR=$(dirname "${TEST_PROGRAM}")