Skip to content

Commit

Permalink
new(libsinsp_e2e): add fs, process and threadinfo tests
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo authored and poiana committed Mar 27, 2024
1 parent a9a9c99 commit df7f57a
Show file tree
Hide file tree
Showing 5 changed files with 2,969 additions and 8 deletions.
5 changes: 4 additions & 1 deletion test/libsinsp_e2e/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ add_executable(libsinsp_e2e_tests
container/container_cgroup.cpp
container/docker_utils.cpp
event_capture.cpp
fs.cpp
main.cpp
paths.cpp
paths.cpp
process.cpp
subprocess.cpp
sys_call_test.cpp
threadinfo.cpp
thread_state.cpp
)

Expand Down
27 changes: 20 additions & 7 deletions test/libsinsp_e2e/event_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,23 @@ void event_capture::capture()
int32_t next_result = SCAP_SUCCESS;
while (!m_capture_stopped && result && !::testing::Test::HasFatalFailure())
{
if (SCAP_SUCCESS == (next_result = get_inspector()->next(&event)))
{
std::scoped_lock inspector_next_lock(m_inspector_mutex);
next_result = get_inspector()->next(&event);
}
if (SCAP_SUCCESS == next_result)
{
result = handle_event(event);
if (m_mode != SINSP_MODE_NODRIVER)
{
dumper->dump(event);
}
}
if (!signaled_start)
{
signaled_start = true;
{
std::unique_lock<std::mutex> lock(m_object_state_mutex);
m_capture_started = true;
m_condition_started.notify_one();
}
m_capture_started = true;
m_condition_started.notify_one();
}
}

Expand All @@ -131,7 +136,10 @@ void event_capture::capture()
uint32_t n_timeouts = 0;
while (result && !::testing::Test::HasFatalFailure())
{
next_result = get_inspector()->next(&event);
{
std::scoped_lock inspector_next_lock(m_inspector_mutex);
next_result = get_inspector()->next(&event);
}
if (next_result == SCAP_TIMEOUT)
{
n_timeouts++;
Expand Down Expand Up @@ -172,6 +180,11 @@ void event_capture::capture()
m_before_close(get_inspector());

get_inspector()->stop_capture();
if (m_mode != SINSP_MODE_NODRIVER)
{
dumper->close();
}

m_capture_stopped = true;
m_condition_stopped.notify_one();
} // End teardown synchronized section
Expand Down
Loading

0 comments on commit df7f57a

Please sign in to comment.