Skip to content

Commit 56f3f40

Browse files
authored
tests: handle ECONNREFUSED in uds_stream::epollhup (#6778)
## Motivation Currently, the test `uds_stream::epollhup` expects that a `UdsStream::connect` future to a Unix socket which is closed by the accept side to always fail with `io::ErrorKind::ConnectionReset`. On illumos, and potentially other systems, it instead fails with `io::ErrorKind::ConnectionRefused`. This was discovered whilst adding an illumos CI job in PR #6769. See: #6769 (comment) ## Solution This commit changes the test to accept either `ConenctionReset` or `ConnectionRefused`. This way, we are more tolerant of different operating systems which may decide to return slightly different errnos here. Both ECONNREFUSED and ECONNRESET seem reasonable to expect in this situation, although arguably, ECONNREFUSED is actually more correct: the acceptor did not accept the connection at all, which seems like "refusing" it to me...
1 parent 2d697fc commit 56f3f40

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tokio/tests/uds_stream.rs

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

408408
let err = connect.await.unwrap_err();
409-
assert_eq!(err.kind(), io::ErrorKind::ConnectionReset);
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+
);
410421
Ok(())
411422
}

0 commit comments

Comments
 (0)