Skip to content

Commit

Permalink
chore(test/libsinsp_e2e): rename before_close to after_capture
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Jan 8, 2025
1 parent afbe598 commit b140f13
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions test/libsinsp_e2e/event_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ unsigned long event_capture::s_buffer_dim = DEFAULT_DRIVER_BUFFER_BYTES_DIM * 4;
event_capture::event_capture(captured_event_callback_t captured_event_callback,
before_open_t before_open,
before_capture_t before_capture,
after_capture_t before_close,
after_capture_t after_capture,
event_filter_t filter,
uint32_t max_thread_table_size,
uint64_t thread_timeout_ns,
uint64_t inactive_thread_scan_time_ns) {
m_captured_event_callback = std::move(captured_event_callback);
m_before_open = std::move(before_open);
m_before_capture = std::move(before_capture);
m_after_capture = std::move(before_close);
m_after_capture = std::move(after_capture);
m_filter = std::move(filter);

m_eventfd = -1;
Expand Down
14 changes: 7 additions & 7 deletions test/libsinsp_e2e/event_capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class event_capture {
event_capture(captured_event_callback_t captured_event_callback,
before_open_t before_open,
before_capture_t before_capture,
after_capture_t before_close,
after_capture_t after_capture,
event_filter_t filter,
uint32_t max_thread_table_size,
uint64_t thread_timeout_ns,
Expand All @@ -84,15 +84,15 @@ class event_capture {
and, for any event that matches the filter,
calls captured_event_callback.
Before starting the capture, before_open is called.
After closing the capture, before_close is called.
After closing the capture, after_capture is called.
The default ppm_sc_set is the whole set minus `read` and `readv`.
*/
static void run(const run_callback_t& run_function,
captured_event_callback_t captured_event_callback,
event_filter_t filter,
before_open_t before_open = event_capture::do_nothing,
before_capture_t before_capture = event_capture::do_nothing,
after_capture_t before_close = event_capture::do_nothing,
after_capture_t after_capture = event_capture::do_nothing,
libsinsp::events::set<ppm_sc_code> sc_set = {},
uint32_t max_thread_table_size = 131072,
uint64_t thread_timeout_ns = (uint64_t)60 * 1000 * 1000 * 1000,
Expand All @@ -101,7 +101,7 @@ class event_capture {
event_capture capturing(std::move(captured_event_callback),
std::move(before_open),
std::move(before_capture),
std::move(before_close),
std::move(after_capture),
std::move(filter),
max_thread_table_size,
thread_timeout_ns,
Expand All @@ -124,15 +124,15 @@ class event_capture {
and, for any event that matches the filter,
calls captured_event_callback.
Before starting the capture, before_open is called.
After closing the capture, before_close is called.
After closing the capture, after_capture is called.
The default ppm_sc_set is the whole set minus `read` and `readv`.
*/
static void run(const run_callback_async_t& run_function,
captured_event_callback_t captured_event_callback,
event_filter_t filter,
before_open_t before_open = event_capture::do_nothing,
before_capture_t before_capture = event_capture::do_nothing,
after_capture_t before_close = event_capture::do_nothing,
after_capture_t after_capture = event_capture::do_nothing,
libsinsp::events::set<ppm_sc_code> sc_set = {},
uint32_t max_thread_table_size = 131072,
uint64_t thread_timeout_ns = (uint64_t)60 * 1000 * 1000 * 1000,
Expand All @@ -141,7 +141,7 @@ class event_capture {
event_capture capturing(std::move(captured_event_callback),
std::move(before_open),
std::move(before_capture),
std::move(before_close),
std::move(after_capture),
std::move(filter),
max_thread_table_size,
thread_timeout_ns,
Expand Down
8 changes: 4 additions & 4 deletions test/libsinsp_e2e/suppress_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void test_helper_quotactl(test_helper_args& hargs) {
}
};

after_capture_t before_close = [](sinsp* inspector) {
after_capture_t after_capture = [](sinsp* inspector) {
scap_stats st;

inspector->get_capture_stats(&st);
Expand All @@ -121,7 +121,7 @@ static void test_helper_quotactl(test_helper_args& hargs) {
filter,
event_capture::do_nothing,
before_open,
before_close,
after_capture,
{},
131072,
6000,
Expand Down Expand Up @@ -259,7 +259,7 @@ void suppress_types::run_test(std::vector<std::string> supp_syscalls) {
}
};

after_capture_t before_close = [&](sinsp* inspector) {
after_capture_t after_capture = [&](sinsp* inspector) {
for(auto sc : m_suppressed_syscalls) {
bool expect_exception = (sc >= PPM_SC_MAX);
bool caught_exception = false;
Expand Down Expand Up @@ -296,7 +296,7 @@ void suppress_types::run_test(std::vector<std::string> supp_syscalls) {
m_tid_filter,
event_capture::do_nothing,
before_open,
before_close);
after_capture);
});
EXPECT_EQ(m_expected_calls, callnum);
}
Expand Down
8 changes: 4 additions & 4 deletions test/libsinsp_e2e/sys_call_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ TEST_F(sys_call_test, getsetresuid_and_gid) {
}
};

after_capture_t before_close = [&](sinsp* inspector) {
after_capture_t after_capture = [&](sinsp* inspector) {
int result = 0;

result += setresuid(orig_uids[0], orig_uids[1], orig_uids[2]);
Expand All @@ -1485,7 +1485,7 @@ TEST_F(sys_call_test, getsetresuid_and_gid) {
filter,
event_capture::do_nothing,
event_capture::do_nothing,
before_close);
after_capture);
});
EXPECT_EQ(8, callnum);
}
Expand Down Expand Up @@ -2166,7 +2166,7 @@ TEST_F(sys_call_test, thread_lookup_live) {
}
};

after_capture_t before_close = [&](sinsp* inspector) {
after_capture_t after_capture = [&](sinsp* inspector) {
// close scap to maintain the num_consumers at exit == 0 assertion
// close_capture(scap, platform);
auto platform = (scap_linux_platform*)inspector->get_scap_platform();
Expand All @@ -2187,7 +2187,7 @@ TEST_F(sys_call_test, thread_lookup_live) {
};

ASSERT_NO_FATAL_FAILURE({
event_capture::run(test, callback, filter, event_capture::do_nothing, before_close);
event_capture::run(test, callback, filter, event_capture::do_nothing, after_capture);
});
}

Expand Down

0 comments on commit b140f13

Please sign in to comment.