1#!/bin/sh 2# Validate timeout parameter combinations 3 4# Copyright (C) 2008-2023 Free Software Foundation, Inc. 5 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. 10 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. 15 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/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ timeout env 21getlimits_ 22 23 24# internal errors are 125, distinct from execution failure 25 26# invalid timeout 27returns_ 125 timeout invalid sleep 0 || fail=1 28 29# invalid kill delay 30returns_ 125 timeout --kill-after=invalid 1 sleep 0 || fail=1 31 32# invalid timeout suffix 33returns_ 125 timeout 42D sleep 0 || fail=1 34 35# floating point notation 36timeout 10.34 sleep 0 || fail=1 37 38# nanoseconds potentially supported 39timeout 9.999999999 sleep 0 || fail=1 40 41# invalid signal spec 42returns_ 125 timeout --signal=invalid 1 sleep 0 || fail=1 43 44# invalid command 45returns_ 126 env . && { returns_ 126 timeout 10 . || fail=1; } 46 47# no such command 48returns_ 127 timeout 10 no_such || fail=1 49 50Exit $fail 51