From 39ea4437885e8386410e21975607a927c18e48bc Mon Sep 17 00:00:00 2001 From: Roberto Scolaro Date: Thu, 21 Mar 2024 15:41:31 +0000 Subject: [PATCH] fix(libsinsp_e2e): more robust container tests Signed-off-by: Roberto Scolaro --- test/libsinsp_e2e/container/container.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/libsinsp_e2e/container/container.cpp b/test/libsinsp_e2e/container/container.cpp index 1fe5eaf152..a1e5107ec7 100644 --- a/test/libsinsp_e2e/container/container.cpp +++ b/test/libsinsp_e2e/container/container.cpp @@ -131,7 +131,8 @@ TEST_F(sys_call_test, container_cgroups) static int clone_callback(void* arg) { - sleep(5); + sleep(1); + sleep(1); return 0; } @@ -231,7 +232,7 @@ TEST_F(sys_call_test, container_clone_nspid_ioctl) // // TEST CODE // - run_callback_t test = [&](concurrent_object_handle inspector) { wait(NULL); }; + run_callback_t test = [&](concurrent_object_handle inspector) { waitpid(ctid, NULL, 0); }; // // OUTPUT VALDATION @@ -239,18 +240,15 @@ TEST_F(sys_call_test, container_clone_nspid_ioctl) captured_event_callback_t callback = [&](const callback_param& param) { sinsp_threadinfo* tinfo = param.m_evt->get_thread_info(); - if (tinfo) + if (tinfo && tinfo->m_vtid == 1 && tinfo->m_vpid == 1) { - EXPECT_EQ(1, tinfo->m_vtid); - EXPECT_EQ(1, tinfo->m_vpid); - done = true; } }; ASSERT_NO_FATAL_FAILURE({ event_capture::run(test, callback, filter); }); - ASSERT_TRUE(done); free(stack); + ASSERT_TRUE(done); } static void run_container_docker_test(bool fork_after_container_start)