mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-21 00:48:31 +08:00
testsuites/support: reformat with clang-format
Updates #3860. Updates #5358.
This commit is contained in:
committed by
Kinsey Moore
parent
f5d93a7421
commit
7c24bcced0
@@ -47,8 +47,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TEST_BEGIN() rtems_test_begin(rtems_test_name, TEST_STATE)
|
||||
#define TEST_END() rtems_test_end(rtems_test_name)
|
||||
#define TEST_BEGIN() rtems_test_begin( rtems_test_name, TEST_STATE )
|
||||
#define TEST_END() rtems_test_end( rtems_test_name )
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@@ -40,18 +40,18 @@ extern "C" {
|
||||
* Return a pointer to the POSIX name that is slightly
|
||||
* beyond the legal limit.
|
||||
*/
|
||||
const char *Get_Too_Long_Name(void);
|
||||
const char *Get_Too_Long_Name( void );
|
||||
|
||||
/*
|
||||
* Return a pointer to the longest legal POSIX name.
|
||||
*/
|
||||
const char *Get_Longest_Name(void);
|
||||
const char *Get_Longest_Name( void );
|
||||
|
||||
/*
|
||||
* Spin for specified number of ticks. The first tick we spin through is a
|
||||
* partial one.
|
||||
*/
|
||||
void rtems_test_spin_for_ticks(rtems_interval ticks);
|
||||
void rtems_test_spin_for_ticks( rtems_interval ticks );
|
||||
|
||||
/*
|
||||
* Spin until the next clock tick
|
||||
@@ -67,20 +67,17 @@ void rtems_test_spin_until_next_tick( void );
|
||||
/*
|
||||
* Type of method used for timing operations
|
||||
*/
|
||||
typedef void (*rtems_time_test_method_t)(
|
||||
int iteration,
|
||||
void *argument
|
||||
);
|
||||
typedef void ( *rtems_time_test_method_t )( int iteration, void *argument );
|
||||
|
||||
/*
|
||||
* Obtain baseline timing information for benchmark tests.
|
||||
*/
|
||||
void rtems_time_test_measure_operation(
|
||||
const char *description,
|
||||
rtems_time_test_method_t operation,
|
||||
void *argument,
|
||||
int iterations,
|
||||
int overhead
|
||||
const char *description,
|
||||
rtems_time_test_method_t operation,
|
||||
void *argument,
|
||||
int iterations,
|
||||
int overhead
|
||||
);
|
||||
|
||||
/*********************************************************************/
|
||||
@@ -89,11 +86,11 @@ void rtems_time_test_measure_operation(
|
||||
/*********************************************************************/
|
||||
/*********************************************************************/
|
||||
|
||||
void locked_print_initialize(void);
|
||||
void locked_print_initialize( void );
|
||||
|
||||
int locked_printf(const char *fmt, ...);
|
||||
int locked_printf( const char *fmt, ... );
|
||||
|
||||
int locked_vprintf(const char *fmt, va_list ap);
|
||||
int locked_vprintf( const char *fmt, va_list ap );
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <rtems/inttypes.h>
|
||||
#include <bsp.h> /* includes <rtems.h> */
|
||||
#include <bsp.h> /* includes <rtems.h> */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
@@ -55,7 +55,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FOREVER 1 /* infinite loop */
|
||||
#define FOREVER 1 /* infinite loop */
|
||||
|
||||
#ifdef CONFIGURE_INIT
|
||||
#define TEST_EXTERN
|
||||
@@ -67,215 +67,286 @@ extern "C" {
|
||||
* Check that that the dispatch disable level is proper for the
|
||||
* mode/state of the test. Normally it should be 0 when in task space.
|
||||
*/
|
||||
#define check_dispatch_disable_level( _expect ) \
|
||||
do { \
|
||||
if ( (_expect) != -1 \
|
||||
&& (((!_Thread_Dispatch_is_enabled()) == false && (_expect) != 0) \
|
||||
|| ((!_Thread_Dispatch_is_enabled()) && (_expect) == 0)) \
|
||||
) { \
|
||||
printf( \
|
||||
"\n_Thread_Dispatch_disable_level is (%i)" \
|
||||
" not %d detected at %s:%d\n", \
|
||||
!_Thread_Dispatch_is_enabled(), (_expect), __FILE__, __LINE__ ); \
|
||||
rtems_test_exit( 1 ); \
|
||||
} \
|
||||
#define check_dispatch_disable_level( _expect ) \
|
||||
do { \
|
||||
if ( \
|
||||
( _expect ) != -1 && \
|
||||
( ( ( !_Thread_Dispatch_is_enabled() ) == false && \
|
||||
( _expect ) != 0 ) || \
|
||||
( ( !_Thread_Dispatch_is_enabled() ) && ( _expect ) == 0 ) ) \
|
||||
) { \
|
||||
printf( \
|
||||
"\n_Thread_Dispatch_disable_level is (%i)" \
|
||||
" not %d detected at %s:%d\n", \
|
||||
!_Thread_Dispatch_is_enabled(), \
|
||||
( _expect ), \
|
||||
__FILE__, \
|
||||
__LINE__ \
|
||||
); \
|
||||
rtems_test_exit( 1 ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
/*
|
||||
* Check that that the allocator mutex is not owned by the executing thread.
|
||||
*/
|
||||
#include <rtems/score/apimutex.h>
|
||||
#define check_if_allocator_mutex_is_not_owned() \
|
||||
do { \
|
||||
if ( _RTEMS_Allocator_is_owner() ) { \
|
||||
printf( \
|
||||
#define check_if_allocator_mutex_is_not_owned() \
|
||||
do { \
|
||||
if ( _RTEMS_Allocator_is_owner() ) { \
|
||||
printf( \
|
||||
"\nRTEMS Allocator Mutex is owned by executing thread " \
|
||||
"and should not be.\n" \
|
||||
"Detected at %s:%d\n", \
|
||||
__FILE__, \
|
||||
__LINE__ \
|
||||
); \
|
||||
rtems_test_exit( 1 ); \
|
||||
} \
|
||||
"and should not be.\n" \
|
||||
"Detected at %s:%d\n", \
|
||||
__FILE__, \
|
||||
__LINE__ \
|
||||
); \
|
||||
rtems_test_exit( 1 ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
/*
|
||||
* These macros properly report errors within the Classic API
|
||||
*/
|
||||
#define directive_failed( _dirstat, _failmsg ) \
|
||||
fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
|
||||
#define directive_failed( _dirstat, _failmsg ) \
|
||||
fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
|
||||
|
||||
#define directive_failed_with_level( _dirstat, _failmsg, _level ) \
|
||||
fatal_directive_status_with_level( \
|
||||
_dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
|
||||
#define directive_failed_with_level( _dirstat, _failmsg, _level ) \
|
||||
fatal_directive_status_with_level( \
|
||||
_dirstat, \
|
||||
RTEMS_SUCCESSFUL, \
|
||||
_failmsg, \
|
||||
_level \
|
||||
)
|
||||
|
||||
#define fatal_directive_status( _stat, _desired, _msg ) \
|
||||
fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
|
||||
|
||||
#define fatal_directive_check_status_only( _stat, _desired, _msg ) \
|
||||
do { \
|
||||
if ( (_stat) != (_desired) ) { \
|
||||
printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
|
||||
(_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
|
||||
rtems_test_exit( _stat ); \
|
||||
} \
|
||||
do { \
|
||||
if ( ( _stat ) != ( _desired ) ) { \
|
||||
printf( \
|
||||
"\n%s FAILED -- expected (%s) got (%s)\n", \
|
||||
( _msg ), \
|
||||
rtems_status_text( _desired ), \
|
||||
rtems_status_text( _stat ) \
|
||||
); \
|
||||
rtems_test_exit( _stat ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
|
||||
do { \
|
||||
check_dispatch_disable_level( _level ); \
|
||||
check_if_allocator_mutex_is_not_owned(); \
|
||||
fatal_directive_check_status_only( _stat, _desired, _msg ); \
|
||||
do { \
|
||||
check_dispatch_disable_level( _level ); \
|
||||
check_if_allocator_mutex_is_not_owned(); \
|
||||
fatal_directive_check_status_only( _stat, _desired, _msg ); \
|
||||
} while ( 0 )
|
||||
|
||||
/*
|
||||
* These macros properly report errors from the POSIX API
|
||||
*/
|
||||
|
||||
#define posix_service_failed( _dirstat, _failmsg ) \
|
||||
fatal_posix_service_status( _dirstat, 0, _failmsg )
|
||||
#define posix_service_failed( _dirstat, _failmsg ) \
|
||||
fatal_posix_service_status( _dirstat, 0, _failmsg )
|
||||
|
||||
#define posix_service_failed_with_level( _dirstat, _failmsg, _level ) \
|
||||
fatal_posix_service_status_with_level( _dirstat, 0, _failmsg, _level )
|
||||
#define posix_service_failed_with_level( _dirstat, _failmsg, _level ) \
|
||||
fatal_posix_service_status_with_level( _dirstat, 0, _failmsg, _level )
|
||||
|
||||
#define fatal_posix_service_status_errno( _stat, _desired, _msg ) \
|
||||
if ( (_stat != -1) && (errno) != (_desired) ) { \
|
||||
long statx = _stat; \
|
||||
check_dispatch_disable_level( 0 ); \
|
||||
check_if_allocator_mutex_is_not_owned(); \
|
||||
printf( "\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \
|
||||
(_msg), _desired, strerror(_desired), \
|
||||
statx, errno, strerror(errno) ); \
|
||||
rtems_test_exit( _stat ); \
|
||||
if ( ( _stat != -1 ) && ( errno ) != ( _desired ) ) { \
|
||||
long statx = _stat; \
|
||||
check_dispatch_disable_level( 0 ); \
|
||||
check_if_allocator_mutex_is_not_owned(); \
|
||||
printf( \
|
||||
"\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \
|
||||
( _msg ), \
|
||||
_desired, \
|
||||
strerror( _desired ), \
|
||||
statx, \
|
||||
errno, \
|
||||
strerror( errno ) \
|
||||
); \
|
||||
rtems_test_exit( _stat ); \
|
||||
}
|
||||
|
||||
#define fatal_posix_service_status( _stat, _desired, _msg ) \
|
||||
fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
|
||||
|
||||
#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
|
||||
do { \
|
||||
check_dispatch_disable_level( _level ); \
|
||||
check_if_allocator_mutex_is_not_owned(); \
|
||||
if ( (_stat) != (_desired) ) { \
|
||||
printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
|
||||
(_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
|
||||
printf( "\n FAILED -- errno (%d - %s)\n", \
|
||||
errno, strerror(errno) ); \
|
||||
rtems_test_exit( _stat ); \
|
||||
} \
|
||||
#define fatal_posix_service_status_with_level( \
|
||||
_stat, \
|
||||
_desired, \
|
||||
_msg, \
|
||||
_level \
|
||||
) \
|
||||
do { \
|
||||
check_dispatch_disable_level( _level ); \
|
||||
check_if_allocator_mutex_is_not_owned(); \
|
||||
if ( ( _stat ) != ( _desired ) ) { \
|
||||
printf( \
|
||||
"\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
|
||||
( _msg ), \
|
||||
_desired, \
|
||||
strerror( _desired ), \
|
||||
_stat, \
|
||||
strerror( _stat ) \
|
||||
); \
|
||||
printf( "\n FAILED -- errno (%d - %s)\n", errno, strerror( errno ) ); \
|
||||
rtems_test_exit( _stat ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
/*
|
||||
* This macro evaluates the semaphore id returned.
|
||||
*/
|
||||
#define fatal_posix_sem( _ptr, _msg ) \
|
||||
if ( (_ptr != SEM_FAILED) ) { \
|
||||
check_dispatch_disable_level( 0 ); \
|
||||
printf( "\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \
|
||||
(_msg), _ptr, errno, strerror(errno) ); \
|
||||
rtems_test_exit( -1 ); \
|
||||
#define fatal_posix_sem( _ptr, _msg ) \
|
||||
if (( _ptr != SEM_FAILED )) { \
|
||||
check_dispatch_disable_level( 0 ); \
|
||||
printf( \
|
||||
"\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \
|
||||
( _msg ), \
|
||||
_ptr, \
|
||||
errno, \
|
||||
strerror( errno ) \
|
||||
); \
|
||||
rtems_test_exit( -1 ); \
|
||||
}
|
||||
|
||||
/*
|
||||
* This macro evaluates the message queue id returned.
|
||||
*/
|
||||
#define fatal_posix_mqd( _ptr, _msg ) \
|
||||
if ( (_ptr != (mqd_t) -1) ) { \
|
||||
check_dispatch_disable_level( 0 ); \
|
||||
printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
|
||||
(_msg), _ptr, errno, strerror(errno) ); \
|
||||
rtems_test_exit( -1 ); \
|
||||
#define fatal_posix_mqd( _ptr, _msg ) \
|
||||
if (( _ptr != ( mqd_t ) - 1 )) { \
|
||||
check_dispatch_disable_level( 0 ); \
|
||||
printf( \
|
||||
"\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
|
||||
( _msg ), \
|
||||
_ptr, \
|
||||
errno, \
|
||||
strerror( errno ) \
|
||||
); \
|
||||
rtems_test_exit( -1 ); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic integer version of the error reporting
|
||||
*/
|
||||
|
||||
#define int_service_failed( _dirstat, _failmsg ) \
|
||||
fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
|
||||
#define int_service_failed( _dirstat, _failmsg ) \
|
||||
fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
|
||||
|
||||
#define int_service_failed_with_level( _dirstat, _failmsg, _level ) \
|
||||
fatal_int_service_status_with_level( \
|
||||
_dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
|
||||
#define int_service_failed_with_level( _dirstat, _failmsg, _level ) \
|
||||
fatal_int_service_status_with_level( \
|
||||
_dirstat, \
|
||||
RTEMS_SUCCESSFUL, \
|
||||
_failmsg, \
|
||||
_level \
|
||||
)
|
||||
|
||||
#define fatal_int_service_status( _stat, _desired, _msg ) \
|
||||
fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
|
||||
|
||||
#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
|
||||
do { \
|
||||
check_dispatch_disable_level( _level ); \
|
||||
if ( (_stat) != (_desired) ) { \
|
||||
printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
|
||||
(_msg), (_desired), (_stat) ); \
|
||||
rtems_test_exit( _stat ); \
|
||||
} \
|
||||
do { \
|
||||
check_dispatch_disable_level( _level ); \
|
||||
if ( ( _stat ) != ( _desired ) ) { \
|
||||
printf( \
|
||||
"\n%s FAILED -- expected (%d) got (%d)\n", \
|
||||
( _msg ), \
|
||||
( _desired ), \
|
||||
( _stat ) \
|
||||
); \
|
||||
rtems_test_exit( _stat ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
|
||||
/*
|
||||
* Print the time
|
||||
*/
|
||||
|
||||
#define sprint_time(_str, _s1, _tb, _s2) \
|
||||
do { \
|
||||
sprintf( (_str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \
|
||||
_s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
|
||||
(_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
|
||||
#define sprint_time( _str, _s1, _tb, _s2 ) \
|
||||
do { \
|
||||
sprintf( \
|
||||
( _str ), \
|
||||
"%s%02d:%02d:%02d %02d/%02d/%04d%s", \
|
||||
_s1, \
|
||||
( _tb )->hour, \
|
||||
( _tb )->minute, \
|
||||
( _tb )->second, \
|
||||
( _tb )->month, \
|
||||
( _tb )->day, \
|
||||
( _tb )->year, \
|
||||
_s2 \
|
||||
); \
|
||||
} while ( 0 )
|
||||
|
||||
#define print_time(_s1, _tb, _s2) \
|
||||
do { \
|
||||
printf( "%s%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 " %02" PRIu32 "/%02" PRIu32 "/%04" PRIu32 "%s", \
|
||||
_s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
|
||||
(_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
|
||||
#define print_time( _s1, _tb, _s2 ) \
|
||||
do { \
|
||||
printf( \
|
||||
"%s%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 " %02" PRIu32 \
|
||||
"/%02" PRIu32 "/%04" PRIu32 "%s", \
|
||||
_s1, \
|
||||
( _tb )->hour, \
|
||||
( _tb )->minute, \
|
||||
( _tb )->second, \
|
||||
( _tb )->month, \
|
||||
( _tb )->day, \
|
||||
( _tb )->year, \
|
||||
_s2 \
|
||||
); \
|
||||
} while ( 0 )
|
||||
|
||||
#define put_dot( _c ) \
|
||||
do { \
|
||||
putchar( _c ); \
|
||||
do { \
|
||||
putchar( _c ); \
|
||||
} while ( 0 )
|
||||
|
||||
#define new_line puts( "" )
|
||||
#define new_line puts( "" )
|
||||
|
||||
#define puts_nocr printf
|
||||
|
||||
#define put_name( name, crlf ) \
|
||||
{ int c0, c1, c2, c3; \
|
||||
c0 = (name >> 24) & 0xff; \
|
||||
c1 = (name >> 16) & 0xff; \
|
||||
c2 = (name >> 8) & 0xff; \
|
||||
c3 = name & 0xff; \
|
||||
putchar( (isprint(c0)) ? c0 : '*' ); \
|
||||
if ( c1 ) putchar( (isprint(c1)) ? c1 : '*' ); \
|
||||
if ( c2 ) putchar( (isprint(c2)) ? c2 : '*' ); \
|
||||
if ( c3 ) putchar( (isprint(c3)) ? c3 : '*' ); \
|
||||
if ( crlf ) \
|
||||
putchar( '\n' ); \
|
||||
}
|
||||
#define put_name( name, crlf ) \
|
||||
{ \
|
||||
int c0, c1, c2, c3; \
|
||||
c0 = ( name >> 24 ) & 0xff; \
|
||||
c1 = ( name >> 16 ) & 0xff; \
|
||||
c2 = ( name >> 8 ) & 0xff; \
|
||||
c3 = name & 0xff; \
|
||||
putchar( ( isprint( c0 ) ) ? c0 : '*' ); \
|
||||
if ( c1 ) \
|
||||
putchar( ( isprint( c1 ) ) ? c1 : '*' ); \
|
||||
if ( c2 ) \
|
||||
putchar( ( isprint( c2 ) ) ? c2 : '*' ); \
|
||||
if ( c3 ) \
|
||||
putchar( ( isprint( c3 ) ) ? c3 : '*' ); \
|
||||
if ( crlf ) \
|
||||
putchar( '\n' ); \
|
||||
}
|
||||
|
||||
#ifndef build_time
|
||||
#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
|
||||
{ (TB)->year = YR; \
|
||||
(TB)->month = MON; \
|
||||
(TB)->day = DAY; \
|
||||
(TB)->hour = HR; \
|
||||
(TB)->minute = MIN; \
|
||||
(TB)->second = SEC; \
|
||||
(TB)->ticks = TK; }
|
||||
{ \
|
||||
( TB )->year = YR; \
|
||||
( TB )->month = MON; \
|
||||
( TB )->day = DAY; \
|
||||
( TB )->hour = HR; \
|
||||
( TB )->minute = MIN; \
|
||||
( TB )->second = SEC; \
|
||||
( TB )->ticks = TK; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define task_number( tid ) \
|
||||
( rtems_object_id_get_index( tid ) - \
|
||||
rtems_configuration_get_rtems_api_configuration()-> \
|
||||
number_of_initialization_tasks )
|
||||
#define task_number( tid ) \
|
||||
( rtems_object_id_get_index( tid ) - \
|
||||
rtems_configuration_get_rtems_api_configuration() \
|
||||
->number_of_initialization_tasks )
|
||||
|
||||
#define rtems_test_assert(__exp) \
|
||||
do { \
|
||||
if (!(__exp)) { \
|
||||
#define rtems_test_assert( __exp ) \
|
||||
do { \
|
||||
if ( !( __exp ) ) { \
|
||||
printf( "%s: %d %s\n", __FILE__, __LINE__, #__exp ); \
|
||||
rtems_test_exit(0); \
|
||||
} \
|
||||
} while (0)
|
||||
rtems_test_exit( 0 ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
/**
|
||||
* This assists in clearly disabling warnings on GCC in certain very
|
||||
@@ -286,10 +357,10 @@ extern "C" {
|
||||
* the code warning free.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_PUSH _Pragma("GCC diagnostic push")
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_POP _Pragma("GCC diagnostic pop")
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_PUSH _Pragma( "GCC diagnostic push" )
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_POP _Pragma( "GCC diagnostic pop" )
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_DISABLE_NONNULL \
|
||||
_Pragma("GCC diagnostic ignored \"-Wnonnull\"")
|
||||
_Pragma( "GCC diagnostic ignored \"-Wnonnull\"" )
|
||||
#else
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_PUSH
|
||||
#define COMPILER_DIAGNOSTIC_SETTINGS_POP
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
|
||||
extern rtems_status_code benchmark_timer_empty_function( void );
|
||||
|
||||
extern void benchmark_timer_empty_operation(
|
||||
int iteration,
|
||||
void *argument
|
||||
);
|
||||
extern void benchmark_timer_empty_operation( int iteration, void *argument );
|
||||
|
||||
#endif /* _TMTESTS_EMPTY_FUNCTION_H */
|
||||
|
||||
@@ -37,32 +37,31 @@
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/counter.h>
|
||||
|
||||
static rtems_id locked_print_semaphore; /* synchronisation semaphore */
|
||||
static rtems_id locked_print_semaphore; /* synchronisation semaphore */
|
||||
|
||||
static int locked_printf_plugin(void *context, const char *fmt, va_list ap)
|
||||
static int locked_printf_plugin( void *context, const char *fmt, va_list ap )
|
||||
{
|
||||
(void) context;
|
||||
return locked_vprintf(fmt, ap);
|
||||
return locked_vprintf( fmt, ap );
|
||||
}
|
||||
|
||||
void locked_print_initialize(void)
|
||||
void locked_print_initialize( void )
|
||||
{
|
||||
rtems_status_code sc;
|
||||
static bool initted = false;
|
||||
static bool initted = false;
|
||||
|
||||
if ( initted )
|
||||
if ( initted ) {
|
||||
return;
|
||||
}
|
||||
|
||||
initted = true;
|
||||
|
||||
/* Create/verify synchronisation semaphore */
|
||||
sc = rtems_semaphore_create(
|
||||
rtems_build_name ('S', 'E', 'M', '1'),
|
||||
rtems_build_name( 'S', 'E', 'M', '1' ),
|
||||
1,
|
||||
RTEMS_LOCAL |
|
||||
RTEMS_BINARY_SEMAPHORE |
|
||||
RTEMS_PRIORITY_CEILING |
|
||||
RTEMS_PRIORITY,
|
||||
RTEMS_LOCAL | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY_CEILING |
|
||||
RTEMS_PRIORITY,
|
||||
1,
|
||||
&locked_print_semaphore
|
||||
);
|
||||
@@ -75,9 +74,9 @@ void locked_print_initialize(void)
|
||||
rtems_test_printer.printer = locked_printf_plugin;
|
||||
}
|
||||
|
||||
int locked_vprintf(const char *fmt, va_list ap)
|
||||
int locked_vprintf( const char *fmt, va_list ap )
|
||||
{
|
||||
int rv;
|
||||
int rv;
|
||||
rtems_status_code sc;
|
||||
|
||||
locked_print_initialize();
|
||||
@@ -86,7 +85,7 @@ int locked_vprintf(const char *fmt, va_list ap)
|
||||
sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
|
||||
|
||||
if ( sc != RTEMS_SUCCESSFUL ) {
|
||||
uint8_t e;
|
||||
uint8_t e;
|
||||
rtems_counter_ticks w;
|
||||
|
||||
/* Use exponential backoff to avoid a livelock */
|
||||
@@ -98,10 +97,10 @@ int locked_vprintf(const char *fmt, va_list ap)
|
||||
rtems_counter_delay_ticks( w );
|
||||
w *= 2;
|
||||
sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
|
||||
} while (sc != RTEMS_SUCCESSFUL );
|
||||
} while ( sc != RTEMS_SUCCESSFUL );
|
||||
}
|
||||
|
||||
rv = vprintk(fmt, ap);
|
||||
rv = vprintk( fmt, ap );
|
||||
|
||||
/* Release the semaphore */
|
||||
rtems_semaphore_release( locked_print_semaphore );
|
||||
@@ -109,14 +108,14 @@ int locked_vprintf(const char *fmt, va_list ap)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int locked_printf(const char *fmt, ...)
|
||||
int locked_printf( const char *fmt, ... )
|
||||
{
|
||||
int rv;
|
||||
va_list ap; /* points to each unnamed argument in turn */
|
||||
int rv;
|
||||
va_list ap; /* points to each unnamed argument in turn */
|
||||
|
||||
va_start(ap, fmt); /* make ap point to 1st unnamed arg */
|
||||
rv = locked_vprintf(fmt, ap);
|
||||
va_end(ap); /* clean up when done */
|
||||
va_start( ap, fmt ); /* make ap point to 1st unnamed arg */
|
||||
rv = locked_vprintf( fmt, ap );
|
||||
va_end( ap ); /* clean up when done */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
/*
|
||||
* Burn CPU for specified number of ticks
|
||||
*/
|
||||
void rtems_test_spin_for_ticks(rtems_interval ticks)
|
||||
void rtems_test_spin_for_ticks( rtems_interval ticks )
|
||||
{
|
||||
rtems_interval start;
|
||||
rtems_interval now;
|
||||
|
||||
@@ -36,25 +36,27 @@
|
||||
#include "test_support.h"
|
||||
#include <rtems/libcsupport.h>
|
||||
|
||||
static char Too_Long_Name[PATH_MAX + 2];
|
||||
static char Longest_Name[PATH_MAX + 1];
|
||||
static char Too_Long_Name[ PATH_MAX + 2 ];
|
||||
static char Longest_Name[ PATH_MAX + 1 ];
|
||||
|
||||
const char *Get_Too_Long_Name(void)
|
||||
const char *Get_Too_Long_Name( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; i <= PATH_MAX; i++ )
|
||||
Too_Long_Name[i] = 'E';
|
||||
Too_Long_Name[i] = '\0';
|
||||
for ( i = 0; i <= PATH_MAX; i++ ) {
|
||||
Too_Long_Name[ i ] = 'E';
|
||||
}
|
||||
Too_Long_Name[ i ] = '\0';
|
||||
return Too_Long_Name;
|
||||
}
|
||||
|
||||
const char *Get_Longest_Name(void)
|
||||
const char *Get_Longest_Name( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0; i < PATH_MAX-1; i++ )
|
||||
Longest_Name[i] = 'L';
|
||||
Longest_Name[i] = '\0';
|
||||
for ( i = 0; i < PATH_MAX - 1; i++ ) {
|
||||
Longest_Name[ i ] = 'L';
|
||||
}
|
||||
Longest_Name[ i ] = '\0';
|
||||
return Longest_Name;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,7 @@ rtems_status_code benchmark_timer_empty_function( void )
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
void benchmark_timer_empty_operation(
|
||||
int iteration,
|
||||
void *argument
|
||||
)
|
||||
void benchmark_timer_empty_operation( int iteration, void *argument )
|
||||
{
|
||||
(void) iteration;
|
||||
(void) argument;
|
||||
|
||||
@@ -37,34 +37,28 @@
|
||||
#include "tmtests_empty_function.h"
|
||||
|
||||
void rtems_time_test_measure_operation(
|
||||
const char *description,
|
||||
rtems_time_test_method_t operation,
|
||||
void *argument,
|
||||
int iterations,
|
||||
int overhead
|
||||
const char *description,
|
||||
rtems_time_test_method_t operation,
|
||||
void *argument,
|
||||
int iterations,
|
||||
int overhead
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
uint32_t loop_overhead;
|
||||
uint32_t end_time;
|
||||
|
||||
benchmark_timer_initialize();
|
||||
for (i=0 ; i<iterations ; i++ ) {
|
||||
benchmark_timer_empty_operation( i, argument );
|
||||
}
|
||||
for ( i = 0; i < iterations; i++ ) {
|
||||
benchmark_timer_empty_operation( i, argument );
|
||||
}
|
||||
loop_overhead = benchmark_timer_read();
|
||||
|
||||
benchmark_timer_initialize();
|
||||
for (i=0 ; i<iterations ; i++ ) {
|
||||
(*operation)( i, argument );
|
||||
}
|
||||
for ( i = 0; i < iterations; i++ ) {
|
||||
( *operation )( i, argument );
|
||||
}
|
||||
end_time = benchmark_timer_read();
|
||||
|
||||
put_time(
|
||||
description,
|
||||
end_time,
|
||||
iterations,
|
||||
loop_overhead,
|
||||
overhead
|
||||
);
|
||||
put_time( description, end_time, iterations, loop_overhead, overhead );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user