aboutsummaryrefslogtreecommitdiff
path: root/src/sp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-30 12:19:10 -0500
committerGarrett D'Amore <garrett@damore.org>2024-11-30 12:19:27 -0500
commit25873b4fad8a5afbf5c539a9b9bb9659ce43c02e (patch)
tree43db7fc1d1a2e0cf24b8af23d20885d213614892 /src/sp
parentcb8e9066edacbd0440df54672b426c44f102085f (diff)
downloadnng-25873b4fad8a5afbf5c539a9b9bb9659ce43c02e.tar.gz
nng-25873b4fad8a5afbf5c539a9b9bb9659ce43c02e.tar.bz2
nng-25873b4fad8a5afbf5c539a9b9bb9659ce43c02e.zip
tests: tcp test converted to NUTS
TCPv6 not done yet since that needs special work to be conditionalized. Also tcpsupp remains to be converted.
Diffstat (limited to 'src/sp')
-rw-r--r--src/sp/transport/tcp/tcp_test.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/sp/transport/tcp/tcp_test.c b/src/sp/transport/tcp/tcp_test.c
index 82abcae1..482d4ff4 100644
--- a/src/sp/transport/tcp/tcp_test.c
+++ b/src/sp/transport/tcp/tcp_test.c
@@ -238,8 +238,47 @@ test_tcp_recv_max(void)
NUTS_CLOSE(s1);
}
-NUTS_TESTS = {
+static void
+check_props_v4(nng_msg *msg)
+{
+ nng_pipe p;
+ size_t z;
+ nng_sockaddr la;
+ nng_sockaddr ra;
+ bool b;
+
+ p = nng_msg_get_pipe(msg);
+ NUTS_TRUE(nng_pipe_id(p) > 0);
+ NUTS_PASS(nng_pipe_get_addr(p, NNG_OPT_LOCADDR, &la));
+ NUTS_FAIL(nng_pipe_get_size(p, NNG_OPT_LOCADDR, &z), NNG_EBADTYPE);
+ NUTS_TRUE(la.s_family == NNG_AF_INET);
+ NUTS_TRUE(la.s_in.sa_port != 0);
+ NUTS_TRUE(la.s_in.sa_addr == htonl(0x7f000001));
+
+ NUTS_PASS(nng_pipe_get_addr(p, NNG_OPT_REMADDR, &ra));
+ NUTS_TRUE(ra.s_family == NNG_AF_INET);
+ NUTS_TRUE(ra.s_in.sa_port != 0);
+ NUTS_TRUE(ra.s_in.sa_addr == htonl(0x7f000001));
+ NUTS_TRUE(ra.s_in.sa_port != la.s_in.sa_port);
+ NUTS_FAIL(nng_pipe_get_size(p, NNG_OPT_REMADDR, &z), NNG_EBADTYPE);
+
+ NUTS_PASS(nng_pipe_get_bool(p, NNG_OPT_TCP_KEEPALIVE, &b));
+ NUTS_TRUE(b == false); // default
+
+ NUTS_PASS(nng_pipe_get_bool(p, NNG_OPT_TCP_NODELAY, &b));
+ NUTS_TRUE(b); // default
+}
+
+void
+test_tcp_props_v4(void)
+{
+ nuts_tran_msg_props("tcp4", check_props_v4);
+}
+NUTS_DECLARE_TRAN_TESTS(tcp)
+
+NUTS_TESTS = {
+ NUTS_INSERT_TRAN_TESTS(tcp),
{ "tcp wild card connect fail", test_tcp_wild_card_connect_fail },
{ "tcp wild card bind", test_tcp_wild_card_bind },
{ "tcp port zero bind", test_tcp_port_zero_bind },
@@ -249,5 +288,6 @@ NUTS_TESTS = {
{ "tcp keep alive option", test_tcp_keep_alive_option },
{ "tcp recv max", test_tcp_recv_max },
{ "tcp ipv6", test_tcp_ipv6 },
+ { "tcp props v4", test_tcp_props_v4 },
{ NULL, NULL },
};