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

« back to all changes in this revision

Viewing changes to tests/tail-2/F-vs-rename

  • 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 when renaming the tailed files
3
 
# Before coreutils-8.3, tail -F a b would stop tracking additions to b
4
 
# after "mv a b".
5
 
 
6
 
# Copyright (C) 2009-2011 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=.}/init.sh"; path_prepend_ ../src
22
 
print_ver_ tail
23
 
 
24
 
touch a b || framework_failure_
25
 
 
26
 
debug='---disable-inotify'
27
 
debug=
28
 
tail $debug -F -s.1 a b > out 2>&1 & pid=$!
29
 
 
30
 
check_tail_output()
31
 
{
32
 
  local delay="$1"
33
 
  grep "$tail_re" out > /dev/null ||
34
 
    { sleep $delay; return 1; }
35
 
}
36
 
 
37
 
# Wait up to 6.3s for tail to start
38
 
echo x > a
39
 
tail_re='^x$' retry_delay_ check_tail_output .1 7 || fail=1
40
 
 
41
 
mv a b || fail=1
42
 
 
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
46
 
 
47
 
echo x > a
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; }
52
 
 
53
 
echo y >> b
54
 
# Wait up to 6.3s for "y" to appear in the output:
55
 
tail_f_vs_rename_2() {
56
 
  local delay="$1"
57
 
  tr '\n' @ < out | grep '@@==> b <==@y@$' > /dev/null ||
58
 
    { sleep $delay; return 1; }
59
 
}
60
 
retry_delay_ tail_f_vs_rename_2 .1 7 ||
61
 
  { echo "$0: b: unexpected delay?"; cat out; fail=1; }
62
 
 
63
 
echo z >> a
64
 
# Wait up to 6.3s for "z" to appear in the output:
65
 
tail_f_vs_rename_3() {
66
 
  local delay="$1"
67
 
  tr '\n' @ < out | grep '@@==> a <==@z@$' > /dev/null ||
68
 
    { sleep $delay; return 1; }
69
 
}
70
 
retry_delay_ tail_f_vs_rename_3 .1 7 ||
71
 
  { echo "$0: a: unexpected delay?"; cat out; fail=1; }
72
 
 
73
 
kill -HUP $pid
74
 
 
75
 
Exit $fail