aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-09 17:55:46 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-09 17:55:46 -0800
commit2e72f32c61e3c6227e654285890807b9ca8709cf (patch)
tree16537edb1267de36e6ac0f57c2017d08456dc72a /src
parent254b243358d89de560148a2c7f28aae4b3bd112f (diff)
downloadnng-2e72f32c61e3c6227e654285890807b9ca8709cf.tar.gz
nng-2e72f32c61e3c6227e654285890807b9ca8709cf.tar.bz2
nng-2e72f32c61e3c6227e654285890807b9ca8709cf.zip
tests: add a test of canceling TCP stream listener
This same test fails on Windows using IPC, and its good to know that it works flawlessly for TCP.
Diffstat (limited to 'src')
-rw-r--r--src/platform/tcp_stream_test.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/platform/tcp_stream_test.c b/src/platform/tcp_stream_test.c
index c1353e8a..b46d2d1c 100644
--- a/src/platform/tcp_stream_test.c
+++ b/src/platform/tcp_stream_test.c
@@ -130,7 +130,29 @@ test_tcp_stream(void)
nng_stream_free(c2);
}
+void
+test_tcp_listen_accept_cancel(void)
+{
+ nng_stream_listener *l;
+ char *addr;
+ nng_aio *aio;
+
+ nng_log_set_logger(nng_stderr_logger);
+ NUTS_ADDR(addr, "tcp");
+ NUTS_PASS(nng_aio_alloc(&aio, NULL, NULL));
+
+ // start a listening stream listener but do not call accept
+ NUTS_PASS(nng_stream_listener_alloc(&l, addr));
+ NUTS_PASS(nng_stream_listener_listen(l));
+ nng_stream_listener_accept(l, aio);
+ nng_msleep(100);
+ nng_aio_free(aio);
+ nng_stream_listener_close(l);
+ nng_stream_listener_free(l);
+}
+
NUTS_TESTS = {
{ "tcp stream", test_tcp_stream },
+ { "tcp stream listen accept cancel", test_tcp_listen_accept_cancel },
{ NULL, NULL },
};