2 # demonstrate that tail -F works for currently missing dirs
3 # Before coreutils-8.6, tail -F missing/file would not
4 # notice any subsequent availability of the missing/file.
6 # Copyright (C) 2010-2013 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=.}/tests/init.sh"; path_prepend_ .
/src
24 debug
='---disable-inotify'
26 tail $debug -F -s.1 missing
/file > out
2>&1 & pid
=$
!
31 grep "$tail_re" out
> /dev
/null ||
32 { sleep $delay; return 1; }
35 # Wait up to 6.3s for tail to start with diagnostic:
36 # tail: cannot open 'missing/file' for reading: No such file or directory
37 tail_re
='cannot open' retry_delay_ check_tail_output
.1 7 || fail
=1
39 mkdir missing || fail
=1
40 (cd missing
&& echo x
> file)
42 # Wait up to 6.3s for this to appear in the output:
43 # "tail: '...' has appeared; following end of new file"
44 tail_re
='has appeared' retry_delay_ check_tail_output
.1 7 ||
45 { echo "$0: file: unexpected delay?"; cat out
; fail
=1; }
53 { sleep $delay; return 1; }
56 # Try repeatedly to remove the temporary directory.
57 # This is normally unnecessary, because the containing directory will
58 # be removed by code from init.sh. However, when this particular test
59 # is run on an NFS-mounted volume, sometimes init.sh's cleanup code
60 # fails because the directory is not yet really empty, perhaps because
61 # the tail process (reading missing/file) is not yet killed.
62 retry_delay_ cleanup
.1 6