Skip to content

Commit 88795b1

Browse files
committed
tests: Add a test case for handling bracketed address
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 7b2be4c commit 88795b1

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/internal/network.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#define TEST_HOSTv4 "127.0.0.1"
1515
#define TEST_HOSTv6 "::1"
16+
#define TEST_HOSTv6_BRACKETED "[::1]"
1617
#define TEST_PORT "41322"
1718

1819
#define TEST_EV_CLIENT MK_EVENT_NOTIFICATION
@@ -159,8 +160,30 @@ void test_ipv6_client_server()
159160
test_client_server(FLB_TRUE);
160161
}
161162

163+
void test_ipv6_bracketed_listen()
164+
{
165+
flb_sockfd_t fd_server;
166+
167+
errno = 0;
168+
fd_server = flb_net_server(TEST_PORT, TEST_HOSTv6_BRACKETED,
169+
FLB_NETWORK_DEFAULT_BACKLOG_SIZE,
170+
FLB_FALSE);
171+
172+
if (fd_server == -1 && errno == EAFNOSUPPORT) {
173+
TEST_MSG("This protocol is not supported in this platform");
174+
return;
175+
}
176+
177+
TEST_CHECK(fd_server != -1);
178+
179+
if (fd_server != -1) {
180+
flb_socket_close(fd_server);
181+
}
182+
}
183+
162184
TEST_LIST = {
163185
{ "ipv4_client_server", test_ipv4_client_server},
164186
{ "ipv6_client_server", test_ipv6_client_server},
187+
{ "ipv6_bracketed_listen", test_ipv6_bracketed_listen},
165188
{ 0 }
166189
};

0 commit comments

Comments
 (0)