mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
test: add watchdog to catch runaway tests
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
d70e2f1ed0
commit
98bbf4a1e5
1 file changed
+20
@@ -208,10 +208,27 @@ retry()
|
|||||||
return "$__retry_cmd_exit"
|
return "$__retry_cmd_exit"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wdstart()
|
||||||
|
{
|
||||||
|
(
|
||||||
|
sleep "$1"
|
||||||
|
if ps -p "$finit_pid" > /dev/null; then
|
||||||
|
kill -9 "$finit_pid" 2>/dev/null
|
||||||
|
fi
|
||||||
|
) &
|
||||||
|
wdpid=$!
|
||||||
|
}
|
||||||
|
|
||||||
|
wdkill()
|
||||||
|
{
|
||||||
|
kill -KILL $wdpid
|
||||||
|
}
|
||||||
|
|
||||||
teardown()
|
teardown()
|
||||||
{
|
{
|
||||||
test_status="$?"
|
test_status="$?"
|
||||||
|
|
||||||
|
wdkill
|
||||||
if type test_teardown > /dev/null 2>&1 ; then
|
if type test_teardown > /dev/null 2>&1 ; then
|
||||||
test_teardown
|
test_teardown
|
||||||
fi
|
fi
|
||||||
@@ -247,6 +264,8 @@ trap teardown EXIT
|
|||||||
SYSROOT="${SYSROOT:-$(pwd)/${TEST_DIR}/sysroot}"
|
SYSROOT="${SYSROOT:-$(pwd)/${TEST_DIR}/sysroot}"
|
||||||
export SYSROOT
|
export SYSROOT
|
||||||
|
|
||||||
|
TEST_TIMEOUT=300
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
. "$SYSROOT/../test.env"
|
. "$SYSROOT/../test.env"
|
||||||
|
|
||||||
@@ -299,3 +318,4 @@ set -u
|
|||||||
if type test_setup > /dev/null 2>&1 ; then
|
if type test_setup > /dev/null 2>&1 ; then
|
||||||
test_setup
|
test_setup
|
||||||
fi
|
fi
|
||||||
|
wdstart $TEST_TIMEOUT
|
||||||
Reference in new issue
Block a user