]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: tail: avoid failure on Solaris 11
authorPádraig Brady <P@draigBrady.com>
Tue, 14 Jan 2025 21:14:50 +0000 (21:14 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 15 Jan 2025 12:07:52 +0000 (12:07 +0000)
* tests/tail/tail-c.sh: On Solaris 11, tail -c 4096 /dev/urandom,
will induce an lseek(,-4096,SEEK_END) which returns -4096 without
setting errno, and a subsequent read() then gives EINVAL.
Since tailing the end of a psuedo device is an edge case,
we just verify that we don't spin reading the device forever.

tests/tail/tail-c.sh

index b7de1e9384c1bd69bb331bdd99d65db2fdf8b4b8..75392df23eb63c94506449da8d1441a4e078e05b 100755 (executable)
@@ -42,7 +42,14 @@ compare exp out || fail=1
 
 # Any part of /dev/urandom, if it exists, should be valid for tail -c.
 if test -r /dev/urandom; then
-  timeout --verbose 1 tail -c 4096 /dev/urandom >/dev/null || fail=1
+  # Or at least it should not read it forever
+  timeout --verbose 1 tail -c 4096 /dev/urandom >/dev/null 2>err
+  case $? in
+      0) ;;
+      # Solaris 11 allows negative seek but then gives EINVAL on read
+      1) grep 'Invalid argument' err || fail=1;;
+      *) fail=1;;
+  esac
 fi
 
 Exit $fail