Skip to content

Commit

Permalink
fix(libsinsp_e2e): more robust container tests
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 Mar 22, 2024
1 parent 6d1fc91 commit 4686acb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/libsinsp_e2e/container/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ TEST_F(sys_call_test, container_cgroups)

static int clone_callback(void* arg)
{
sleep(5);
// Here we need 2 sleeps instead of once because, for some reason,
// we miss the first one. This problem is *probably* related to the
// fact that before we created a brand new inspector for each test but
// not we keep the same and start/stop the capture.
sleep(1);
sleep(1);
return 0;
}

Expand Down Expand Up @@ -231,26 +236,23 @@ TEST_F(sys_call_test, container_clone_nspid_ioctl)
//
// TEST CODE
//
run_callback_t test = [&](concurrent_object_handle<sinsp> inspector) { wait(NULL); };
run_callback_t test = [&](concurrent_object_handle<sinsp> inspector) { waitpid(ctid, NULL, 0); };

//
// OUTPUT VALDATION
//
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)
Expand Down

0 comments on commit 4686acb

Please sign in to comment.