Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharness: add a per-test global timeout option #2833

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions t/sharness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,27 @@ test_pause() {
fi
}

die_on_alarm() {
kill -9 $! > /dev/null 2>&1 # kill currently executing command
echo "Top-level test timed out"
}

test_eval_() {
( # start a subshell in the background to provide a timeout
set -e
parent_pid=$$
i=0
while kill -0 $parent_pid ; do
sleep 1
if test "$i" -gt ${FLUX_TEST_TIMEOUT:-120} ; then
break
fi
i=$(($i+1))
done
kill -ALRM $$ # send ALRM to parent
) &
ALRM=$!
trap die_on_alarm ALRM
# This is a separate function because some tests use
# "return" to end a test_expect_success block early.
case ",$test_prereq," in
Expand All @@ -336,6 +356,10 @@ test_eval_() {
eval </dev/null >&3 2>&4 "$*"
;;
esac
ret=$?
trap - ALRM
kill $ALRM >/dev/null 2>&1
return $ret
}

test_run_() {
Expand Down