Skip to content

Commit edc213d

Browse files
committed
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.
1 parent 3fc9c40 commit edc213d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/by-util/test_timeout.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ fn test_dont_overflow() {
125125
.no_output();
126126
}
127127

128+
#[test]
129+
fn test_dont_underflow() {
130+
new_ucmd!()
131+
.args(&[".0000000001", "sleep", "1"])
132+
.fails_with_code(124)
133+
.no_output();
134+
new_ucmd!()
135+
.args(&["1e-100", "sleep", "1"])
136+
.fails_with_code(124)
137+
.no_output();
138+
// Unlike GNU coreutils, we underflow to 1ns for very short timeouts.
139+
// https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77535
140+
new_ucmd!()
141+
.args(&["1e-18172487393827593258", "sleep", "1"])
142+
.fails_with_code(124)
143+
.no_output();
144+
}
145+
128146
#[test]
129147
fn test_negative_interval() {
130148
new_ucmd!()

0 commit comments

Comments
 (0)