Skip to content

Commit c7876c4

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 fb6dc3c commit c7876c4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/by-util/test_timeout.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ 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 small timeouts.
139+
new_ucmd!()
140+
.args(&["1e-18172487393827593258", "sleep", "1"])
141+
.fails_with_code(124)
142+
.no_output();
143+
}
144+
128145
#[test]
129146
fn test_negative_interval() {
130147
new_ucmd!()

0 commit comments

Comments
 (0)