Browse Source

Fix a flaky poll_oneoff test (#6577)

This commit fixes a test that has failed on CI and seems flaky. This
test asserts that stderr/stdout are writable and that a 200ms timeout
does not elapse when calculating this. The implementation, on Windows at
least, of `poll_oneoff` always reports stdout/stderr as "ready for
write" meaning that this test should trivially pass. The flakiness comes
from the timeout parameter where apparently sometimes on CI the
determination of this takes more than 200ms. This means that the timer
subscription may or may not fire depending on the timing of the test,
and currently the test always fails if the timeout subscription fires.

This commit updates the test to store whether a timeout has passed and
only fail if `poll_oneoff` is attempted when the timeout has already
elapsed. This will allow the timeout to fire so long as the two streams
are considered writable at the same time, achieving the desired result
of the test to assert that, without timing out both stdout and stderr
are considered writable.
pull/6615/head
Alex Crichton 1 year ago
committed by GitHub
parent
commit
143a83888f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      crates/test-programs/wasi-tests/src/bin/poll_oneoff_stdio.rs

8
crates/test-programs/wasi-tests/src/bin/poll_oneoff_stdio.rs

@ -103,15 +103,17 @@ unsafe fn test_stdout_stderr_write() {
},
},
};
let mut timed_out = false;
while !writable.is_empty() {
if timed_out {
panic!("timed out with the following pending subs: {:?}", writable)
}
let mut subs = writable_subs(&writable);
subs.push(clock.clone());
let out = poll_oneoff_impl(&subs).unwrap();
for event in out {
match event.userdata {
CLOCK_ID => {
panic!("timed out with the following pending subs: {:?}", writable)
}
CLOCK_ID => timed_out = true,
ud => {
if let Some(_) = writable.remove(&ud) {
assert_eq!(event.type_, wasi::EVENTTYPE_FD_WRITE);

Loading…
Cancel
Save