From 7f7a8194a60e9f5883866dd8b8c22d4576fc1abc Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 30 Dec 2024 15:39:50 -0800 Subject: ipc test: add a case for IPC that never connects This involved test-specific hacks, since connect() for UNIX domain sockets always completes synchronously one way or the other, even though it is documented that it might not. This found a bug, with an uninitialized poll FD as well! --- src/platform/ipc_stream_test.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/platform/ipc_stream_test.c') diff --git a/src/platform/ipc_stream_test.c b/src/platform/ipc_stream_test.c index 7e5e7701..fb3bc493 100644 --- a/src/platform/ipc_stream_test.c +++ b/src/platform/ipc_stream_test.c @@ -107,6 +107,37 @@ test_ipc_stream(void) nng_stream_free(c2); } +void +test_ipc_no_connect(void) +{ +#ifdef NNG_PLATFORM_POSIX + nng_stream_dialer *d = NULL; + nng_stream_listener *l = NULL; + char *url; + nng_aio *daio = NULL; + + NUTS_ADDR(url, "ipc"); + NUTS_PASS(nng_aio_alloc(&daio, NULL, NULL)); + + NUTS_PASS(nng_stream_listener_alloc(&l, url)); + NUTS_PASS(nng_stream_listener_listen(l)); + nng_aio_set_timeout(daio, 100); + + NUTS_PASS(nng_stream_dialer_alloc(&d, url)); + NUTS_PASS(nng_stream_dialer_set_bool(d, "test-no-connect", true)); + nng_stream_dialer_dial(d, daio); + + nng_aio_wait(daio); + NUTS_FAIL(nng_aio_result(daio), NNG_ETIMEDOUT); + + nng_aio_free(daio); + nng_stream_dialer_free(d); + nng_stream_listener_free(l); +#else + NUTS_SKIP("Not POSIX"); +#endif +} + void test_ipc_listen_activation(void) { @@ -290,6 +321,7 @@ test_ipc_listen_activation_bad_arg(void) NUTS_TESTS = { { "ipc stream", test_ipc_stream }, + { "ipc no connect", test_ipc_no_connect }, { "ipc socket activation", test_ipc_listen_activation }, { "ipc socket activation busy", test_ipc_listen_activation_busy }, { "ipc socket activation closed", test_ipc_listen_activation_closed }, -- cgit v1.2.3-70-g09d2