1#!/bin/sh
2# Validate large timeout parameters
3# Separated from standard parameter testing due to kernel overflow bugs.
4
5# Copyright (C) 2008-2023 Free Software Foundation, Inc.
6
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.
11
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.
16
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
20. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
21print_ver_ timeout
22getlimits_
23
24# It was seen on 32 bit Linux/HPPA and OpenIndiana 11
25# that a kernel time_t overflowing cause the timer to fire immediately.
26# This is still racy, but unlikely to cause an issue unless
27# timeout can't process the timer firing within 3 seconds.
28timeout $TIME_T_OFLOW sleep 3
29if test $? = 124; then
30  skip_ 'timeout $TIME_T_OFLOW ..., timed out immediately!'
31fi
32
33# timeout overflow
34timeout $UINT_OFLOW sleep 0 || fail=1
35
36# timeout overflow
37timeout ${TIME_T_OFLOW}d sleep 0 || fail=1
38
39# floating point notation
40timeout 2.34e+5d sleep 0 || fail=1
41
42# floating point overflow
43timeout $LDBL_MAX sleep 0 || fail=1
44returns_ 125 timeout -- -$LDBL_MAX sleep 0 || fail=1
45
46Exit $fail
47