2 # Check stats output for SIG{INFO,USR1} and status=progress
4 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 env
kill -l |
grep '^INFO$' && SIGINFO
='INFO' || SIGINFO
='USR1'
24 # This to avoid races in the USR1 case
25 # as the dd process will terminate by default until
26 # it has its handler enabled.
31 # Terminate any background processes
35 kill $pid2 2>/dev
/null
39 for open
in '' '1'; do
40 # Run dd with the fullblock iflag to avoid short reads
41 # which can be triggered by reception of signals
42 dd iflag
=fullblock
if=/dev
/zero of
=fifo count
=100 bs
=5000000 2>err
& pid
=$
!
44 # Note if we sleep here we give dd a chance to exec and block on open.
45 # Otherwise we're probably testing SIG_IGN in the forked shell or early dd.
46 test "$open" && sleep .1
48 # dd will block on open until fifo is opened for reading.
49 # Timeout in case dd goes away erroneously which we check for below.
50 timeout
10 sh
-c 'wc -c < fifo > nwritten' & pid2
=$
!
52 # Send lots of signals immediately to ensure dd not killed due
53 # to race setting handler, or blocking on open of fifo.
54 # Many signals also check that short reads are handled.
55 until ! kill -s $SIGINFO $pid 2>/dev
/null
; do
61 # Ensure all data processed and at least last status written
62 grep '500000000 bytes .* copied' err ||
{ cat err
; fail
=1; }
67 { sleep "$1"; echo 1; } |
dd bs
=1 status
=progress of
=/dev
/null
2>err
68 # Progress output should be for "byte ... copied", while final is "bytes ..."
69 grep 'byte .* copied' err
71 retry_delay_ progress_output
1 4 ||
{ cat err
; fail
=1; }