Skip to content

Commit

Permalink
Rollup merge of rust-lang#44647 - tmerr:fix-44645, r=dtolnay
Browse files Browse the repository at this point in the history
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 rust-lang#44645
  • Loading branch information
TimNN authored Sep 17, 2017
2 parents dfbf8e3 + fcdd46e commit 7e08a23
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1570,10 +1570,13 @@ mod tests {

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

#[test]
Expand Down

0 comments on commit 7e08a23

Please sign in to comment.