Skip to content

Commit 35c1465

Browse files
committed
make errno assertion less flaky
1 parent ed03ae9 commit 35c1465

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tokio/tests/uds_stream.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,17 @@ async fn epollhup() -> io::Result<()> {
406406
drop(listener);
407407

408408
let err = connect.await.unwrap_err();
409-
410-
// On illumos (and presumably other Solaris descendents), `connect(3SOCKET)`
411-
// returns `ECONNREFUSED` here rather than `ECONNRESET`.
412-
//
413-
// See: https://illumos.org/man/3SOCKET/connect
414-
let expected_errno = if cfg!(target_os = "illumos") || cfg!(target_os = "solaris") {
415-
io::ErrorKind::ConnectionRefused
416-
} else {
417-
io::ErrorKind::ConnectionReset
418-
};
419-
assert_eq!(err.kind(), expected_errno);
409+
let errno = err.kind();
410+
assert!(
411+
// As far as I can tell, whether we see ECONNREFUSED or ECONNRESET here
412+
// seems relatively inconsistent, at least on non-Linux operating
413+
// systems. The difference in meaning between these errnos is not
414+
// particularly well-defined, so let's just accept either.
415+
matches!(
416+
errno,
417+
io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionReset
418+
),
419+
"unexpected error kind: {errno:?} (expected ConnectionRefused or ConnectionReset)"
420+
);
420421
Ok(())
421422
}

0 commit comments

Comments
 (0)