From: Bin Meng <bin.meng@windriver.com>
Enable the following 3 test cases for Windows when AF_UNIX is available:
* test_io_channel_unix_sync
* test_io_channel_unix_async
* test_io_channel_unix_listen_cleanup
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
(no changes since v2)
Changes in v2:
- new patch: tests/unit: Update test-io-channel-socket.c for Windows
tests/unit/test-io-channel-socket.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/tests/unit/test-io-channel-socket.c b/tests/unit/test-io-channel-socket.c
index 6713886d02..ec5df32489 100644
--- a/tests/unit/test-io-channel-socket.c
+++ b/tests/unit/test-io-channel-socket.c
@@ -179,10 +179,12 @@ static void test_io_channel(bool async,
test_io_channel_setup_async(listen_addr, connect_addr,
&srv, &src, &dst);
+#ifndef _WIN32
g_assert(!passFD ||
qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS));
g_assert(!passFD ||
qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS));
+#endif
g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN));
g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN));
@@ -206,10 +208,12 @@ static void test_io_channel(bool async,
test_io_channel_setup_async(listen_addr, connect_addr,
&srv, &src, &dst);
+#ifndef _WIN32
g_assert(!passFD ||
qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS));
g_assert(!passFD ||
qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS));
+#endif
g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN));
g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN));
@@ -236,10 +240,12 @@ static void test_io_channel(bool async,
test_io_channel_setup_sync(listen_addr, connect_addr,
&srv, &src, &dst);
+#ifndef _WIN32
g_assert(!passFD ||
qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS));
g_assert(!passFD ||
qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS));
+#endif
g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN));
g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN));
@@ -263,10 +269,12 @@ static void test_io_channel(bool async,
test_io_channel_setup_sync(listen_addr, connect_addr,
&srv, &src, &dst);
+#ifndef _WIN32
g_assert(!passFD ||
qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS));
g_assert(!passFD ||
qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS));
+#endif
g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN));
g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN));
@@ -367,7 +375,7 @@ static void test_io_channel_ipv6_async(void)
}
-#ifndef _WIN32
+#ifdef CONFIG_AF_UNIX
static void test_io_channel_unix(bool async)
{
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
@@ -398,6 +406,7 @@ static void test_io_channel_unix_async(void)
return test_io_channel_unix(true);
}
+#ifndef _WIN32
static void test_io_channel_unix_fd_pass(void)
{
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
@@ -491,6 +500,7 @@ static void test_io_channel_unix_fd_pass(void)
}
g_free(fdrecv);
}
+#endif /* _WIN32 */
static void test_io_channel_unix_listen_cleanup(void)
{
@@ -588,13 +598,15 @@ int main(int argc, char **argv)
test_io_channel_ipv6_async);
}
-#ifndef _WIN32
+#ifdef CONFIG_AF_UNIX
g_test_add_func("/io/channel/socket/unix-sync",
test_io_channel_unix_sync);
g_test_add_func("/io/channel/socket/unix-async",
test_io_channel_unix_async);
+#ifndef _WIN32
g_test_add_func("/io/channel/socket/unix-fd-pass",
test_io_channel_unix_fd_pass);
+#endif
g_test_add_func("/io/channel/socket/unix-listen-cleanup",
test_io_channel_unix_listen_cleanup);
#endif /* _WIN32 */
--
2.34.1
Hi
On Sat, Jul 30, 2022 at 6:53 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> From: Bin Meng <bin.meng@windriver.com>
>
> Enable the following 3 test cases for Windows when AF_UNIX is available:
>
> * test_io_channel_unix_sync
> * test_io_channel_unix_async
> * test_io_channel_unix_listen_cleanup
>
The test should runtime-check the availability of AF_UNIX socket, and skip
those appropriately (not failing the test).
(for ex, in glib I wrote
https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/tests/gdbus-peer.c#L305)
> diff --git a/tests/unit/test-io-channel-socket.c
> b/tests/unit/test-io-channel-socket.c
> index 6713886d02..ec5df32489 100644
> --- a/tests/unit/test-io-channel-socket.c
> +++ b/tests/unit/test-io-channel-socket.c
> @@ -179,10 +179,12 @@ static void test_io_channel(bool async,
> test_io_channel_setup_async(listen_addr, connect_addr,
> &srv, &src, &dst);
>
> +#ifndef _WIN32
> g_assert(!passFD ||
> qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_FD_PASS));
> g_assert(!passFD ||
> qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_FD_PASS));
> +#endif
> g_assert(qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
> g_assert(qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
>
> @@ -206,10 +208,12 @@ static void test_io_channel(bool async,
> test_io_channel_setup_async(listen_addr, connect_addr,
> &srv, &src, &dst);
>
> +#ifndef _WIN32
> g_assert(!passFD ||
> qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_FD_PASS));
> g_assert(!passFD ||
> qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_FD_PASS));
> +#endif
> g_assert(qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
> g_assert(qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
>
> @@ -236,10 +240,12 @@ static void test_io_channel(bool async,
> test_io_channel_setup_sync(listen_addr, connect_addr,
> &srv, &src, &dst);
>
> +#ifndef _WIN32
> g_assert(!passFD ||
> qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_FD_PASS));
> g_assert(!passFD ||
> qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_FD_PASS));
> +#endif
> g_assert(qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
> g_assert(qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
>
> @@ -263,10 +269,12 @@ static void test_io_channel(bool async,
> test_io_channel_setup_sync(listen_addr, connect_addr,
> &srv, &src, &dst);
>
> +#ifndef _WIN32
> g_assert(!passFD ||
> qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_FD_PASS));
> g_assert(!passFD ||
> qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_FD_PASS));
> +#endif
> g_assert(qio_channel_has_feature(src,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
> g_assert(qio_channel_has_feature(dst,
> QIO_CHANNEL_FEATURE_SHUTDOWN));
>
> @@ -367,7 +375,7 @@ static void test_io_channel_ipv6_async(void)
> }
>
>
> -#ifndef _WIN32
> +#ifdef CONFIG_AF_UNIX
> static void test_io_channel_unix(bool async)
> {
> SocketAddress *listen_addr = g_new0(SocketAddress, 1);
> @@ -398,6 +406,7 @@ static void test_io_channel_unix_async(void)
> return test_io_channel_unix(true);
> }
>
> +#ifndef _WIN32
> static void test_io_channel_unix_fd_pass(void)
> {
> SocketAddress *listen_addr = g_new0(SocketAddress, 1);
> @@ -491,6 +500,7 @@ static void test_io_channel_unix_fd_pass(void)
> }
> g_free(fdrecv);
> }
> +#endif /* _WIN32 */
>
> static void test_io_channel_unix_listen_cleanup(void)
> {
> @@ -588,13 +598,15 @@ int main(int argc, char **argv)
> test_io_channel_ipv6_async);
> }
>
> -#ifndef _WIN32
> +#ifdef CONFIG_AF_UNIX
> g_test_add_func("/io/channel/socket/unix-sync",
> test_io_channel_unix_sync);
> g_test_add_func("/io/channel/socket/unix-async",
> test_io_channel_unix_async);
> +#ifndef _WIN32
> g_test_add_func("/io/channel/socket/unix-fd-pass",
> test_io_channel_unix_fd_pass);
> +#endif
> g_test_add_func("/io/channel/socket/unix-listen-cleanup",
> test_io_channel_unix_listen_cleanup);
> #endif /* _WIN32 */
>
The comments needs to be updated
--
Marc-André Lureau
© 2016 - 2026 Red Hat, Inc.