maint: update all copyright year number ranges
[coreutils.git] / tests / misc / sleep.sh
blob0876dd7eb658a0c885725437dac18d9c84088cfc
1 #!/bin/sh
2 # Validate sleep parameters
4 # Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ sleep
21 getlimits_
23 # invalid timeouts
24 returns_ 1 timeout 10 sleep invalid || fail=1
25 returns_ 1 timeout 10 sleep -- -1 || fail=1
26 returns_ 1 timeout 10 sleep 42D || fail=1
27 returns_ 1 timeout 10 sleep 42d 42day || fail=1
28 returns_ 1 timeout 10 sleep nan || fail=1
29 returns_ 1 timeout 10 sleep '' || fail=1
30 returns_ 1 timeout 10 sleep || fail=1
32 # subsecond actual sleep
33 timeout 10 sleep 0.001 || fail=1
34 timeout 10 sleep 0x.002p1 || fail=1
36 # Using small timeouts for larger sleeps is racy,
37 # but false positives should be avoided on most systems
38 returns_ 124 timeout 0.1 sleep 1d 2h 3m 4s || fail=1
39 returns_ 124 timeout 0.1 sleep inf || fail=1
40 returns_ 124 timeout 0.1 sleep $LDBL_MAX || fail=1
42 Exit $fail