mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 09:25:38 +00:00
Timing self test: print some diagnosis information
Print some not-very-nice-looking but helpful diagnosis information if the timing selftest fails. Since the failures tend to be due to heavy system load that's hard to reproduce, this information is necessary to understand what's going on.
This commit is contained in:
parent
2484ffeb81
commit
e405069608
|
@ -366,6 +366,19 @@ static void busy_msleep( unsigned long msec )
|
||||||
(void) j;
|
(void) j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FAIL do \
|
||||||
|
{ \
|
||||||
|
if( verbose != 0 ) \
|
||||||
|
{ \
|
||||||
|
polarssl_printf( "failed at line %d\n", __LINE__ ); \
|
||||||
|
polarssl_printf( " cycles=%lu ratio=%lu millisecs=%lu secs=%lu hardfail=%d\n", \
|
||||||
|
cycles, ratio, millisecs, secs, hardfail ); \
|
||||||
|
polarssl_printf( " elapsed(hires)=%lu\n", \
|
||||||
|
get_timer( &hires, 0 ) ); \
|
||||||
|
} \
|
||||||
|
return( 1 ); \
|
||||||
|
} while( 0 )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checkup routine
|
* Checkup routine
|
||||||
*
|
*
|
||||||
|
@ -374,9 +387,9 @@ static void busy_msleep( unsigned long msec )
|
||||||
*/
|
*/
|
||||||
int timing_self_test( int verbose )
|
int timing_self_test( int verbose )
|
||||||
{
|
{
|
||||||
unsigned long cycles, ratio;
|
unsigned long cycles = 0, ratio = 0;
|
||||||
unsigned long millisecs, secs;
|
unsigned long millisecs = 0, secs = 0;
|
||||||
int hardfail;
|
int hardfail = 0;
|
||||||
struct hr_time hires;
|
struct hr_time hires;
|
||||||
|
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
|
@ -394,12 +407,7 @@ int timing_self_test( int verbose )
|
||||||
millisecs = get_timer( &hires, 0 );
|
millisecs = get_timer( &hires, 0 );
|
||||||
|
|
||||||
if( millisecs < 400 * secs || millisecs > 600 * secs )
|
if( millisecs < 400 * secs || millisecs > 600 * secs )
|
||||||
{
|
FAIL;
|
||||||
if( verbose != 0 )
|
|
||||||
polarssl_printf( "failed\n" );
|
|
||||||
|
|
||||||
return( 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
|
@ -421,12 +429,7 @@ int timing_self_test( int verbose )
|
||||||
/* For some reason on Windows it looks like alarm has an extra delay
|
/* For some reason on Windows it looks like alarm has an extra delay
|
||||||
* (maybe related to creating a new thread). Allow some room here. */
|
* (maybe related to creating a new thread). Allow some room here. */
|
||||||
if( millisecs < 800 * secs || millisecs > 1200 * secs + 300 )
|
if( millisecs < 800 * secs || millisecs > 1200 * secs + 300 )
|
||||||
{
|
FAIL;
|
||||||
if( verbose != 0 )
|
|
||||||
polarssl_printf( "failed\n" );
|
|
||||||
|
|
||||||
return( 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
|
@ -440,7 +443,6 @@ int timing_self_test( int verbose )
|
||||||
* On a 4Ghz 32-bit machine the cycle counter wraps about once per second;
|
* On a 4Ghz 32-bit machine the cycle counter wraps about once per second;
|
||||||
* since the whole test is about 10ms, it shouldn't happen twice in a row.
|
* since the whole test is about 10ms, it shouldn't happen twice in a row.
|
||||||
*/
|
*/
|
||||||
hardfail = 0;
|
|
||||||
|
|
||||||
hard_test:
|
hard_test:
|
||||||
if( hardfail > 1 )
|
if( hardfail > 1 )
|
||||||
|
@ -492,12 +494,7 @@ hard_test_done:
|
||||||
millisecs = get_timer( &hires, 0 );
|
millisecs = get_timer( &hires, 0 );
|
||||||
|
|
||||||
if( millisecs < 400 * secs || millisecs > 600 * secs )
|
if( millisecs < 400 * secs || millisecs > 600 * secs )
|
||||||
{
|
FAIL;
|
||||||
if( verbose != 0 )
|
|
||||||
polarssl_printf( "failed\n" );
|
|
||||||
|
|
||||||
return( 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
|
|
Loading…
Reference in a new issue