Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

wasi p2 tcp busy poll test: fix condition changed by tokio upgrade (#14998)

Pat Hickey35cb86d0bc0c
diff --git a/crates/test-programs/src/bin/p2_tcp_busy_poll.rs b/crates/test-programs/src/bin/p2_tcp_busy_poll.rs
index 2a0f834c7c..bc73f1c0d5 100644
--- a/crates/test-programs/src/bin/p2_tcp_busy_poll.rs
+++ b/crates/test-programs/src/bin/p2_tcp_busy_poll.rs
@@ -30,7 +30,8 @@ fn test_tcp_busy_poll(family: IpAddressFamily, address: IpSocketAddress) {
let (_accepted, rx, _tx) = listener.blocking_accept().unwrap();
let rx_ready = rx.subscribe();
let mut counter = 0;
- loop {
+ let mut data = Vec::new();
+ while data.len() < message.len() {
let zero_wait = monotonic_clock::subscribe_duration(0);
if counter > 1_000_000 {
panic!("socket still not ready!");
@@ -38,13 +39,13 @@ fn test_tcp_busy_poll(family: IpAddressFamily, address: IpSocketAddress) {
let ready = poll::poll(&[&zero_wait, &rx_ready]);
if ready.contains(&1) {
- break;
+ let remaining = message.len() - data.len();
+ data.extend(rx.read(remaining.try_into().unwrap()).unwrap());
}
counter += 1;
}
- let data = rx.read(message.len().try_into().unwrap()).unwrap();
- assert_eq!(data, message); // Not guaranteed to work but should work in practice.
+ assert_eq!(data, message);
}
}