diff options
author | Bin Meng <bin.meng@windriver.com> | 2022-08-02 15:52:00 +0800 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-09-02 15:54:47 +0400 |
commit | 0370f239ad14aeacc496775e241b9ef041df4374 (patch) | |
tree | c9c50117be99741dc4e556956ba8be18c2652587 /tests/unit/socket-helpers.c | |
parent | 120fa5e0e6ebacd811e4d830cff8a405806d305c (diff) |
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>
Diffstat (limited to 'tests/unit/socket-helpers.c')
-rw-r--r-- | tests/unit/socket-helpers.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c index 5af4de513b..eecadf3a3c 100644 --- a/tests/unit/socket-helpers.c +++ b/tests/unit/socket-helpers.c @@ -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; +} |