Skip to content

Commit

Permalink
tests: tcp test converted to NUTS
Browse files Browse the repository at this point in the history
TCPv6 not done yet since that needs special work to be conditionalized.
Also tcpsupp remains to be converted.
  • Loading branch information
gdamore committed Nov 30, 2024
1 parent cb8e906 commit 25873b4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 62 deletions.
42 changes: 41 additions & 1 deletion src/sp/transport/tcp/tcp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
};
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ add_nng_test(nonblock 60)
add_nng_test(scalability 20 ON)
add_nng_test(synch 5)
add_nng_test(tcpsupp 10)
add_nng_test(tcp 180)
add_nng_test(tcp6 60)
add_nng_test(ws 30)
add_nng_test(wss 30)
Expand Down
60 changes: 0 additions & 60 deletions tests/tcp.c

This file was deleted.

0 comments on commit 25873b4

Please sign in to comment.