4 # Copyright (C) 2009-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
23 # tail -f - would fail with the initial inotify implementation
28 grep "$tail_re" out ||
29 { sleep $delay; return 1; }
32 # Terminate any background tail process
33 cleanup_
() { kill $pid 2>/dev
/null
&& wait $pid; }
35 # Speedup the non inotify case
36 fastpoll
='-s.1 --max-unchanged-stats=1'
38 echo line
> in || framework_failure_
39 echo line
> exp || framework_failure_
41 for mode
in '' '---disable-inotify'; do
42 > out || framework_failure_
44 tail $mode -f $fastpoll < in > out
2> err
& pid
=$
!
46 # Wait up to 12.7s for output to appear:
47 tail_re
='line' retry_delay_ check_tail_output
.1 7 ||
48 { echo "$0: a: unexpected delay?"; cat out
; fail
=1; }
50 # Ensure there was no error output.
51 compare
/dev
/null err || fail
=1
58 # Before coreutils-8.26 this would induce an UMR under UBSAN
59 returns_
1 timeout
10 tail -f - <&- 2>errt || fail
=1
60 cat <<\EOF
>exp || framework_failure_
61 tail: cannot fstat
'standard input'
62 tail: error reading
'standard input'
63 tail: no files remaining
66 sed 's/\(tail:.*\):.*/\1/' errt
> err || framework_failure_
67 compare exp err || fail
=1
71 # Before coreutils-8.28 this would erroneously issue a warning
72 if tty
-s </dev
/tty
&& test -t 0; then
73 for input
in '' '-' '/dev/tty'; do
74 returns_
124 timeout
0.1 tail -f $input 2>err || fail
=1
75 compare
/dev
/null err || fail
=1
78 tail -f - /dev
/null
</dev
/tty
2> out
& pid
=$
!
79 # Wait up to 12.7s for output to appear:
80 tail_re
='ineffective' retry_delay_ check_tail_output
.1 7 ||