diff --git a/test/libsinsp_e2e/sys_call_test.cpp b/test/libsinsp_e2e/sys_call_test.cpp index cd56bb25db8..5f465fe861d 100644 --- a/test/libsinsp_e2e/sys_call_test.cpp +++ b/test/libsinsp_e2e/sys_call_test.cpp @@ -132,17 +132,15 @@ TEST_F(sys_call_test, open_close) captured_event_callback_t callback = [&](const callback_param& param) { - if ((0 == strcmp(param.m_evt->get_name(), "open") || - 0 == strcmp(param.m_evt->get_name(), "openat")) && - param.m_evt->get_direction() == SCAP_ED_OUT) + if((0 == strcmp(param.m_evt->get_name(), "open") || 0 == strcmp(param.m_evt->get_name(), "openat") || + 0 == strcmp(param.m_evt->get_name(), "close")) && "/tmp" == param.m_evt->get_param_value_str("fd")) { - EXPECT_EQ("/tmp", param.m_evt->get_param_value_str("fd")); + callnum++; } - callnum++; }; ASSERT_NO_FATAL_FAILURE({ event_capture::run(test, callback, filter); }); - EXPECT_EQ(4, callnum); + EXPECT_EQ(2, callnum); } TEST_F(sys_call_test, open_close_dropping) @@ -169,13 +167,11 @@ TEST_F(sys_call_test, open_close_dropping) captured_event_callback_t callback = [&](const callback_param& param) { - if ((0 == strcmp(param.m_evt->get_name(), "open") || - 0 == strcmp(param.m_evt->get_name(), "openat")) && - param.m_evt->get_direction() == SCAP_ED_OUT) + if((0 == strcmp(param.m_evt->get_name(), "open") || 0 == strcmp(param.m_evt->get_name(), "openat") || + 0 == strcmp(param.m_evt->get_name(), "close")) && "/tmp" == param.m_evt->get_param_value_str("fd")) { - EXPECT_EQ("/tmp", param.m_evt->get_param_value_str("fd")); + callnum++; } - callnum++; }; before_close_t cleanup = [&](sinsp* inspector) @@ -184,7 +180,7 @@ TEST_F(sys_call_test, open_close_dropping) }; ASSERT_NO_FATAL_FAILURE({ event_capture::run(test, callback, filter, setup, cleanup); }); - EXPECT_EQ(4, callnum); + EXPECT_EQ(2, callnum); } TEST_F(sys_call_test, fcntl_getfd) @@ -294,7 +290,19 @@ TEST_F(sys_call_test, close_badfd) close(INT_MAX); }; - captured_event_callback_t callback = [&](const callback_param& param) { callnum++; }; + captured_event_callback_t callback = [&](const callback_param& param) + { + int fd = param.m_evt->get_param(0)->as(); + if(param.m_evt->get_direction() == SCAP_ED_IN && + (fd == -1 || fd == INT_MAX)) + { + callnum++; + } + else if(param.m_evt->get_direction() == SCAP_ED_OUT && fd == -EBADF) + { + callnum++; + } + }; ASSERT_NO_FATAL_FAILURE({ event_capture::run(test, callback, filter); }); EXPECT_EQ(4, callnum); @@ -320,7 +328,19 @@ TEST_F(sys_call_test, close_badfd_dropping) close(INT_MAX); }; - captured_event_callback_t callback = [&](const callback_param& param) { callnum++; }; + captured_event_callback_t callback = [&](const callback_param& param) + { + int fd = param.m_evt->get_param(0)->as(); + if(param.m_evt->get_direction() == SCAP_ED_IN && + (fd == -1 || fd == INT_MAX)) + { + callnum++; + } + else if(param.m_evt->get_direction() == SCAP_ED_OUT && fd == -EBADF) + { + callnum++; + } + }; before_close_t cleanup = [&](sinsp* inspector) {