]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix false failure under some shells master
authorPádraig Brady <P@draigBrady.com>
Sat, 11 Apr 2026 21:33:50 +0000 (22:33 +0100)
committerPádraig Brady <P@draigBrady.com>
Sun, 12 Apr 2026 10:41:31 +0000 (11:41 +0100)
Verified with:
  make -j4 PREFERABLY_POSIX_SHELL=/bin/ksh SUBDIRS=. check

* tests/fold/fold-zero-width.sh: Don't timeout $SHELL -c ...
as the ulimit induces a failure in the subshell depending
on the order of the allocations it does.  The main issue is
disparity between the probed ulimit and that needed by $SHELL -c.
Such subshells load the often very large locale archive, thus
if there are any allocations done after the now too low ulimit is set,
then the $SHELL command fails. Note we timeout fold rather than
the whole pipeline so any 124 exit status is propagated.

tests/fold/fold-zero-width.sh

index 402b2b55eee12baea25cecc2523fd66745fa9b6e..933d09ca138a100c09df58c0e3121f9291858e2a 100755 (executable)
@@ -54,13 +54,12 @@ test $(wc -l < out) -eq $(($IO_BUFSIZE_TIMES2 / 80)) || fail=1
 
 # Ensure bounded memory operation.
 test -w /dev/full && test -c /dev/full &&
-vm=$(get_min_ulimit_v_ fold /dev/null) && {
+vm=$(get_min_ulimit_v_ timeout 10 fold /dev/null) && {
   # \303 results in EILSEQ on input
   for c in '\n' '\0' '\303'; do
-    tr '\0' "$c" < /dev/zero | timeout 10 $SHELL -c \
-     "(ulimit -v $(($vm+12000)) && fold 2>err >/dev/full)"
+    tr '\0' "$c" < /dev/zero |
+     (ulimit -v $(($vm+12000)) && timeout 10 fold 2>err >/dev/full)
     ret=$?
-    test -f err || skip_ 'shell ulimit failure'
     { test $ret = 124 || ! grep "$ENOSPC" err >/dev/null; } &&
      { fail=1; cat err; echo "fold didn't diagnose ENOSPC" >&2; }
   done