aboutsummaryrefslogtreecommitdiff
path: root/src/platform/ipc_stream_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-30 15:39:50 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-30 15:47:04 -0800
commit7f7a8194a60e9f5883866dd8b8c22d4576fc1abc (patch)
treecbd7af87601a5f68e84ca9dcaad890881dec62db /src/platform/ipc_stream_test.c
parenta74d853241fa21ef4b6352fd39c25b4d4c6a4ab3 (diff)
downloadnng-7f7a8194a60e9f5883866dd8b8c22d4576fc1abc.tar.gz
nng-7f7a8194a60e9f5883866dd8b8c22d4576fc1abc.tar.bz2
nng-7f7a8194a60e9f5883866dd8b8c22d4576fc1abc.zip
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!
Diffstat (limited to 'src/platform/ipc_stream_test.c')
-rw-r--r--src/platform/ipc_stream_test.c32
1 files changed, 32 insertions, 0 deletions
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
@@ -108,6 +108,37 @@ test_ipc_stream(void)
}
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)
{
#if defined(NNG_PLATFORM_POSIX)
@@ -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 },