diff --git a/userspace/libsinsp/test/events_net.ut.cpp b/userspace/libsinsp/test/events_net.ut.cpp index 8ca476c332..eaa82dfae6 100644 --- a/userspace/libsinsp/test/events_net.ut.cpp +++ b/userspace/libsinsp/test/events_net.ut.cpp @@ -216,10 +216,7 @@ TEST_F(sinsp_with_test_input, net_ipv6_multiple_connects) { open_inspector(); sinsp_evt* evt = NULL; - generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_INET6, - .type = SOCK_DGRAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET6, SOCK_DGRAM)); sockaddr_in6 client = test_utils::fill_sockaddr_in6(DEFAULT_CLIENT_PORT, DEFAULT_IPV6_CLIENT_STRING); @@ -424,10 +421,7 @@ TEST_F(sinsp_with_test_input, net_bind_listen_accept_ipv6) { open_inspector(); sinsp_evt* evt = NULL; - generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_INET6, - .type = SOCK_STREAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET6, SOCK_STREAM)); add_event_advance_ts(increasing_ts(), 1, @@ -602,10 +596,7 @@ TEST_F(sinsp_with_test_input, net_connect_enter_event_is_empty) { sinsp_fdinfo* fdinfo = NULL; char ipv4_string[DEFAULT_IP_STRING_SIZE]; - generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_INET, - .type = SOCK_DGRAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET, SOCK_DGRAM)); sockaddr_in client = test_utils::fill_sockaddr_in(DEFAULT_CLIENT_PORT, DEFAULT_IPV4_CLIENT_STRING); @@ -703,10 +694,7 @@ TEST_F(sinsp_with_test_input, net_connect_enter_event_is_missing) { sinsp_fdinfo* fdinfo = NULL; char ipv4_string[DEFAULT_IP_STRING_SIZE]; - generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_INET, - .type = SOCK_DGRAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET, SOCK_DGRAM)); int port_client = 12; std::string ipv4_client = "80.9.11.45"; @@ -768,10 +756,7 @@ TEST_F(sinsp_with_test_input, net_connect_enter_event_is_missing_wo_fd_param_exi open_inspector(); sinsp_evt* evt = NULL; - generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_INET, - .type = SOCK_DGRAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET, SOCK_DGRAM)); int port_client = 12; std::string ipv4_client = "80.9.11.45"; diff --git a/userspace/libsinsp/test/events_param.ut.cpp b/userspace/libsinsp/test/events_param.ut.cpp index 38b695de3b..fed05dba5e 100644 --- a/userspace/libsinsp/test/events_param.ut.cpp +++ b/userspace/libsinsp/test/events_param.ut.cpp @@ -406,10 +406,7 @@ TEST_F(sinsp_with_test_input, enumparams) { sinsp_evt* evt = NULL; /* `PPME_SOCKET_SOCKET_X` is a simple event that uses a PT_ENUMFLAGS32 (param 1) */ - evt = generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_UNIX, - .type = SOCK_DGRAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET, SOCK_DGRAM)); ASSERT_EQ(evt->get_param(1)->as(), PPM_AF_UNIX); diff --git a/userspace/libsinsp/test/filterchecks/mock.cpp b/userspace/libsinsp/test/filterchecks/mock.cpp index 0021ec662c..27fe0d4143 100644 --- a/userspace/libsinsp/test/filterchecks/mock.cpp +++ b/userspace/libsinsp/test/filterchecks/mock.cpp @@ -342,10 +342,7 @@ TEST_F(sinsp_with_test_input, check_some_fd_fields) { open_inspector(); // Prepare the setup to extract something from the filter checks `fd.cip`. - generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_INET6, - .type = SOCK_DGRAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_INET6, SOCK_DGRAM)); sockaddr_in6 client = test_utils::fill_sockaddr_in6(DEFAULT_CLIENT_PORT, DEFAULT_IPV6_CLIENT_STRING); diff --git a/userspace/libsinsp/test/parsers/parse_connect.cpp b/userspace/libsinsp/test/parsers/parse_connect.cpp index 76a8b7b2fc..200effa784 100644 --- a/userspace/libsinsp/test/parsers/parse_connect.cpp +++ b/userspace/libsinsp/test/parsers/parse_connect.cpp @@ -27,10 +27,8 @@ TEST_F(sinsp_with_test_input, CONNECT_parse_unix_socket) { add_default_init_thread(); open_inspector(); - auto evt = generate_socket_x_event(sinsp_test_input::socket_params{ - .domain = PPM_AF_UNIX, - .type = SOCK_STREAM, - }); + generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_UNIX, SOCK_STREAM)); + auto fdinfo = evt->get_fd_info(); ASSERT_TRUE(fdinfo); ASSERT_TRUE(fdinfo->is_unix_socket()); diff --git a/userspace/libsinsp/test/sinsp_with_test_input.h b/userspace/libsinsp/test/sinsp_with_test_input.h index 4cf59175e9..6363ff36b8 100644 --- a/userspace/libsinsp/test/sinsp_with_test_input.h +++ b/userspace/libsinsp/test/sinsp_with_test_input.h @@ -57,6 +57,18 @@ struct socket_params { uint32_t domain = PPM_AF_INET; uint32_t type = SOCK_STREAM; uint32_t proto = 0; + + socket_params() { + domain = PPM_AF_INET; + type = SOCK_STREAM; + proto = 0; + }; + + socket_params(uint32_t d, uint32_t t): domain(d), type(t) { + domain = d; + type = t; + proto = 0; + }; }; struct fd_info_fields {