From: Collin Funk Date: Sat, 24 Jan 2026 19:15:10 +0000 (-0800) Subject: tests: avoid failures if 'ulimit -n' cannot set file descriptor limits X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec77664a31c474319e4987f1194b009769410477;p=thirdparty%2Fcoreutils.git tests: avoid failures if 'ulimit -n' cannot set file descriptor limits This fixes test failures seen on Haiku. * tests/ls/recursive.sh: Run 'ls' even if ulimit fails. * tests/split/r-chunk.sh: Run 'split' even if ulimit fails. * tests/sort/sort-merge-fdlimit.sh: Skip test if 'ulimit -n' cannot set file descriptor limits. Reported by Bruno Haible. --- diff --git a/tests/ls/recursive.sh b/tests/ls/recursive.sh index 74673680eb..477f92f54f 100755 --- a/tests/ls/recursive.sh +++ b/tests/ls/recursive.sh @@ -62,7 +62,7 @@ compare exp out || fail=1 # Check that we don't run out of file descriptors when visiting # directories recursively. mkdir -p $(seq 30 | tr '\n' '/') || framework_failure_ -(ulimit -n 20 && ls -R 1 > out 2> err) || fail=1 +(ulimit -n 20; ls -R 1 > out 2> err) || fail=1 test $(wc -l < out) = 88 || fail=1 test $(wc -l < err) = 0 || fail=1 diff --git a/tests/sort/sort-merge-fdlimit.sh b/tests/sort/sort-merge-fdlimit.sh index 6ec34cfd9f..bb9c2c0816 100755 --- a/tests/sort/sort-merge-fdlimit.sh +++ b/tests/sort/sort-merge-fdlimit.sh @@ -35,10 +35,12 @@ seq 17 >some-data # the ATF but fail inside it. # The default batch size (nmerge) is 16. -(ulimit -n 19 \ +(ulimit -n 19 && touch ulimit-worked \ && sort -m --batch-size=16 in/* 2>err/merge-default-err \ || ! grep "open failed" err/merge-default-err) || fail=1 +test -f ulimit-worked || skip_ 'cannot modify open file descriptor limit' + # If sort opens a file to sort by random hashes of keys, # it needs to consider this file against its limit on open file # descriptors. Test once with the default random source diff --git a/tests/split/r-chunk.sh b/tests/split/r-chunk.sh index d946697fba..71fdb3ad54 100755 --- a/tests/split/r-chunk.sh +++ b/tests/split/r-chunk.sh @@ -58,7 +58,7 @@ compare exp out || fail=1 # Ensure we fall back to appending to a file at a time # if we hit the limit for the number of open files. rm x* -(ulimit -n 20 && yes | head -n90 | split -n r/30 ) || fail=1 +(ulimit -n 20; yes | head -n90 | split -n r/30 ) || fail=1 test "$(stat -c %s x* | uniq -c | sed 's/^ *//; s/ /x/')" = "30x6" || fail=1 Exit $fail