From: Pádraig Brady Date: Sat, 3 Aug 2024 13:13:43 +0000 (+0100) Subject: tests: limit mem usage on potentially expensive test X-Git-Tag: v9.6~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bb31793c29e9bac15df531d1e8ad13078be00c8;p=thirdparty%2Fcoreutils.git tests: limit mem usage on potentially expensive test * tests/misc/write-errors.sh: Limit mem usage if possible, as some implementations may use unbounded memory for the tests cases used here. --- diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh index 0ead519d65..8b573d4f0a 100755 --- a/tests/misc/write-errors.sh +++ b/tests/misc/write-errors.sh @@ -58,11 +58,21 @@ sort -k 1b,1 > built_programs || framework_failure_ join all_writers built_programs > built_writers || framework_failure_ while read writer; do - timeout 10 $SHELL -c "$writer > /dev/full" - test $? = 124 && { fail=1; echo "$writer: failed to exit" >&2; } + # Enforce mem usage limits if possible + cmd=$(printf '%s\n' "$writer" | cut -d ' ' -f1) || framework_failure_ + base_mem=$(get_min_ulimit_v_ $cmd --version) \ + && ulimit="ulimit -v $(($base_mem+8000))" \ + || ulimit='true' + # Check /dev/full handling + rm -f full.err || framework_failure_ + timeout 10 $SHELL -c "($ulimit && $writer 2>full.err >/dev/full)" + { test $? = 124 || ! grep 'space' full.err >/dev/null; } && + { fail=1; cat full.err; echo "$writer: failed to exit" >&2; } + + # Check closed pipe handling rm -f pipe.err || framework_failure_ - timeout 10 $SHELL -c "$writer 2>pipe.err | :" + timeout 10 $SHELL -c "($ulimit && $writer 2>pipe.err | :)" { test $? = 0 && compare /dev/null pipe.err; } || { fail=1; cat pipe.err; echo "$writer: failed to write to closed pipe" >&2; } done < built_writers