aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-18 22:22:25 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-18 22:22:25 -0800
commit73b3ed5a38cdd2312351ea8f19c3c89cbfc1154c (patch)
treee9734b4edb34bbac7c60b1fafcb8dff748687a0d /src
parent6499dd847ca8889ea0aa4a2fe934bcfff9466e60 (diff)
downloadnng-73b3ed5a38cdd2312351ea8f19c3c89cbfc1154c.tar.gz
nng-73b3ed5a38cdd2312351ea8f19c3c89cbfc1154c.tar.bz2
nng-73b3ed5a38cdd2312351ea8f19c3c89cbfc1154c.zip
TCPv6 test suite fixes for addresses.
We moved some of the tests out of the older Convey framework into the NUTS framework.
Diffstat (limited to 'src')
-rw-r--r--src/sp/transport/tcp/tcp_test.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/sp/transport/tcp/tcp_test.c b/src/sp/transport/tcp/tcp_test.c
index c80a259f..37321ac1 100644
--- a/src/sp/transport/tcp/tcp_test.c
+++ b/src/sp/transport/tcp/tcp_test.c
@@ -125,6 +125,42 @@ test_tcp_no_delay_option(void)
NUTS_CLOSE(s);
}
+static bool
+has_v6(void)
+{
+ nng_sockaddr sa;
+ nng_udp *u;
+ int rv;
+
+ sa.s_in6.sa_family = NNG_AF_INET6;
+ sa.s_in6.sa_port = 0;
+ memset(sa.s_in6.sa_addr, 0, 16);
+ sa.s_in6.sa_addr[15] = 1;
+
+ rv = nng_udp_open(&u, &sa);
+ if (rv == 0) {
+ nng_udp_close(u);
+ }
+ return (rv == 0 ? 1 : 0);
+}
+
+void
+test_tcp_ipv6(void)
+{
+ if (!has_v6()) {
+ NUTS_SKIP("No IPv6 support");
+ return;
+ }
+ nng_socket s;
+ NUTS_OPEN(s);
+ // this should have a [::1] bracket
+ NUTS_FAIL(nng_dial(s, "tcp://::1", NULL, 0), NNG_EINVAL);
+ NUTS_FAIL(nng_dial(s, "tcp://::1:5055", NULL, 0), NNG_EINVAL);
+ // this requires a port, but otherwise its ok, so address is invalid
+ NUTS_FAIL(nng_dial(s, "tcp://[::1]", NULL, 0), NNG_EADDRINVAL);
+ NUTS_CLOSE(s);
+}
+
void
test_tcp_keep_alive_option(void)
{
@@ -206,5 +242,6 @@ NUTS_TESTS = {
{ "tcp no delay option", test_tcp_no_delay_option },
{ "tcp keep alive option", test_tcp_keep_alive_option },
{ "tcp recv max", test_tcp_recv_max },
+ { "tcp ipv6", test_tcp_ipv6 },
{ NULL, NULL },
};