diff --git a/userspace/libsinsp/test/plugins.ut.cpp b/userspace/libsinsp/test/plugins.ut.cpp index f802590942..78b48c34b8 100644 --- a/userspace/libsinsp/test/plugins.ut.cpp +++ b/userspace/libsinsp/test/plugins.ut.cpp @@ -1092,7 +1092,7 @@ TEST_F(sinsp_with_test_input, plugin_routines) { PPM_O_RDWR, 0); std::this_thread::sleep_for( - std::chrono::nanoseconds(1000)); // wait for a bit to let routine finish + std::chrono::milliseconds(100)); // wait for a bit to let routine finish routines_num = tp->routines_num(); ASSERT_EQ(routines_num, 1); @@ -1100,7 +1100,7 @@ TEST_F(sinsp_with_test_input, plugin_routines) { // unsubscribe it on capture close m_inspector.close(); std::this_thread::sleep_for( - std::chrono::nanoseconds(100)); // wait for a bit to let routine finish + std::chrono::milliseconds(100)); // wait for a bit to let routine finish routines_num = tp->routines_num(); ASSERT_EQ(routines_num, 0); } diff --git a/userspace/libsinsp/test/thread_pool.ut.cpp b/userspace/libsinsp/test/thread_pool.ut.cpp index 55fc3dd599..261e88f577 100644 --- a/userspace/libsinsp/test/thread_pool.ut.cpp +++ b/userspace/libsinsp/test/thread_pool.ut.cpp @@ -48,21 +48,22 @@ TEST_F(sinsp_with_test_input, thread_pool) { std::atomic count = 0; std::atomic routine_exited = false; r = tp->subscribe([&count, &routine_exited] { - if(count >= 1024) { + if(count >= 10) { routine_exited = true; return false; } count++; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); return true; }); ASSERT_EQ(tp->routines_num(), 1); - // the routine above keeps increasing a counter, until the counter reaches 1024 + // the routine above keeps increasing a counter, until the counter reaches 10 // we wait for the routine to exit, then we check if it has been unsubscribed while(!routine_exited) { - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } - ASSERT_EQ(count, 1024); + ASSERT_EQ(count, 10); ASSERT_EQ(tp->routines_num(), 0); // all the remaining routines should be unsubscribed when the inspector is closed