maint: update all copyright year number ranges
[coreutils.git] / tests / tail-2 / F-vs-missing.sh
blob2f13225ad3827459e3251a43d3a3c6358d2b314b
1 #!/bin/sh
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-2017 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
22 print_ver_ tail
24 check_tail_output()
26 local delay="$1"
27 grep "$tail_re" out > /dev/null ||
28 { sleep $delay; return 1; }
31 # Terminate any background tail process
32 cleanup_() { kill $pid 2>/dev/null && wait $pid; }
34 # Speedup the non inotify case
35 fastpoll='-s.1 --max-unchanged-stats=1'
37 for mode in '' '---disable-inotify'; do
38 rm -rf out missing
40 tail $mode -F $fastpoll missing/file > out 2>&1 & pid=$!
42 # Wait up to 12.7s for tail to start with diagnostic:
43 # tail: cannot open 'missing/file' for reading: No such file or directory
44 tail_re='cannot open' retry_delay_ check_tail_output .1 7 ||
45 { cat out; fail=1; }
47 mkdir missing || framework_failure_
48 (cd missing && echo x > file) || framework_failure_
50 # Wait up to 12.7s for this to appear in the output:
51 # "tail: '...' has appeared; following new file"
52 tail_re='has appeared' retry_delay_ check_tail_output .1 7 ||
53 { echo "$0: file: unexpected delay?"; cat out; fail=1; }
55 cleanup_
56 done
59 Exit $fail