From 1701d8fea1865c80d6842b0ad3d6f3321969edea Mon Sep 17 00:00:00 2001 From: Roberto Scolaro Date: Fri, 20 Sep 2024 13:28:45 +0000 Subject: [PATCH] wip Signed-off-by: Roberto Scolaro --- test/libsinsp_e2e/event_capture.cpp | 57 ++++++----------------------- test/libsinsp_e2e/event_capture.h | 5 +-- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/test/libsinsp_e2e/event_capture.cpp b/test/libsinsp_e2e/event_capture.cpp index cf615c2872..7d6a06cc06 100644 --- a/test/libsinsp_e2e/event_capture.cpp +++ b/test/libsinsp_e2e/event_capture.cpp @@ -103,66 +103,31 @@ void event_capture::capture() { } } // End init synchronized section - bool signaled_start = false; sinsp_evt* event; - bool result = true; int32_t next_result = SCAP_SUCCESS; bool end_event = false; - while(!m_capture_stopped && !end_event && result && !::testing::Test::HasFatalFailure()) { + + m_capture_started = true; + m_condition_started.notify_one(); + + while(!end_event && !::testing::Test::HasFatalFailure()) { { std::scoped_lock inspector_next_lock(m_inspector_mutex); next_result = get_inspector()->next(&event); } - if(SCAP_SUCCESS == next_result) { - if(strcmp(event->get_name(), "close") == 0 && event->get_param(0)->as() == 8192) { + if(next_result == SCAP_SUCCESS) { + if(event->get_type() == PPME_SYSCALL_KILL_E && event->get_param(1)->as() == -1) { end_event = true; - continue; - } - result = handle_event(event); - if(m_mode != SINSP_MODE_NODRIVER && m_dump) { - dumper->dump(event); - } - } - if(!signaled_start) { - signaled_start = true; - m_capture_started = true; - m_condition_started.notify_one(); - } - } - - if(m_mode != SINSP_MODE_NODRIVER) { - uint32_t n_timeouts = 0; - while(result && !::testing::Test::HasFatalFailure()) { - { - std::scoped_lock inspector_next_lock(m_inspector_mutex); - next_result = get_inspector()->next(&event); - } - if(next_result == SCAP_TIMEOUT) { - n_timeouts++; - - if(n_timeouts < m_max_timeouts) { - continue; - } else { + if(m_capture_stopped) { break; } - } - - if(next_result == SCAP_FILTERED_EVENT) { continue; + } else { + handle_event(event); } - if(next_result != SCAP_SUCCESS) { - break; - } - if(m_dump) { + if(m_mode != SINSP_MODE_NODRIVER && m_dump) { dumper->dump(event); } - result = handle_event(event); - } - { - std::scoped_lock inspector_next_lock(m_inspector_mutex); - while(SCAP_SUCCESS == get_inspector()->next(&event)) { - // just consume the remaining events - } } } diff --git a/test/libsinsp_e2e/event_capture.h b/test/libsinsp_e2e/event_capture.h index 75462421f7..40df9cee25 100644 --- a/test/libsinsp_e2e/event_capture.h +++ b/test/libsinsp_e2e/event_capture.h @@ -158,10 +158,9 @@ class event_capture { if(!capturing.m_start_failed.load()) { run_function(capturing.get_inspector_handle()); - // This close is just used to be sure that all the events + // This kill is just used to be sure that all the events // created in the run_function were consumed. - close(8192); - capturing.stop_capture(); + kill(-1,-1); capturing.wait_for_capture_stop(); } else { std::unique_lock error_lookup_lock(capturing.m_object_state_mutex);