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