2 # Test for proper detection of I/O errors in seq
4 # Copyright (C) 2016-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 # Run 'seq' with a timeout, preventing infinite-loop run.
27 # expected returned codes:
28 # 1 - seq detected an I/O error and exited with an error.
29 # 124 - timed-out (seq likely infloop)
30 # other - unexpected error
31 timed_seq_fail
() { timeout
10 seq "$@" >/dev
/full
2>/dev
/null
; }
34 # Test infinite sequence, using fast-path method (seq_fast).
35 returns_
1 timed_seq_fail
1 inf || fail
=1
37 # Test infinite sequence, using slow-path method (print_numbers).
38 returns_
1 timed_seq_fail
1.1 .1 inf || fail
=1
40 # Test non-infinite sequence, using slow-path method (print_numbers).
41 # (despite being non-infinite, the entire sequence should take long time to
42 # print. Thus, either an I/O error is detected immediately, or seq will
44 returns_
1 timed_seq_fail
1 0.0001 99999999 || fail
=1