Fix nondeterministic failures in poll_oneoff_stdio.

Adjust this test so that it tolerates poll_oneoff returning that both a
timeout occurred and an input is ready for reading, at the same time.
This commit is contained in:
Dan Gohman
2021-03-15 10:48:02 -07:00
parent a46daa7eee
commit 2d3f2adf04

View File

@@ -46,8 +46,8 @@ unsafe fn test_stdin_read() {
let out = poll_oneoff_impl(&r#in).unwrap(); let out = poll_oneoff_impl(&r#in).unwrap();
// The result should be either a timeout, or that stdin is ready for reading. // The result should be either a timeout, or that stdin is ready for reading.
// Both are valid behaviors that depend on the test environment. // Both are valid behaviors that depend on the test environment.
assert_eq!(out.len(), 1, "should return 1 event"); assert!(out.len() >= 1, "should return at least 1 event");
let event = &out[0]; for event in out {
if event.r#type == wasi::EVENTTYPE_CLOCK { if event.r#type == wasi::EVENTTYPE_CLOCK {
assert_errno!(event.error, wasi::ERRNO_SUCCESS); assert_errno!(event.error, wasi::ERRNO_SUCCESS);
assert_eq!( assert_eq!(
@@ -63,6 +63,7 @@ unsafe fn test_stdin_read() {
} else { } else {
panic!("unexpected event type {}", event.r#type); panic!("unexpected event type {}", event.r#type);
} }
}
} }
unsafe fn test_stdout_stderr_write() { unsafe fn test_stdout_stderr_write() {