Skip to content

Commit f189423

Browse files
authored
Rollup merge of #44647 - tmerr:fix-44645, r=dtolnay
Ensure tcp test case passes when disconnected from network net::tcp::tests::connect_timeout_unroutable fails when the network is unreachable, like on a laptop disconnected from wifi. Check for this error and allow the test to pass. Closes #44645
2 parents 7019666 + fcdd46e commit f189423

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/libstd/net/tcp.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1570,10 +1570,13 @@ mod tests {
15701570

15711571
#[test]
15721572
fn connect_timeout_unroutable() {
1573-
// this IP is unroutable, so connections should always time out.
1573+
// this IP is unroutable, so connections should always time out,
1574+
// provided the network is reachable to begin with.
15741575
let addr = "10.255.255.1:80".parse().unwrap();
15751576
let e = TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap_err();
1576-
assert_eq!(e.kind(), io::ErrorKind::TimedOut);
1577+
assert!(e.kind() == io::ErrorKind::TimedOut ||
1578+
e.kind() == io::ErrorKind::Other,
1579+
"bad error: {} {:?}", e, e.kind());
15771580
}
15781581

15791582
#[test]

0 commit comments

Comments
 (0)