]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fold: add a memory constraint test
authorPádraig Brady <P@draigBrady.com>
Mon, 25 Aug 2025 10:38:42 +0000 (11:38 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 26 Aug 2025 15:48:31 +0000 (16:48 +0100)
Enforcing this interface behavior is worthwhile
irrespective of our current implementation,
to ensure future or other implementations conform.

* tests/fold/fold-characters.sh: Ensure the fold implementation
uses bounded memory.

tests/fold/fold-characters.sh

index 0b22aad6be62a66e1cb4ba320be5e440e7deb7f6..a6cc39b73ce6e3a49ee0361f45f10a92e172ef4e 100755 (executable)
@@ -58,4 +58,10 @@ compare column-exp2 column-out2 || fail=1
 fold --characters -w 10 input2 > character-out2 || fail=1
 compare character-exp2 character-out2 || fail=1
 
+# Ensure bounded memory operation
+vm=$(get_min_ulimit_v_ fold /dev/null) && {
+  yes | tr -d '\n' | (ulimit -v $(($vm+8000)) && fold 2>err) | head -n10 || fail=1
+  compare /dev/null err || fail=1
+}
+
 Exit $fail