make tests less flaky

This commit is contained in:
Lysann Tranvouez 2025-10-03 22:51:20 +02:00
parent 67a74ef7e1
commit 2eeb075739

View file

@ -55,7 +55,7 @@ TEST_CASE( "Handling other threads", "[attach][local][threads]" )
SECTION( "running threads modify a value" )
{
const int saved_b = g_b;
usleep( 100 ); // let the threads update g_b a bit
usleep( 1000 ); // let the threads update g_b a bit
CHECK( saved_b != g_b );
}
@ -79,13 +79,13 @@ TEST_CASE( "Handling other threads", "[attach][local][threads]" )
}
int saved_b = g_b;
usleep( 300 ); // let any running thread update g_b a bit
usleep( 1000 ); // let any running thread update g_b a bit
CHECK( saved_b == g_b );
CHECK( detour_transaction_commit() == err_none );
saved_b = g_b;
usleep( 100 ); // let the threads update g_b a bit
usleep( 1000 ); // let the threads update g_b a bit
CHECK( saved_b != g_b );
}
@ -95,7 +95,7 @@ TEST_CASE( "Handling other threads", "[attach][local][threads]" )
CHECK( detour_transaction_abort() == err_none );
const int saved_b = g_b;
usleep( 100 ); // let the threads update g_b a bit
usleep( 1000 ); // let the threads update g_b a bit
CHECK( saved_b != g_b );
}
@ -108,7 +108,7 @@ TEST_CASE( "Handling other threads", "[attach][local][threads]" )
CHECK( detour_attach_and_commit(reinterpret_cast<detour_func_t*>(&realLocalFunction), reinterpret_cast<detour_func_t>(localFunctionDetour)) == err_none );
const int saved_b = g_b;
usleep( 300 ); // let the threads update g_b a bit
usleep( 1000 ); // let the threads update g_b a bit
CHECK( saved_b != g_b );
// clean up