Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Split class sinsp_with_test_input into hdr + src #1694

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions userspace/libsinsp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ file(GLOB_RECURSE TEST_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/helpers/*.cpp)

set(LIBSINSP_UNIT_TESTS_SOURCES
test_utils.cpp
sinsp_with_test_input.cpp
cgroup_list_counter.ut.cpp
events_evt.ut.cpp
events_file.ut.cpp
Expand Down
86 changes: 43 additions & 43 deletions userspace/libsinsp/test/helpers/threads_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ limitations under the License.
\
/*=============================== p1_t1 ===========================*/ \
\
UNUSED int64_t p1_t1_tid = 2; \
UNUSED int64_t p1_t1_pid = p1_t1_tid; \
UNUSED int64_t p1_t1_ptid = INIT_TID; \
[[maybe_unused]] int64_t p1_t1_tid = 2; \
[[maybe_unused]] int64_t p1_t1_pid = p1_t1_tid; \
[[maybe_unused]] int64_t p1_t1_ptid = INIT_TID; \
\
/* Parent exit event */ \
generate_clone_x_event(p1_t1_tid, INIT_TID, INIT_PID, INIT_PTID); \
Expand All @@ -179,9 +179,9 @@ limitations under the License.
\
/*=============================== p1_t2 ===========================*/ \
\
UNUSED int64_t p1_t2_tid = 6; \
UNUSED int64_t p1_t2_pid = p1_t1_pid; \
UNUSED int64_t p1_t2_ptid = INIT_TID; \
[[maybe_unused]] int64_t p1_t2_tid = 6; \
[[maybe_unused]] int64_t p1_t2_pid = p1_t1_pid; \
[[maybe_unused]] int64_t p1_t2_ptid = INIT_TID; \
\
/* Parent exit event */ \
generate_clone_x_event(p1_t2_tid, p1_t1_tid, p1_t1_pid, p1_t1_ptid, PPM_CL_CLONE_THREAD); \
Expand All @@ -192,9 +192,9 @@ limitations under the License.
\
/*=============================== p2_t1 ===========================*/ \
\
UNUSED int64_t p2_t1_tid = 25; \
UNUSED int64_t p2_t1_pid = 25; \
UNUSED int64_t p2_t1_ptid = INIT_TID; \
[[maybe_unused]] int64_t p2_t1_tid = 25; \
[[maybe_unused]] int64_t p2_t1_pid = 25; \
[[maybe_unused]] int64_t p2_t1_ptid = INIT_TID; \
\
/* Parent exit event */ \
generate_clone_x_event(p2_t1_tid, p1_t2_tid, p1_t2_pid, p1_t2_ptid, PPM_CL_CLONE_PARENT); \
Expand All @@ -209,9 +209,9 @@ limitations under the License.
\
/*=============================== p2_t2 ===========================*/ \
\
UNUSED int64_t p2_t2_tid = 23; \
UNUSED int64_t p2_t2_pid = p2_t1_pid; \
UNUSED int64_t p2_t2_ptid = INIT_TID; /* p2_t2 will have the same parent of p2_t1 */ \
[[maybe_unused]] int64_t p2_t2_tid = 23; \
[[maybe_unused]] int64_t p2_t2_pid = p2_t1_pid; \
[[maybe_unused]] int64_t p2_t2_ptid = INIT_TID; /* p2_t2 will have the same parent of p2_t1 */ \
\
/* Parent exit event */ \
generate_clone_x_event(p2_t2_tid, p2_t1_tid, p2_t1_pid, p2_t1_ptid, PPM_CL_CLONE_THREAD); \
Expand All @@ -222,9 +222,9 @@ limitations under the License.
\
/*=============================== p2_t3 ===========================*/ \
\
UNUSED int64_t p2_t3_tid = 24; \
UNUSED int64_t p2_t3_pid = p2_t1_pid; \
UNUSED int64_t p2_t3_ptid = INIT_TID; \
[[maybe_unused]] int64_t p2_t3_tid = 24; \
[[maybe_unused]] int64_t p2_t3_pid = p2_t1_pid; \
[[maybe_unused]] int64_t p2_t3_ptid = INIT_TID; \
\
/* Parent exit event */ \
generate_clone_x_event(p2_t3_tid, p2_t2_tid, p2_t2_pid, p2_t2_ptid, PPM_CL_CLONE_THREAD); \
Expand All @@ -235,9 +235,9 @@ limitations under the License.
\
/*=============================== p3_t1 ===========================*/ \
\
UNUSED int64_t p3_t1_tid = 72; \
UNUSED int64_t p3_t1_pid = p3_t1_tid; \
UNUSED int64_t p3_t1_ptid = p2_t1_tid; \
[[maybe_unused]] int64_t p3_t1_tid = 72; \
[[maybe_unused]] int64_t p3_t1_pid = p3_t1_tid; \
[[maybe_unused]] int64_t p3_t1_ptid = p2_t1_tid; \
\
/* Parent exit event */ \
generate_clone_x_event(p3_t1_tid, p2_t1_tid, p2_t1_pid, p2_t1_ptid); \
Expand All @@ -248,11 +248,11 @@ limitations under the License.
\
/*=============================== p4_t1 ===========================*/ \
\
UNUSED int64_t p4_t1_tid = 76; \
UNUSED int64_t p4_t1_pid = p4_t1_tid; \
UNUSED int64_t p4_t1_ptid = p3_t1_tid; \
UNUSED int64_t p4_t1_vtid = 1; /* This process will be the `init` one in the new namespace */ \
UNUSED int64_t p4_t1_vpid = p4_t1_vtid; \
[[maybe_unused]] int64_t p4_t1_tid = 76; \
[[maybe_unused]] int64_t p4_t1_pid = p4_t1_tid; \
[[maybe_unused]] int64_t p4_t1_ptid = p3_t1_tid; \
[[maybe_unused]] int64_t p4_t1_vtid = 1; /* This process will be the `init` one in the new namespace */ \
[[maybe_unused]] int64_t p4_t1_vpid = p4_t1_vtid; \
\
generate_clone_x_event(p4_t1_tid, p3_t1_tid, p3_t1_pid, p3_t1_ptid, PPM_CL_CLONE_NEWPID); \
\
Expand All @@ -270,11 +270,11 @@ limitations under the License.
\
/*=============================== p4_t2 ===========================*/ \
\
UNUSED int64_t p4_t2_tid = 79; \
UNUSED int64_t p4_t2_pid = p4_t1_pid; \
UNUSED int64_t p4_t2_ptid = p3_t1_tid; \
UNUSED int64_t p4_t2_vtid = 2; \
UNUSED int64_t p4_t2_vpid = p4_t1_vpid; \
[[maybe_unused]] int64_t p4_t2_tid = 79; \
[[maybe_unused]] int64_t p4_t2_pid = p4_t1_pid; \
[[maybe_unused]] int64_t p4_t2_ptid = p3_t1_tid; \
[[maybe_unused]] int64_t p4_t2_vtid = 2; \
[[maybe_unused]] int64_t p4_t2_vpid = p4_t1_vpid; \
\
generate_clone_x_event(0, p4_t2_tid, p4_t2_pid, p4_t2_ptid, PPM_CL_CLONE_THREAD | PPM_CL_CHILD_IN_PIDNS, \
p4_t2_vtid, p4_t2_vpid); \
Expand All @@ -283,35 +283,35 @@ limitations under the License.
\
/*=============================== p5_t1 ===========================*/ \
\
UNUSED int64_t p5_t1_tid = 82; \
UNUSED int64_t p5_t1_pid = p5_t1_tid; \
UNUSED int64_t p5_t1_ptid = p4_t2_tid; \
UNUSED int64_t p5_t1_vtid = 10; \
UNUSED int64_t p5_t1_vpid = p5_t1_vtid; \
[[maybe_unused]] int64_t p5_t1_tid = 82; \
[[maybe_unused]] int64_t p5_t1_pid = p5_t1_tid; \
[[maybe_unused]] int64_t p5_t1_ptid = p4_t2_tid; \
[[maybe_unused]] int64_t p5_t1_vtid = 10; \
[[maybe_unused]] int64_t p5_t1_vpid = p5_t1_vtid; \
\
generate_clone_x_event(0, p5_t1_tid, p5_t1_pid, p5_t1_ptid, PPM_CL_CHILD_IN_PIDNS, p5_t1_vtid, p5_t1_vpid); \
\
/*=============================== p5_t1 ===========================*/ \
\
/*=============================== p5_t2 ===========================*/ \
\
UNUSED int64_t p5_t2_tid = 84; \
UNUSED int64_t p5_t2_pid = p5_t1_pid; \
UNUSED int64_t p5_t2_ptid = p4_t2_tid; \
UNUSED int64_t p5_t2_vtid = 12; \
UNUSED int64_t p5_t2_vpid = p5_t1_vpid; \
[[maybe_unused]] int64_t p5_t2_tid = 84; \
[[maybe_unused]] int64_t p5_t2_pid = p5_t1_pid; \
[[maybe_unused]] int64_t p5_t2_ptid = p4_t2_tid; \
[[maybe_unused]] int64_t p5_t2_vtid = 12; \
[[maybe_unused]] int64_t p5_t2_vpid = p5_t1_vpid; \
\
generate_clone_x_event(0, p5_t2_tid, p5_t2_pid, p5_t2_ptid, PPM_CL_CHILD_IN_PIDNS, p5_t2_vtid, p5_t2_vpid); \
\
/*=============================== p5_t2 ===========================*/ \
\
/*=============================== p6_t1 ===========================*/ \
\
UNUSED int64_t p6_t1_tid = 87; \
UNUSED int64_t p6_t1_pid = p6_t1_tid; \
UNUSED int64_t p6_t1_ptid = p5_t2_tid; \
UNUSED int64_t p6_t1_vtid = 17; \
UNUSED int64_t p6_t1_vpid = p6_t1_vtid; \
[[maybe_unused]] int64_t p6_t1_tid = 87; \
[[maybe_unused]] int64_t p6_t1_pid = p6_t1_tid; \
[[maybe_unused]] int64_t p6_t1_ptid = p5_t2_tid; \
[[maybe_unused]] int64_t p6_t1_vtid = 17; \
[[maybe_unused]] int64_t p6_t1_vpid = p6_t1_vtid; \
\
generate_clone_x_event(0, p6_t1_tid, p6_t1_pid, p6_t1_ptid, PPM_CL_CHILD_IN_PIDNS, p6_t1_vtid, p6_t1_vpid); \
\
Expand Down
10 changes: 5 additions & 5 deletions userspace/libsinsp/test/parsers/parse_clone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ TEST_F(sinsp_with_test_input, CLONE_CALLER_comm_update)
*/

int64_t p2_t1_tid = 26;
UNUSED int64_t p2_t1_pid = 26;
UNUSED int64_t p2_t1_ptid = p1_t1_tid;
[[maybe_unused]] int64_t p2_t1_pid = 26;
[[maybe_unused]] int64_t p2_t1_ptid = p1_t1_tid;

ASSERT_THREAD_INFO_COMM(p1_t1_tid, "old-name");
generate_clone_x_event(p2_t1_tid, p1_t1_tid, p1_t1_pid, p1_t1_ptid, DEFAULT_VALUE, DEFAULT_VALUE, DEFAULT_VALUE,
Expand Down Expand Up @@ -440,7 +440,7 @@ TEST_F(sinsp_with_test_input, CLONE_CHILD_tid_collision)

/* Create a mock child with a clone exit parent event */
int64_t p1_t1_tid = 24;
UNUSED int64_t p1_t1_pid = 24;
[[maybe_unused]] int64_t p1_t1_pid = 24;
int64_t p1_t1_ptid = INIT_PID;

/* Parent clone exit event */
Expand Down Expand Up @@ -609,8 +609,8 @@ TEST_F(sinsp_with_test_input, CLONE_CHILD_missing_both_clone_events_create_secon

/* Init creates a new process p1 but we miss both clone events so we know nothing about it */
int64_t p1_t1_tid = 24;
UNUSED int64_t p1_t1_pid = 24;
UNUSED int64_t p1_t1_ptid = INIT_TID;
[[maybe_unused]] int64_t p1_t1_pid = 24;
[[maybe_unused]] int64_t p1_t1_ptid = INIT_TID;

/* The process p1 creates a second thread p1_t2 */
int64_t p1_t2_tid = 30;
Expand Down
Loading
Loading