Skip to content

Commit

Permalink
Ensure tcp test case passes when disconnected from network
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tmerr committed Sep 17, 2017
1 parent b492405 commit fcdd46e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/libstd/net/tcp.rs
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 fcdd46e

Please sign in to comment.