about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-17 15:14:52 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-17 17:26:44 -0800
commitf807b6a61e7f1fb0645a4f58f874292214d65907 (patch)
tree87a2c404ddfeb56b3d35d9fde5d78548fe441036
parent02c276175af6caeeb0bc41f7c3c5d3bc79db6359 (diff)
parent9eeaa3c78694ec593450e5dd96a5f3fa10afd434 (diff)
downloadrust-f807b6a61e7f1fb0645a4f58f874292214d65907.tar.gz
rust-f807b6a61e7f1fb0645a4f58f874292214d65907.zip
rollup merge of #22440: semarie/openbsd-connect_error
The `connect_error` test check if connecting to "0.0.0.0:1" works (it
shouldn't). And in case of error, the test expects a `ConnectionRefused`
error.

Under OpenBSD, trying to connect to "0.0.0.0" isn't a `ConnectionRefused`:
it is an `InvalidInput` error.

The patch allow the error to be `ConnectionRefused` or `InvalidInput`.

Another possibility is to check connecting to "127.0.0.1:1" and expects only `ConnectionRefused` error.
-rw-r--r--src/libstd/net/tcp.rs3
-rw-r--r--src/libstd/old_io/net/tcp.rs4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs
index 50eafdfc5c2..01c005bd8a6 100644
--- a/src/libstd/net/tcp.rs
+++ b/src/libstd/net/tcp.rs
@@ -247,7 +247,8 @@ mod tests {
     fn connect_error() {
         match TcpStream::connect("0.0.0.0:1") {
             Ok(..) => panic!(),
-            Err(e) => assert_eq!(e.kind(), ErrorKind::ConnectionRefused),
+            Err(e) => assert!((e.kind() == ErrorKind::ConnectionRefused)
+                              || (e.kind() == ErrorKind::InvalidInput)),
         }
     }
 
diff --git a/src/libstd/old_io/net/tcp.rs b/src/libstd/old_io/net/tcp.rs
index ebf7f6cc0f2..45dba733535 100644
--- a/src/libstd/old_io/net/tcp.rs
+++ b/src/libstd/old_io/net/tcp.rs
@@ -494,6 +494,7 @@ mod test {
     use old_io::{EndOfFile, TimedOut, ShortWrite, IoError};
     use old_io::{ConnectionRefused, BrokenPipe, ConnectionAborted};
     use old_io::{ConnectionReset, NotConnected, PermissionDenied, OtherIoError};
+    use old_io::{InvalidInput};
     use old_io::{Acceptor, Listener};
 
     // FIXME #11530 this fails on android because tests are run as root
@@ -510,7 +511,8 @@ mod test {
     fn connect_error() {
         match TcpStream::connect("0.0.0.0:1") {
             Ok(..) => panic!(),
-            Err(e) => assert_eq!(e.kind, ConnectionRefused),
+            Err(e) => assert!((e.kind == ConnectionRefused)
+                              || (e.kind == InvalidInput)),
         }
     }