2
# demonstrate that tail -F works when renaming the tailed files
3
# Before coreutils-8.3, tail -F a b would stop tracking additions to b
6
# Copyright (C) 2009-2011 Free Software Foundation, Inc.
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
. "${srcdir=.}/init.sh"; path_prepend_ ../src
24
touch a b || framework_failure_
26
debug='---disable-inotify'
28
tail $debug -F -s.1 a b > out 2>&1 & pid=$!
33
grep "$tail_re" out > /dev/null ||
34
{ sleep $delay; return 1; }
37
# Wait up to 6.3s for tail to start
39
tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1
43
# Wait 6.3s for this diagnostic:
44
# tail: `a' has become inaccessible: No such file or directory
45
tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1
48
# Wait up to 6.3s for this to appear in the output:
49
# "tail: `...' has appeared; following end of new file"
50
tail_re='has appeared' retry_delay_ check_tail_output .1 7 ||
51
{ echo "$0: a: unexpected delay?"; cat out; fail=1; }
54
# Wait up to 6.3s for "y" to appear in the output:
55
tail_f_vs_rename_2() {
57
tr '\n' @ < out | grep '@@==> b <==@y@$' > /dev/null ||
58
{ sleep $delay; return 1; }
60
retry_delay_ tail_f_vs_rename_2 .1 7 ||
61
{ echo "$0: b: unexpected delay?"; cat out; fail=1; }
64
# Wait up to 6.3s for "z" to appear in the output:
65
tail_f_vs_rename_3() {
67
tr '\n' @ < out | grep '@@==> a <==@z@$' > /dev/null ||
68
{ sleep $delay; return 1; }
70
retry_delay_ tail_f_vs_rename_3 .1 7 ||
71
{ echo "$0: a: unexpected delay?"; cat out; fail=1; }