diff options
| author | Pádraig Brady <P@draigBrady.com> | 2024-08-03 14:13:43 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2024-08-04 10:58:31 +0100 |
| commit | 1bb31793c29e9bac15df531d1e8ad13078be00c8 (patch) | |
| tree | c0560170c244a7ca148a024d0e36f86fffb7ae8f /tests/misc/write-errors.sh | |
| parent | tests: ensure utils support writing to a closed pipe (diff) | |
| download | coreutils-1bb31793c29e9bac15df531d1e8ad13078be00c8.tar.gz coreutils-1bb31793c29e9bac15df531d1e8ad13078be00c8.zip | |
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.
Diffstat (limited to 'tests/misc/write-errors.sh')
| -rwxr-xr-x | tests/misc/write-errors.sh | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh index 0ead519d6..8b573d4f0 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 |
