1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

test/path.sh: don't fail if 'command -x' test runs out of memory

Some systems issue SIGKILL if a process takes up too much memory.
That is easy to check for.
This commit is contained in:
Martijn Dekker 2021-03-12 13:14:54 +00:00
parent a35a47b835
commit 5939964725

View file

@ -24,6 +24,7 @@ function err_exit
let Errors+=1 let Errors+=1
} }
alias err_exit='err_exit $LINENO' alias err_exit='err_exit $LINENO'
alias warning='err\_exit $((Errors--,LINENO)) warning:'
Command=${0##*/} Command=${0##*/}
integer Errors=0 integer Errors=0
@ -341,7 +342,7 @@ scr=$tmp/script
exp=126 exp=126
if [[ $(id -u) == '0' ]]; then if [[ $(id -u) == '0' ]]; then
print -u2 "\t${Command}[$LINENO]: warning: running as root: skipping tests involving unreadable scripts" warning "running as root: skipping tests involving unreadable scripts"
else else
: > $scr : > $scr
@ -571,11 +572,13 @@ sleep_pid=$!
' static_argzero "$@" final_static_arg_1 final_static_arg_2 ' static_argzero "$@" final_static_arg_1 final_static_arg_2
) >$ofile & ) >$ofile &
pid=$! pid=$!
wait $pid { wait $pid; } 2>/dev/null # wait and suppress signal messages
e=$? e=$?
trap - TERM INT trap - TERM INT
[[ $sleep_pid ]] && kill $sleep_pid [[ $sleep_pid ]] && kill $sleep_pid
if let "e > 0" if [[ ${ kill -l "$e"; } == KILL ]]
then warning "'command -x' test killed, probably due to lack of memory; skipping test"
else if let "e > 0"
then err_exit "'command -x' test yielded exit status $e$( let "e>128" && print -n / && kill -l "$e")" then err_exit "'command -x' test yielded exit status $e$( let "e>128" && print -n / && kill -l "$e")"
fi fi
if [[ ! -s $ofile ]] if [[ ! -s $ofile ]]
@ -588,6 +591,7 @@ else save_Command=$Command
"(expected $expargs args of total size $expsize, got $args args of total size $size;" \ "(expected $expargs args of total size $expsize, got $args args of total size $size;" \
"divided in $chunks chunks)" "divided in $chunks chunks)"
fi fi
fi
# ====== # ======
# whence -a/-v tests # whence -a/-v tests