]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: cat: avoid false failure on systems without splice
authorPádraig Brady <P@draigBrady.com>
Tue, 7 Apr 2026 11:20:10 +0000 (12:20 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 7 Apr 2026 11:20:10 +0000 (12:20 +0100)
* tests/cat/splice.sh: Ensure splice is called multiple times
before we check specific invocation counts.
On Linux kernel 5.10 for example, splice from /dev/zero
returns EINVAL.

tests/cat/splice.sh

index 513a33181962340360656898a92af28ae73b0c51..55b96711bb5d15fc79fca078e0880a569c5a4200 100755 (executable)
@@ -27,9 +27,16 @@ if timeout 10 true; then
   test $? = 124 || fail=1
 fi
 
+# Verify splice is called multiple times,
+# and doesn't just fall back after the first EINVAL.
+# This also implicitly handles systems without splice at all.
+strace -o splice_count -e splice cat /dev/zero | head -c1M >/dev/null
+splice_count=$(grep '^splice' splice_count | wc -l)
+
 # Test that splice errors are diagnosed.
 # Odd numbers are for input, even for output
-if strace -o /dev/null -e inject=splice:error=EIO:when=3 true; then
+if test "$splice_count" -gt 1 &&
+   strace -o /dev/null -e inject=splice:error=EIO:when=3 true; then
   for when in 3 4; do
     test "$when" = 4 && efile='write error' || efile='/dev/zero'
     printf 'cat: %s: %s\n' "$efile" "$EIO" > exp || framework_failure_