tests/unit: Update test-io-channel-socket.c for Windows

Change to dynamically include the test cases by checking AF_UNIX
availability using a new helper socket_check_afunix_support().
With such changes testing on a Windows host can be covered as well.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220802075200.907360-5-bmeng.cn@gmail.com>
This commit is contained in:
Bin Meng 2022-08-02 15:52:00 +08:00 committed by Marc-André Lureau
parent 120fa5e0e6
commit 0370f239ad
3 changed files with 48 additions and 14 deletions

View file

@ -154,3 +154,19 @@ int socket_check_protocol_support(bool *has_ipv4, bool *has_ipv6)
return 0;
}
void socket_check_afunix_support(bool *has_afunix)
{
int fd;
fd = socket(PF_UNIX, SOCK_STREAM, 0);
closesocket(fd);
#ifdef _WIN32
*has_afunix = (fd != (int)INVALID_SOCKET);
#else
*has_afunix = (fd >= 0);
#endif
return;
}