]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid failures if 'ulimit -n' cannot set file descriptor limits
authorCollin Funk <collin.funk1@gmail.com>
Sat, 24 Jan 2026 19:15:10 +0000 (11:15 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 24 Jan 2026 19:20:56 +0000 (11:20 -0800)
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.

tests/ls/recursive.sh
tests/sort/sort-merge-fdlimit.sh
tests/split/r-chunk.sh

index 74673680eb4a201df3585079f3be99ac2944f56d..477f92f54ffff44c7679dce449f66fda5ea74964 100755 (executable)
@@ -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
 
index 6ec34cfd9f8cabbbe425a2a8f55f062dc72c0372..bb9c2c0816daa49a9f692ca40a030d92094da396 100755 (executable)
@@ -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
index d946697fbae02a14db0e8a66e1e8fe82ff036ccd..71fdb3ad542086e49afdb8933cf49c803317703d 100755 (executable)
@@ -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