2 # Ensure we diagnose and not continue writing to
3 # the output if we get a write error.
5 # Copyright (C) 2014-2016 Free Software Foundation, Inc.
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.
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.
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/>.
20 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
23 if ! test -w /dev
/full ||
! test -c /dev
/full
; then
24 skip_
'/dev/full is required'
27 # We can't use /dev/zero as that's bypassed in the --lines case
28 # due to lseek() indicating it has a size of zero.
29 yes |
head -c10M > bigseek || framework_failure_
31 # This is the single output diagnostic expected,
32 # (without the possibly varying :strerror(ENOSPC) suffix).
33 printf '%s\n' "head: error writing 'standard output'" > exp
35 # Memory is bounded in these cases
36 for item
in lines bytes
; do
39 yes | timeout
10s
head --$item=-$N > /dev
/full
2> errt
&& fail
=1
40 test $?
= 124 && fail
=1
41 sed 's/\(head:.*\):.*/\1/' errt
> err
42 compare exp err || fail
=1
45 timeout
10s
head --$item=-$N bigseek
> /dev
/full
2> errt
&& fail
=1
46 test $?
= 124 && fail
=1
47 sed 's/\(head:.*\):.*/\1/' errt
> err
48 compare exp err || fail
=1