make errno assertion less flaky

This commit is contained in:
Eliza Weisman
2024-08-14 11:34:29 -07:00
parent ed03ae90a9
commit 35c1465555
+12 -11
View File
@@ -406,16 +406,17 @@ async fn epollhup() -> io::Result<()> {
drop(listener); drop(listener);
let err = connect.await.unwrap_err(); let err = connect.await.unwrap_err();
let errno = err.kind();
// On illumos (and presumably other Solaris descendents), `connect(3SOCKET)` assert!(
// returns `ECONNREFUSED` here rather than `ECONNRESET`. // As far as I can tell, whether we see ECONNREFUSED or ECONNRESET here
// // seems relatively inconsistent, at least on non-Linux operating
// See: https://illumos.org/man/3SOCKET/connect // systems. The difference in meaning between these errnos is not
let expected_errno = if cfg!(target_os = "illumos") || cfg!(target_os = "solaris") { // particularly well-defined, so let's just accept either.
io::ErrorKind::ConnectionRefused matches!(
} else { errno,
io::ErrorKind::ConnectionReset io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionReset
}; ),
assert_eq!(err.kind(), expected_errno); "unexpected error kind: {errno:?} (expected ConnectionRefused or ConnectionReset)"
);
Ok(()) Ok(())
} }