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

« back to all changes in this revision

Viewing changes to tests/tail-2/wait.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
# Make sure that 'tail -f' returns immediately if a file doesn't exist
 
3
# while 'tail -F' waits for it to appear.
 
4
 
 
5
# Copyright (C) 2003-2012 Free Software Foundation, Inc.
 
6
 
 
7
# This program is free software: you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation, either version 3 of the License, or
 
10
# (at your option) any later version.
 
11
 
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
 
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
21
print_ver_ tail
 
22
 
 
23
touch here || framework_failure_
 
24
{ touch unreadable && chmod a-r unreadable; } || framework_failure_
 
25
 
 
26
 
 
27
for inotify in ---disable-inotify ''; do
 
28
  timeout 10 tail -s0.1 -f $inotify not_here
 
29
  test $? = 124 && fail=1
 
30
 
 
31
  if test ! -r unreadable; then # can't test this when root
 
32
    timeout 10 tail -s0.1 -f $inotify unreadable
 
33
    test $? = 124 && fail=1
 
34
  fi
 
35
 
 
36
  timeout 1 tail -s0.1 -f $inotify here 2>tail.err
 
37
  test $? = 124 || fail=1
 
38
 
 
39
  # 'tail -F' must wait in any case.
 
40
 
 
41
  timeout 1 tail -s0.1 -F $inotify here 2>>tail.err
 
42
  test $? = 124 || fail=1
 
43
 
 
44
  if test ! -r unreadable; then # can't test this when root
 
45
    timeout 1 tail -s0.1 -F $inotify unreadable
 
46
    test $? = 124 || fail=1
 
47
  fi
 
48
 
 
49
  timeout 1 tail -s0.1 -F $inotify not_here
 
50
  test $? = 124 || fail=1
 
51
 
 
52
  grep -Ev 'inotify (resources exhausted|cannot be used)' tail.err > x
 
53
  mv x tail.err
 
54
  test -s tail.err && fail=1
 
55
  :>tail.err
 
56
 
 
57
  tail_F()
 
58
  {
 
59
    local delay="$1"
 
60
 
 
61
    touch k || framework_failure_
 
62
    tail -s.1 --max-unchanged-stats=2 -F $inotify k > tail.out &
 
63
    pid=$!
 
64
    sleep $delay
 
65
    mv k l
 
66
    sleep $delay
 
67
    touch k
 
68
    mv k l
 
69
    sleep $delay
 
70
    echo NO >> l
 
71
    sleep $delay
 
72
    kill $pid
 
73
    rm -f k l
 
74
 
 
75
    test ! -s tail.out
 
76
  }
 
77
  retry_delay_ tail_F .1 4 || fail=1
 
78
done
 
79
 
 
80
Exit $fail