Skip to content

Commit

Permalink
Timing: increased duration for self test
Browse files Browse the repository at this point in the history
Increase the duration of the self test, otherwise it tends to fail on
a busy machine even with the recently upped tolerance. But run the
loop only once, it's enough for a simple smoke test.
  • Loading branch information
gilles-peskine-arm committed Oct 27, 2017
1 parent aa9388b commit ca5f6e2
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions library/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,28 +442,26 @@ int mbedtls_timing_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( " TIMING test #2 (set/get_delay ): " );

for( a = 200; a <= 400; a += 200 )
{
for( b = 200; b <= 400; b += 200 )
{
mbedtls_timing_set_delay( &ctx, a, a + b );
a = 800;
b = 400;
mbedtls_timing_set_delay( &ctx, a, a + b );

busy_msleep( a - a / 4 );
if( mbedtls_timing_get_delay( &ctx ) != 0 )
FAIL;
busy_msleep( a - a / 4 );
if( mbedtls_timing_get_delay( &ctx ) != 0 )
FAIL;

busy_msleep( a / 2 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;
busy_msleep( a / 2 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;

busy_msleep( b - a / 4 - b / 4 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;
busy_msleep( b - a / 4 - b / 4 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;

busy_msleep( b / 2 );
if( mbedtls_timing_get_delay( &ctx ) != 2 )
FAIL;
}
busy_msleep( b / 2 );
if( mbedtls_timing_get_delay( &ctx ) != 2 )
FAIL;
}

mbedtls_timing_set_delay( &ctx, 0, 0 );
Expand Down

0 comments on commit ca5f6e2

Please sign in to comment.