Skip to content

Commit 6ca2baa

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

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/internal/network.c

Lines changed: 22 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,29 @@ 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+
fd_server = flb_net_server(TEST_PORT, TEST_HOSTv6_BRACKETED,
168+
FLB_NETWORK_DEFAULT_BACKLOG_SIZE,
169+
FLB_FALSE);
170+
171+
if (errno == EAFNOSUPPORT) {
172+
TEST_MSG("This protocol is not supported in this platform");
173+
return;
174+
}
175+
176+
TEST_CHECK(fd_server != -1);
177+
178+
if (fd_server != -1) {
179+
flb_socket_close(fd_server);
180+
}
181+
}
182+
162183
TEST_LIST = {
163184
{ "ipv4_client_server", test_ipv4_client_server},
164185
{ "ipv6_client_server", test_ipv6_client_server},
186+
{ "ipv6_bracketed_listen", test_ipv6_bracketed_listen},
165187
{ 0 }
166188
};

0 commit comments

Comments
 (0)