2 # Ensure that tail does not ignore data that is appended to a tailed-forever
3 # file between tail's initial read-to-EOF, and when the inotify watches
4 # are established in tail_forever_inotify. That data could be ignored
5 # indefinitely if no *other* data is appended, but it would be printed as
6 # soon as any additional appended data is detected.
8 # Copyright (C) 2009-2016 Free Software Foundation, Inc.
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
26 # Terminate any background gdb/tail process
28 kill $pid 2>/dev
/null
&& wait $pid
29 kill $sleep 2>/dev
/null
&& wait $sleep
32 touch file || framework_failure_
33 touch tail.out || framework_failure_
35 ( timeout
10s gdb
--version ) > gdb.out
2>&1
36 case $
(cat gdb.out
) in
38 *) skip_
"can't run gdb";;
41 # Break on a line rather than a symbol, to cater for inline functions
42 break_src
="$abs_top_srcdir/src/tail.c"
43 break_line
=$
(grep -n ^tail_forever_inotify
"$break_src") || framework_failure_
44 break_line
=$
(echo "$break_line" | cut
-d: -f1) || framework_failure_
47 # Note we get tail to monitor a background sleep process
48 # rather than using timeout(1), as timeout sends SIGCONT
49 # signals to its monitored process, and gdb (7.9 at least)
50 # has _intermittent_ issues with this.
51 # Sending SIGCONT resulted in either delayed child termination,
52 # or no child termination resulting in a hung test.
53 # See https://sourceware.org/bugzilla/show_bug.cgi?id=18364
55 env
sleep 10 & sleep=$
!
57 # See if gdb works and
58 # tail_forever_inotify is compiled and run
59 gdb
-nx --batch-silent \
60 --eval-command="break $break_line" \
61 --eval-command="run --pid=$sleep -f file" \
62 --eval-command='quit' \
63 tail < /dev
/null
> gdb.out
2>&1
65 kill $sleep || skip_
'breakpoint not hit'
68 # FIXME: The above is seen to _intermittently_ fail with:
69 # warning: .dynamic section for "/lib/libc.so.6" is not at the expected address
70 # warning: difference appears to be caused by prelink, adjusting expectations
71 compare
/dev
/null gdb.out || skip_
"can't set breakpoints in tail"
73 env
sleep 10 & sleep=$
!
75 # Run "tail -f file", stopping to append a line just before
76 # inotify initialization, and then continue. Before the fix,
77 # that just-appended line would never be output.
78 gdb
-nx --batch-silent \
79 --eval-command="break $break_line" \
80 --eval-command="run --pid=$sleep -f file >> tail.out" \
81 --eval-command='shell echo never-seen-with-tail-7.5 >> file' \
82 --eval-command='continue' \
83 --eval-command='quit' \
84 tail < /dev
/null
> /dev
/null
2>&1 & pid
=$
!
86 tail --pid=$pid -f tail.out |
(read REPLY
; kill $pid)
88 # gdb has a bug in Debian's gdb-6.8-3 at least that causes it to not
89 # cleanup and exit correctly when it receives a SIGTERM, but
90 # killing sleep, should cause the tail process and thus gdb to exit.
96 compare
/dev
/null
tail.out
&& fail
=1