forked from Imagelibrary/rtems
sapi: Use an interrupt lock for test extension
Ensure to report only once on SMP machines and ensure that the report is output completely.
This commit is contained in:
@@ -19,27 +19,10 @@
|
|||||||
#include <rtems/test.h>
|
#include <rtems/test.h>
|
||||||
#include <rtems/profiling.h>
|
#include <rtems/profiling.h>
|
||||||
|
|
||||||
#if defined(RTEMS_SMP)
|
static bool report_done;
|
||||||
#include <rtems/score/smpimpl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(RTEMS_PROFILING)
|
static rtems_interrupt_lock report_lock =
|
||||||
static bool should_report(
|
RTEMS_INTERRUPT_LOCK_INITIALIZER( "test report" );
|
||||||
rtems_fatal_source source,
|
|
||||||
rtems_fatal_code code
|
|
||||||
)
|
|
||||||
{
|
|
||||||
#if defined(RTEMS_SMP)
|
|
||||||
return source != RTEMS_FATAL_SOURCE_SMP
|
|
||||||
|| code != SMP_FATAL_SHUTDOWN_RESPONSE;
|
|
||||||
#else
|
|
||||||
(void) source;
|
|
||||||
(void) code;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void rtems_test_fatal_extension(
|
void rtems_test_fatal_extension(
|
||||||
rtems_fatal_source source,
|
rtems_fatal_source source,
|
||||||
@@ -47,10 +30,18 @@ void rtems_test_fatal_extension(
|
|||||||
rtems_fatal_code code
|
rtems_fatal_code code
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(void) is_internal;
|
|
||||||
|
|
||||||
#if defined(RTEMS_PROFILING)
|
#if defined(RTEMS_PROFILING)
|
||||||
if ( should_report( source, code ) ) {
|
rtems_interrupt_lock_context lock_context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensures to report only once on SMP machines and ensures that the report is
|
||||||
|
* output completely.
|
||||||
|
*/
|
||||||
|
rtems_interrupt_lock_acquire( &report_lock, &lock_context );
|
||||||
|
|
||||||
|
if ( !report_done ) {
|
||||||
|
report_done = true;
|
||||||
|
|
||||||
printk(
|
printk(
|
||||||
"\n*** PROFILING REPORT BEGIN %s ***\n",
|
"\n*** PROFILING REPORT BEGIN %s ***\n",
|
||||||
rtems_test_name
|
rtems_test_name
|
||||||
@@ -69,5 +60,11 @@ void rtems_test_fatal_extension(
|
|||||||
rtems_test_name
|
rtems_test_name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtems_interrupt_lock_release( &report_lock, &lock_context );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
(void) source;
|
||||||
|
(void) is_internal;
|
||||||
|
(void) code;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user