Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a4b045

Browse files
authoredOct 22, 2023
Unrolled build for rust-lang#116989
Rollup merge of rust-lang#116989 - ChrisDenton:skip-unsupported, r=Mark-Simulacrum Skip test if Unix sockets are unsupported Fixes rust-lang#116683 (comment) The test will be skipped if `AF_UNIX` is not supported. In that case [`WSASocketW` returns `WSAEAFNOSUPPORT`](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw#return-value). It will never skip the test when run in CI but maybe this is me being too defensive since the error code is narrowly scoped to just the af family parameter being unsupported? Also fixed a minor typo. r? `@Mark-Simulacrum`
2 parents 3932c87 + 46f68cc commit 9a4b045

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎library/std/src/fs/tests.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ fn windows_unix_socket_exists() {
17171717
let tmp = tmpdir();
17181718
let socket_path = tmp.join("socket");
17191719

1720-
// std doesn't current support Unix sockets on Windows so manually create one here.
1720+
// std doesn't currently support Unix sockets on Windows so manually create one here.
17211721
net::init();
17221722
unsafe {
17231723
let socket = c::WSASocketW(
@@ -1728,7 +1728,16 @@ fn windows_unix_socket_exists() {
17281728
0,
17291729
c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT,
17301730
);
1731-
assert_ne!(socket, c::INVALID_SOCKET);
1731+
// AF_UNIX is not supported on earlier versions of Windows,
1732+
// so skip this test if it's unsupported and we're not in CI.
1733+
if socket == c::INVALID_SOCKET {
1734+
let error = c::WSAGetLastError();
1735+
if env::var_os("CI").is_none() && error == c::WSAEAFNOSUPPORT {
1736+
return;
1737+
} else {
1738+
panic!("Creating AF_UNIX socket failed (OS error {error})");
1739+
}
1740+
}
17321741
let mut addr = c::SOCKADDR_UN { sun_family: c::AF_UNIX, sun_path: mem::zeroed() };
17331742
let bytes = socket_path.as_os_str().as_encoded_bytes();
17341743
addr.sun_path[..bytes.len()].copy_from_slice(bytes);

0 commit comments

Comments
 (0)
Please sign in to comment.