1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-07-25 18:19:00 +02:00
Files
coreutils/tests/timeout/timeout-parameters.sh
T

56 lines
1.6 KiB
Bash
Raw Normal View History

2008-03-28 11:05:55 +00:00
#!/bin/sh
# Validate timeout parameter combinations
2026-01-01 10:56:16 -08:00
# Copyright (C) 2008-2026 Free Software Foundation, Inc.
2008-03-28 11:05:55 +00:00
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
2017-09-19 01:13:23 -07:00
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2008-03-28 11:05:55 +00:00
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ timeout env
getlimits_
2008-03-28 11:05:55 +00:00
2009-10-23 08:54:53 -06:00
# internal errors are 125, distinct from execution failure
2025-04-05 00:58:22 -07:00
# invalid timeouts
returns_ 125 timeout invalid sleep 0 || fail=1
2025-04-05 00:58:22 -07:00
returns_ 125 timeout ' -0.1' sleep 0 || fail=1
returns_ 125 timeout ' -1e-10000' sleep 0 || fail=1
2008-03-28 11:05:55 +00:00
2010-03-15 23:03:30 +00:00
# invalid kill delay
returns_ 125 timeout --kill-after=invalid 1 sleep 0 || fail=1
2010-03-15 23:03:30 +00:00
2008-03-28 11:05:55 +00:00
# invalid timeout suffix
returns_ 125 timeout 42D sleep 0 || fail=1
2008-03-28 11:05:55 +00:00
# floating point notation
timeout 10.34 sleep 0 || fail=1
2011-07-18 10:49:17 +01:00
# nanoseconds potentially supported
timeout 9.999999999 sleep 0 || fail=1
2011-07-18 10:49:17 +01:00
2025-04-05 00:58:22 -07:00
# round underflow up to 1 ns
2025-04-05 11:27:32 +01:00
returns_ 124 timeout 1e-10000 sleep 10 || fail=1
2025-04-05 00:58:22 -07:00
2008-03-28 11:05:55 +00:00
# invalid signal spec
returns_ 125 timeout --signal=invalid 1 sleep 0 || fail=1
2008-03-28 11:05:55 +00:00
# invalid command
returns_ 126 env . && { returns_ 126 timeout 10 . || fail=1; }
2008-03-28 11:05:55 +00:00
2009-10-23 08:54:53 -06:00
# no such command
returns_ 127 timeout 10 no_such || fail=1
2008-03-28 11:05:55 +00:00
Exit $fail