Skip to content

Commit a00ede9

Browse files
committed
fix issue tokio-rs#1080, re-enabled and fixed UDP tests failing on Windows. One tests needed to have interests reregistered by calling a blocking recv. Another tests needed a Windows specific assert error message.
Signed-off-by: Daniel Tacalau <[email protected]>
1 parent 2972f2b commit a00ede9

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

tests/udp_socket.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ fn reconnect_udp_socket_sending() {
288288
}
289289

290290
#[test]
291-
#[cfg_attr(windows, ignore = "fails on Windows, see #1080")]
292291
fn reconnect_udp_socket_receiving() {
293292
let (mut poll, mut events) = init_with_poll();
294293

@@ -334,7 +333,11 @@ fn reconnect_udp_socket_receiving() {
334333
let mut buf = [0; 20];
335334
expect_read!(socket1.recv(&mut buf), DATA1);
336335

336+
//this will reregister socket1 resetting the interests
337+
assert_would_block(socket1.recv(&mut buf));
338+
337339
socket1.connect(address3).unwrap();
340+
338341
checked_write!(socket3.send(DATA2));
339342

340343
expect_events(
@@ -343,12 +346,16 @@ fn reconnect_udp_socket_receiving() {
343346
vec![ExpectEvent::new(ID1, Interests::READABLE)],
344347
);
345348

346-
// Read only a part of the data.
347-
let max = 4;
348-
expect_read!(socket1.recv(&mut buf[..max]), &DATA2[..max]);
349+
// Read all data.
350+
// On Windows, reading part of data returns error WSAEMSGSIZE (10040).
351+
expect_read!(socket1.recv(&mut buf), DATA2);
352+
353+
//this will reregister socket1 resetting the interests
354+
assert_would_block(socket1.recv(&mut buf));
349355

350356
// Now connect back to socket 2, dropping the unread data.
351357
socket1.connect(address2).unwrap();
358+
352359
checked_write!(socket2.send(DATA2));
353360

354361
expect_events(
@@ -365,7 +372,6 @@ fn reconnect_udp_socket_receiving() {
365372
}
366373

367374
#[test]
368-
#[cfg_attr(windows, ignore = "fails on Windows, see #1080")]
369375
fn unconnected_udp_socket_connected_methods() {
370376
let (mut poll, mut events) = init_with_poll();
371377

@@ -387,7 +393,15 @@ fn unconnected_udp_socket_connected_methods() {
387393
);
388394

389395
// Socket is unconnected, but we're using an connected method.
390-
assert_error(socket1.send(DATA1), "address required");
396+
if cfg!(not(target_os = "windows")) {
397+
assert_error(socket1.send(DATA1), "address required");
398+
}
399+
if cfg!(target_os = "windows") {
400+
assert_error(
401+
socket1.send(DATA1),
402+
"no address was supplied. (os error 10057)",
403+
);
404+
}
391405

392406
// Now send some actual data.
393407
checked_write!(socket1.send_to(DATA1, address2));

0 commit comments

Comments
 (0)