2 # Make sure all of these programs promptly diagnose write errors.
4 # Copyright (C) 2023-2024 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 <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 if ! test -w /dev
/full ||
! test -c /dev
/full
; then
23 skip_
'/dev/full is required'
26 # Writers that may output data indefinitely
27 # First word in command line is checked against built programs
30 comm -z /dev/zero /dev/zero
35 factor --version; yes 1 | factor
37 # TODO: fold -b /dev/zero
38 head -z -n-1 /dev/zero
39 join -a 1 -z /dev/zero /dev/null
40 # TODO: nl --version; yes | nl
41 # TODO: numfmt --version; yes 1 | numfmt
46 tail -n+1 -z /dev/zero
53 sort -k 1b
,1 > all_writers || framework_failure_
55 printf '%s\n' $built_programs |
56 sort -k 1b
,1 > built_programs || framework_failure_
58 join all_writers built_programs
> built_writers || framework_failure_
61 # Enforce mem usage limits if possible
62 cmd
=$
(printf '%s\n' "$writer" | cut
-d ' ' -f1) || framework_failure_
63 base_mem
=$
(get_min_ulimit_v_
$cmd --version) \
64 && ulimit="ulimit -v $(($base_mem+8000))" \
67 # Check /dev/full handling
68 rm -f full.err || framework_failure_
69 timeout
10 $SHELL -c "($ulimit && $writer 2>full.err >/dev/full)"
70 { test $?
= 124 ||
! grep 'space' full.err
>/dev
/null
; } &&
71 { fail
=1; cat full.err
; echo "$writer: failed to exit" >&2; }
73 # Check closed pipe handling
74 rm -f pipe.err || framework_failure_
75 timeout
10 $SHELL -c "($ulimit && $writer 2>pipe.err | :)"
76 { test $?
= 0 && compare
/dev
/null pipe.err
; } ||
77 { fail
=1; cat pipe.err
; echo "$writer: failed to write to closed pipe" >&2; }