Skip to content

Commit f807b6a

Browse files
committed
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.
2 parents 02c2761 + 9eeaa3c commit f807b6a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/libstd/net/tcp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ mod tests {
247247
fn connect_error() {
248248
match TcpStream::connect("0.0.0.0:1") {
249249
Ok(..) => panic!(),
250-
Err(e) => assert_eq!(e.kind(), ErrorKind::ConnectionRefused),
250+
Err(e) => assert!((e.kind() == ErrorKind::ConnectionRefused)
251+
|| (e.kind() == ErrorKind::InvalidInput)),
251252
}
252253
}
253254

src/libstd/old_io/net/tcp.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ mod test {
494494
use old_io::{EndOfFile, TimedOut, ShortWrite, IoError};
495495
use old_io::{ConnectionRefused, BrokenPipe, ConnectionAborted};
496496
use old_io::{ConnectionReset, NotConnected, PermissionDenied, OtherIoError};
497+
use old_io::{InvalidInput};
497498
use old_io::{Acceptor, Listener};
498499

499500
// FIXME #11530 this fails on android because tests are run as root
@@ -510,7 +511,8 @@ mod test {
510511
fn connect_error() {
511512
match TcpStream::connect("0.0.0.0:1") {
512513
Ok(..) => panic!(),
513-
Err(e) => assert_eq!(e.kind, ConnectionRefused),
514+
Err(e) => assert!((e.kind == ConnectionRefused)
515+
|| (e.kind == InvalidInput)),
514516
}
515517
}
516518

0 commit comments

Comments
 (0)