From 1c94702980f6fb1a1455f233406b4b5f312f385b Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Sat, 28 Jan 2023 09:53:21 +0900 Subject: [PATCH] tests: internal: network: prevent Infinite loop for no IPv6 environment (#6697) With no IPv6 supported environment, the current implementation causes infinite loop to wait ev events for network testing. We should prevent such protocol glitching issue on test to prevent stucking test cases. Signed-off-by: Hiroshi Hatake --- tests/internal/network.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/internal/network.c b/tests/internal/network.c index 3296bcb7972..d69d710da97 100644 --- a/tests/internal/network.c +++ b/tests/internal/network.c @@ -63,6 +63,10 @@ static void test_client_server(int is_ipv6) /* Create client and server sockets */ fd_client = flb_net_socket_create(family, FLB_TRUE); + if (errno == EAFNOSUPPORT) { + TEST_MSG("This protocol is not supported in this platform"); + return; + } TEST_CHECK(fd_client != -1); fd_server = flb_net_server(TEST_PORT, host); @@ -94,6 +98,10 @@ static void test_client_server(int is_ipv6) /* Event loop */ while (1) { + /* Break immediately for invalid status */ + if (fd_client == -1 || fd_server == -1) { + break; + } mk_event_wait(evl); mk_event_foreach(e_item, evl) { if (e_item->type == TEST_EV_CLIENT) {