~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/tail-2/F-vs-missing.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 
 
6
# Copyright (C) 2010-2012 Free Software Foundation, Inc.
 
7
 
 
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.
 
12
 
 
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.
 
17
 
 
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/>.
 
20
 
 
21
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
22
print_ver_ tail
 
23
 
 
24
debug='---disable-inotify'
 
25
debug=
 
26
tail $debug -F -s.1 missing/file > out 2>&1 & pid=$!
 
27
 
 
28
check_tail_output()
 
29
{
 
30
  local delay="$1"
 
31
  grep "$tail_re" out > /dev/null ||
 
32
    { sleep $delay; return 1; }
 
33
}
 
34
 
 
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
 
38
 
 
39
mkdir missing || fail=1
 
40
(cd missing && echo x > file)
 
41
 
 
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; }
 
46
 
 
47
kill -HUP $pid
 
48
 
 
49
cleanup()
 
50
{
 
51
  local delay="$1"
 
52
  rm -rf missing ||
 
53
    { sleep $delay; return 1; }
 
54
}
 
55
 
 
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
 
63
 
 
64
Exit $fail