From a1c3d169400b695219d154d9d7b5ee6002aa2919 Mon Sep 17 00:00:00 2001 From: Andrea Terzolo Date: Wed, 18 Dec 2024 12:12:29 +0100 Subject: [PATCH] fix tests Signed-off-by: Andrea Terzolo --- test/e2e/tests/test_network/test_network.py | 2 +- userspace/libsinsp/parsers.cpp | 10 ++++++---- userspace/libsinsp/test/parsers/parse_connect.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/e2e/tests/test_network/test_network.py b/test/e2e/tests/test_network/test_network.py index ae64990d8c0..2160ec92078 100644 --- a/test/e2e/tests/test_network/test_network.py +++ b/test/e2e/tests/test_network/test_network.py @@ -40,7 +40,7 @@ def expected_events(origin: dict, destination: dict) -> list: "proc.exe": "curl", }, { "container.id": origin['id'], - "evt.args": "fd=3(<4>)", + "evt.args": "fd=3(<4>) domain=2(AF_INET) type=1 proto=0", "evt.category": "net", "evt.type": "socket", "fd.name": "", diff --git a/userspace/libsinsp/parsers.cpp b/userspace/libsinsp/parsers.cpp index 30e601a27a6..2e9e7ffff2d 100644 --- a/userspace/libsinsp/parsers.cpp +++ b/userspace/libsinsp/parsers.cpp @@ -2591,10 +2591,12 @@ inline void sinsp_parser::add_socket(sinsp_evt *evt, #endif domain != 17) // AF_PACKET, used for packet capture { - // - // IPv6 will go here - // - ASSERT(false); + // A possible case in which we enter here is when we reproduce an old scap-file like + // `scap_2013` in our tests. In this case, we have only the exit event of the socket + // `evt_num=5` because we have just started the capture so we lost the enter event. The + // result produced by our scap-file converter is a socket with (domain=0, type=0, + // protocol=0). + fdi->m_type == SCAP_FD_UNKNOWN } } diff --git a/userspace/libsinsp/test/parsers/parse_connect.cpp b/userspace/libsinsp/test/parsers/parse_connect.cpp index b1886f0f106..47dfa09c4f1 100644 --- a/userspace/libsinsp/test/parsers/parse_connect.cpp +++ b/userspace/libsinsp/test/parsers/parse_connect.cpp @@ -27,7 +27,7 @@ TEST_F(sinsp_with_test_input, CONNECT_parse_unix_socket) { add_default_init_thread(); open_inspector(); - generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_UNIX, SOCK_STREAM)); + auto evt = generate_socket_x_event(sinsp_test_input::socket_params(PPM_AF_UNIX, SOCK_STREAM)); auto fdinfo = evt->get_fd_info(); ASSERT_TRUE(fdinfo);