about summary refs log tree commit diff
path: root/src/libstd/net/tcp.rs
diff options
context:
space:
mode:
authorTrevor Merrifield <trevorm42@gmail.com>2017-09-16 23:36:11 -0400
committerTrevor Merrifield <trevorm42@gmail.com>2017-09-17 00:16:30 -0400
commitfcdd46e534686c1cfb89e923610a3e9f4e2b9b7e (patch)
treefb11c383e14616be4b98d1fb3cf9c21d8f7719df /src/libstd/net/tcp.rs
parentb492405b1fcfb8243481582182a0232fb5177021 (diff)
downloadrust-fcdd46e534686c1cfb89e923610a3e9f4e2b9b7e.tar.gz
rust-fcdd46e534686c1cfb89e923610a3e9f4e2b9b7e.zip
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
Diffstat (limited to 'src/libstd/net/tcp.rs')
-rw-r--r--src/libstd/net/tcp.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs
index 943a83a95fb..aff9af66444 100644
--- a/src/libstd/net/tcp.rs
+++ b/src/libstd/net/tcp.rs
@@ -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]