]> git.lizzy.rs Git - rust.git/commitdiff
openbsd: adapt connect_error test
authorSébastien Marie <semarie@users.noreply.github.com>
Tue, 17 Feb 2015 10:11:53 +0000 (11:11 +0100)
committerSébastien Marie <semarie@users.noreply.github.com>
Tue, 17 Feb 2015 10:11:53 +0000 (11:11 +0100)
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.

src/libstd/net/tcp.rs
src/libstd/old_io/net/tcp.rs

index 50eafdfc5c2389677aa0cd6cb6c5dcf39fc4b98d..01c005bd8a60ebe36b9ac22fc099d0f1b0e35887 100644 (file)
@@ -247,7 +247,8 @@ fn bind_error() {
     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)),
         }
     }
 
index ebf7f6cc0f2a9e6b4d256033ef1669e755827cfc..45dba733535647ecb0f32a1f454587175e07ca41 100644 (file)
@@ -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 @@ fn bind_error() {
     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)),
         }
     }