From edc213d2c7f14a59916f56d38c10e17826ad7629 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Fri, 4 Apr 2025 12:15:16 +0200 Subject: [PATCH] test_timeout: Add tests for very short timeouts Note that unlike GNU coreutils, any value > 0 will not be treated as 0, even if the exponent is very large. --- tests/by-util/test_timeout.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/by-util/test_timeout.rs b/tests/by-util/test_timeout.rs index 20d3e8fef..12da849db 100644 --- a/tests/by-util/test_timeout.rs +++ b/tests/by-util/test_timeout.rs @@ -125,6 +125,24 @@ fn test_dont_overflow() { .no_output(); } +#[test] +fn test_dont_underflow() { + new_ucmd!() + .args(&[".0000000001", "sleep", "1"]) + .fails_with_code(124) + .no_output(); + new_ucmd!() + .args(&["1e-100", "sleep", "1"]) + .fails_with_code(124) + .no_output(); + // Unlike GNU coreutils, we underflow to 1ns for very short timeouts. + // https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77535 + new_ucmd!() + .args(&["1e-18172487393827593258", "sleep", "1"]) + .fails_with_code(124) + .no_output(); +} + #[test] fn test_negative_interval() { new_ucmd!()