ci: When using restarting tests kill make with the shell

This commit is contained in:
ZyX 2017-04-24 18:27:33 +03:00
parent 8dc3eca49b
commit 26fad863ba

View File

@ -82,21 +82,27 @@ run_test_wd() {
local output_file="$(mktemp)" local output_file="$(mktemp)"
local status_file="$(mktemp)" local status_file="$(mktemp)"
local sid_file="$(mktemp)"
local restarts=5 local restarts=5
local prev_tmpsize=-1 local prev_tmpsize=-1
while test $restarts -gt 0 ; do while test $restarts -gt 0 ; do
: > "${status_file}" : > "${status_file}"
( setsid \
set -o pipefail env \
ret=0 output_file="$output_file" \
if ! eval "$cmd" 2>&1 | tee -a "$output_file" ; then status_file="$status_file" \
ret=1 sid_file="$sid_file" \
fi cmd="$cmd" \
echo "$ret" > "$status_file" sh -c '
exit $ret set -o pipefail
) & ps -o sid= > "$sid_file"
local pid=$! ret=0
if ! eval "$cmd" 2>&1 | tee -a "$output_file" ; then
ret=1
fi
echo "$ret" > "$status_file"
'
while test "$(stat -c "%s" "$status_file")" -eq 0 ; do while test "$(stat -c "%s" "$status_file")" -eq 0 ; do
prev_tmpsize=$tmpsize prev_tmpsize=$tmpsize
sleep $timeout sleep $timeout
@ -106,13 +112,13 @@ run_test_wd() {
break break
fi fi
done done
restarts=$[ restarts - 1 ] restarts=$(( restarts - 1 ))
if test "$(stat -c "%s" "$status_file")" -eq 0 ; then if test "$(stat -c "%s" "$status_file")" -eq 0 ; then
# status file not updated, assuming hang # status file not updated, assuming hang
kill -KILL $pid pkill -KILL -s$(cat "$sid_file")
if test $restarts -eq 0 ; then if test $restarts -eq 0 ; then
if test "x$hang_ok" = "x" ; then if test "x$hang_ok" = "x" ; then
fail "${test_name}" E "Test hang up" fail "$test_name" E "Test hang up"
fi fi
else else
echo "Test ${test_name} hang up, restarting" echo "Test ${test_name} hang up, restarting"
@ -121,11 +127,15 @@ run_test_wd() {
else else
local new_failed="$(cat "$status_file")" local new_failed="$(cat "$status_file")"
if test "x$new_failed" != "x0" ; then if test "x$new_failed" != "x0" ; then
fail "${test_name}" F "Test failed in run_test_wd" fail "$test_name" F "Test failed in run_test_wd"
fi fi
return 0 break
fi fi
done done
rm -f "$output_file"
rm -f "$status_file"
rm -f "$sid_file"
} }
ended_successfully() { ended_successfully() {