summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-07-16 12:07:46 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-07-16 12:10:45 -0700
commit240a63375697be8f3ff0fb97aea35ef2fecf1f4d (patch)
tree4a24d1c077bbe0ef3d552a20c4fd5c8d668405b1 /tests/misc
parent2d9b49789fadd039d43e5c1b6d09bebcc075227f (diff)
downloadcoreutils-240a63375697be8f3ff0fb97aea35ef2fecf1f4d.tar.xz
timeout: treat seconds counts like 'sleep' does
Treat fractions as a request to round up to the next representable value, and treat out-of-range values as maximal ones. This is consistent with how "sleep" works. And this way, "timeout 999999999999999999d FOO" and "timeout 4.5 foo" are more likely to do what the user wants. * src/timeout.c: Include c-strtod.h and xstrtod.h, not xstrtol.h. (apply_time_suffix): Change it to the way sleep.c's time_suffix does things. Maybe this function (identical in both programs, other than its name) should be moved to a library? (parse_duration): Return a maximal value on overflow. Return unsigned int, not unsigned long. Allow fractions, which round up to the next integer value. * tests/misc/timeout-parameters: Adjust tests to match new behavior. Add a very large number.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/timeout-parameters16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/misc/timeout-parameters b/tests/misc/timeout-parameters
index 6e9152b96..56804a808 100755
--- a/tests/misc/timeout-parameters
+++ b/tests/misc/timeout-parameters
@@ -37,11 +37,23 @@ test $? = 125 || fail=1
# timeout overflow
timeout $UINT_OFLOW sleep 0
-test $? = 125 || fail=1
+test $? = 0 || fail=1
# timeout overflow
timeout $(expr $UINT_MAX / 86400 + 1)d sleep 0
-test $? = 125 || fail=1
+test $? = 0 || fail=1
+
+# timeout overflow
+timeout 999999999999999999999999999999999999999999999999999999999999d sleep 0
+test $? = 0 || fail=1
+
+# floating point notation
+timeout 2.34 sleep 0
+test $? = 0 || fail=1
+
+# floating point notation
+timeout 2.34e+5d sleep 0
+test $? = 0 || fail=1
# invalid signal spec
timeout --signal=invalid 1 sleep 0