ci: remove watchdog function run_tests_wd
It's only used once for running check-single-includes (which I strongly suspect it doesn't need anyway), its core logic is incorrect since both the variables "tempsize" and "prev_temsize" are never defined and parsing ps is incredibly fragile.
This commit is contained in:
parent
e42c906597
commit
64f23c27e2
|
@ -98,99 +98,6 @@ run_test() {
|
|||
fi
|
||||
}
|
||||
|
||||
run_test_wd() {
|
||||
local hang_ok=
|
||||
if test "$1" = "--allow-hang" ; then
|
||||
hang_ok=1
|
||||
shift
|
||||
fi
|
||||
|
||||
local timeout="$1"
|
||||
test $# -gt 0 && shift
|
||||
|
||||
local cmd="$1"
|
||||
test $# -gt 0 && shift
|
||||
|
||||
local restart_cmd="$1"
|
||||
: ${restart_cmd:=true}
|
||||
test $# -gt 0 && shift
|
||||
|
||||
local test_name="$1"
|
||||
: ${test_name:=$cmd}
|
||||
test $# -gt 0 && shift
|
||||
|
||||
local output_file="$(mktemp)"
|
||||
local status_file="$(mktemp)"
|
||||
local sid_file="$(mktemp)"
|
||||
|
||||
local restarts=5
|
||||
local prev_tmpsize=-1
|
||||
while test $restarts -gt 0 ; do
|
||||
: > "$status_file"
|
||||
: > "$sid_file"
|
||||
setsid \
|
||||
env \
|
||||
output_file="$output_file" \
|
||||
status_file="$status_file" \
|
||||
sid_file="$sid_file" \
|
||||
cmd="$cmd" \
|
||||
CI_DIR="$CI_DIR" \
|
||||
sh -c '
|
||||
. "${CI_DIR}/common/test.sh"
|
||||
ps -o sid= > "$sid_file"
|
||||
(
|
||||
ret=0
|
||||
if ! eval "$cmd" 2>&1 ; then
|
||||
ret=1
|
||||
fi
|
||||
echo "$ret" > "$status_file"
|
||||
) | tee -a "$output_file"
|
||||
'
|
||||
while test "$(stat -c "%s" "$status_file")" -eq 0 ; do
|
||||
prev_tmpsize=$tmpsize
|
||||
sleep $timeout
|
||||
tmpsize="$(stat -c "%s" "$output_file")"
|
||||
if test $tempsize -eq $prev_temsize ; then
|
||||
# no output, assuming either hang or exit
|
||||
break
|
||||
fi
|
||||
done
|
||||
restarts=$(( restarts - 1 ))
|
||||
if test "$(stat -c "%s" "$status_file")" -eq 0 ; then
|
||||
# Status file not updated, assuming hang
|
||||
|
||||
# SID not known, this should not ever happen
|
||||
if test "$(stat -c "%s" "$sid_file")" -eq 0 ; then
|
||||
fail "$test_name" E "Shell did not run"
|
||||
break
|
||||
fi
|
||||
|
||||
# Kill all processes which belong to one session: should get rid of test
|
||||
# processes as well as sh itself.
|
||||
pkill -KILL -s$(cat "$sid_file")
|
||||
|
||||
if test $restarts -eq 0 ; then
|
||||
if test -z "$hang_ok" ; then
|
||||
fail "$test_name" E "Test hang up"
|
||||
fi
|
||||
else
|
||||
echo "Test ${test_name} hang up, restarting"
|
||||
eval "$restart_cmd"
|
||||
fi
|
||||
else
|
||||
local new_failed="$(cat "$status_file")"
|
||||
if test "$new_failed" != "0" ; then
|
||||
fail "$test_name" F "Test failed in run_test_wd"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f "$output_file"
|
||||
rm -f "$status_file"
|
||||
rm -f "$sid_file"
|
||||
}
|
||||
|
||||
ended_successfully() {
|
||||
if test -f "${FAIL_SUMMARY_FILE}" ; then
|
||||
echo 'Test failed, complete summary:'
|
||||
|
|
|
@ -25,12 +25,7 @@ run_test 'make shlint' shlint
|
|||
exit_suite --continue
|
||||
|
||||
enter_suite single-includes
|
||||
CLICOLOR_FORCE=1 run_test_wd \
|
||||
--allow-hang \
|
||||
10s \
|
||||
'make check-single-includes' \
|
||||
'csi_clean' \
|
||||
single-includes
|
||||
run_test 'make check-single-includes' single-includes
|
||||
exit_suite --continue
|
||||
|
||||
end_tests
|
||||
|
|
Loading…
Reference in New Issue