about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Neumann <mail@timnn.me>2017-09-17 13:19:15 +0200
committerGitHub <noreply@github.com>2017-09-17 13:19:15 +0200
commit7aefb6c3ef3cb964060c7dc104ab56dd83e5c9aa (patch)
treed133a8529fcb6321c18588973846062964f6c101 /src/libstd
parentd046421743bd2e3f26840abc6398912936960408 (diff)
parentfcdd46e534686c1cfb89e923610a3e9f4e2b9b7e (diff)
downloadrust-7aefb6c3ef3cb964060c7dc104ab56dd83e5c9aa.tar.gz
rust-7aefb6c3ef3cb964060c7dc104ab56dd83e5c9aa.zip
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
Diffstat (limited to 'src/libstd')
-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]