forked from Imagelibrary/rtems
tests: Use ld to map (wrap) printf, puts and putchar to tester functions.
- Remove the macro defines and the need for tmacro.h by remapping the symbols using ld's wrap option. - Remove FLUSH_OUTPUT, it was empty. - Move rtems_test_exit to libmisc/testsupport as a function. Update #3199.
This commit is contained in:
@@ -182,6 +182,7 @@ libtestsupport_a_SOURCES += testsupport/testbeginend.c
|
|||||||
libtestsupport_a_SOURCES += testsupport/testbusy.c
|
libtestsupport_a_SOURCES += testsupport/testbusy.c
|
||||||
libtestsupport_a_SOURCES += testsupport/testextension.c
|
libtestsupport_a_SOURCES += testsupport/testextension.c
|
||||||
libtestsupport_a_SOURCES += testsupport/testparallel.c
|
libtestsupport_a_SOURCES += testsupport/testparallel.c
|
||||||
|
libtestsupport_a_SOURCES += testsupport/testwrappers.c
|
||||||
|
|
||||||
## fsmount
|
## fsmount
|
||||||
noinst_LIBRARIES += libfsmount.a
|
noinst_LIBRARIES += libfsmount.a
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state);
|
|||||||
*/
|
*/
|
||||||
int rtems_test_end(const char* name);
|
int rtems_test_end(const char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Exit the test without calling exit() since it closes stdin, etc and
|
||||||
|
* pulls in stdio code
|
||||||
|
*/
|
||||||
|
void rtems_test_exit(int status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints via the RTEMS printer.
|
* @brief Prints via the RTEMS printer.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -123,6 +123,12 @@ int rtems_test_end(const char* name)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtems_test_exit(int status)
|
||||||
|
{
|
||||||
|
(void) status;
|
||||||
|
rtems_shutdown_executive(0);
|
||||||
|
}
|
||||||
|
|
||||||
int rtems_test_printf(
|
int rtems_test_printf(
|
||||||
const char* format,
|
const char* format,
|
||||||
...
|
...
|
||||||
|
|||||||
48
cpukit/libmisc/testsupport/testwrappers.c
Normal file
48
cpukit/libmisc/testsupport/testwrappers.c
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.org/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rtems/test.h>
|
||||||
|
|
||||||
|
int __wrap_printf(const char* format, ...);
|
||||||
|
int __wrap_puts(const char *str);
|
||||||
|
int __wrap_putchar(int c);
|
||||||
|
|
||||||
|
int __wrap_printf(
|
||||||
|
const char* format,
|
||||||
|
...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int len;
|
||||||
|
va_start(ap, format);
|
||||||
|
len = rtems_vprintf(
|
||||||
|
&rtems_test_printer,
|
||||||
|
format,
|
||||||
|
ap
|
||||||
|
);
|
||||||
|
va_end(ap);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int __wrap_puts(
|
||||||
|
const char *str
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return rtems_test_printf( "%s\n", str );
|
||||||
|
}
|
||||||
|
|
||||||
|
int __wrap_putchar(
|
||||||
|
int c
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return rtems_test_printf( "%c", c );
|
||||||
|
}
|
||||||
@@ -10,7 +10,8 @@ STRIP = @STRIP@
|
|||||||
|
|
||||||
##
|
##
|
||||||
AM_CPPFLAGS = $(TEST_FLAGS)
|
AM_CPPFLAGS = $(TEST_FLAGS)
|
||||||
AM_CFLAGS =
|
AM_CFLAGS = $(TEST_C_FLAGS)
|
||||||
AM_CXXFLAGS =
|
AM_CXXFLAGS = $(TEST_CXX_FLAGS)
|
||||||
|
AM_LDFLAGS = $(TEST_LD_FLAGS)
|
||||||
|
|
||||||
CLEANFILES = *.num *.nxe *.elf *.srec* *.bin *.bt *.ralf
|
CLEANFILES = *.num *.nxe *.elf *.srec* *.bin *.bt *.ralf
|
||||||
|
|||||||
@@ -2,3 +2,5 @@ preinstall:
|
|||||||
.PHONY: preinstall
|
.PHONY: preinstall
|
||||||
|
|
||||||
PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools
|
PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools
|
||||||
|
|
||||||
|
TEST_LD_FLAGS = -Wl,--wrap=printf -Wl,--wrap=puts -Wl,--wrap=putchar
|
||||||
|
|||||||
@@ -105,8 +105,6 @@ rtems_task Task_1_through_5(
|
|||||||
|
|
||||||
printf( "TA5 - PERIODS CHECK OK (%" PRIu32 ")\n", pass );
|
printf( "TA5 - PERIODS CHECK OK (%" PRIu32 ")\n", pass );
|
||||||
|
|
||||||
FLUSH_OUTPUT();
|
|
||||||
|
|
||||||
if ( pass == 10 ) {
|
if ( pass == 10 ) {
|
||||||
puts( "" );
|
puts( "" );
|
||||||
rtems_rate_monotonic_report_statistics();
|
rtems_rate_monotonic_report_statistics();
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ rtems_asr Process_asr(
|
|||||||
case RTEMS_SIGNAL_0:
|
case RTEMS_SIGNAL_0:
|
||||||
case RTEMS_SIGNAL_1:
|
case RTEMS_SIGNAL_1:
|
||||||
puts( "ASR - rtems_task_wake_after - yield processor" );
|
puts( "ASR - rtems_task_wake_after - yield processor" );
|
||||||
FLUSH_OUTPUT();
|
|
||||||
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
||||||
directive_failed( status, "rtems_task_wake_after yield" );
|
directive_failed( status, "rtems_task_wake_after yield" );
|
||||||
break;
|
break;
|
||||||
@@ -44,5 +43,4 @@ rtems_asr Process_asr(
|
|||||||
"ASR - EXIT - signal => %08" PRIxrtems_signal_set "\n",
|
"ASR - EXIT - signal => %08" PRIxrtems_signal_set "\n",
|
||||||
the_signal_set
|
the_signal_set
|
||||||
);
|
);
|
||||||
FLUSH_OUTPUT();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ rtems_task Task_1(
|
|||||||
status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR );
|
status = rtems_signal_catch( Process_asr, RTEMS_NO_ASR );
|
||||||
directive_failed( status, "rtems_signal_catch" );
|
directive_failed( status, "rtems_signal_catch" );
|
||||||
|
|
||||||
FLUSH_OUTPUT();
|
rtems_test_pause();
|
||||||
|
|
||||||
rtems_test_pause();
|
|
||||||
|
|
||||||
puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_1 to self" );
|
puts( "TA1 - rtems_signal_send - RTEMS_SIGNAL_1 to self" );
|
||||||
status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
|
status = rtems_signal_send( RTEMS_SELF, RTEMS_SIGNAL_1 );
|
||||||
@@ -98,7 +96,6 @@ rtems_test_pause();
|
|||||||
);
|
);
|
||||||
|
|
||||||
puts( "TA1 - rtems_task_mode - enable ASRs" );
|
puts( "TA1 - rtems_task_mode - enable ASRs" );
|
||||||
FLUSH_OUTPUT();
|
|
||||||
status = rtems_task_mode( RTEMS_ASR, RTEMS_ASR_MASK, &previous_mode );
|
status = rtems_task_mode( RTEMS_ASR, RTEMS_ASR_MASK, &previous_mode );
|
||||||
directive_failed( status, "rtems_task_mode" );
|
directive_failed( status, "rtems_task_mode" );
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ rtems_task Task_2(
|
|||||||
directive_failed( status, "rtems_signal_send" );
|
directive_failed( status, "rtems_signal_send" );
|
||||||
|
|
||||||
puts( "TA2 - rtems_task_wake_after - yield processor" );
|
puts( "TA2 - rtems_task_wake_after - yield processor" );
|
||||||
FLUSH_OUTPUT();
|
|
||||||
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
|
||||||
directive_failed( status, "rtems_task_wake_after" );
|
directive_failed( status, "rtems_task_wake_after" );
|
||||||
|
|
||||||
|
|||||||
@@ -11,34 +11,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef printf
|
|
||||||
#define printf(...) \
|
|
||||||
do { \
|
|
||||||
rtems_printf( &rtems_test_printer, __VA_ARGS__ ); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#undef puts
|
|
||||||
#define puts(_s) \
|
|
||||||
do { \
|
|
||||||
rtems_printf( &rtems_test_printer, "%s\n", _s ); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#undef putchar
|
|
||||||
#define putchar(_c) \
|
|
||||||
do { \
|
|
||||||
rtems_printf( &rtems_test_printer, "%c", _c ); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* Do not call exit() since it closes stdin, etc and pulls in stdio code */
|
|
||||||
#define rtems_test_exit(_s) \
|
|
||||||
do { \
|
|
||||||
rtems_shutdown_executive(0); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define FLUSH_OUTPUT() \
|
|
||||||
do { \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define TEST_BEGIN() rtems_test_begin(rtems_test_name, TEST_STATE)
|
#define TEST_BEGIN() rtems_test_begin(rtems_test_name, TEST_STATE)
|
||||||
#define TEST_END() rtems_test_end(rtems_test_name)
|
#define TEST_END() rtems_test_end(rtems_test_name)
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ extern "C" {
|
|||||||
"\n_Thread_Dispatch_disable_level is (%i)" \
|
"\n_Thread_Dispatch_disable_level is (%i)" \
|
||||||
" not %d detected at %s:%d\n", \
|
" not %d detected at %s:%d\n", \
|
||||||
!_Thread_Dispatch_is_enabled(), (_expect), __FILE__, __LINE__ ); \
|
!_Thread_Dispatch_is_enabled(), (_expect), __FILE__, __LINE__ ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( 1 ); \
|
rtems_test_exit( 1 ); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
@@ -84,7 +83,6 @@ extern "C" {
|
|||||||
__FILE__, \
|
__FILE__, \
|
||||||
__LINE__ \
|
__LINE__ \
|
||||||
); \
|
); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( 1 ); \
|
rtems_test_exit( 1 ); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
@@ -107,7 +105,6 @@ extern "C" {
|
|||||||
if ( (_stat) != (_desired) ) { \
|
if ( (_stat) != (_desired) ) { \
|
||||||
printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
|
printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
|
||||||
(_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
|
(_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( _stat ); \
|
rtems_test_exit( _stat ); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
@@ -137,7 +134,6 @@ extern "C" {
|
|||||||
printf( "\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \
|
printf( "\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \
|
||||||
(_msg), _desired, strerror(_desired), \
|
(_msg), _desired, strerror(_desired), \
|
||||||
statx, errno, strerror(errno) ); \
|
statx, errno, strerror(errno) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( _stat ); \
|
rtems_test_exit( _stat ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +149,6 @@ extern "C" {
|
|||||||
(_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
|
(_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
|
||||||
printf( "\n FAILED -- errno (%d - %s)\n", \
|
printf( "\n FAILED -- errno (%d - %s)\n", \
|
||||||
errno, strerror(errno) ); \
|
errno, strerror(errno) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( _stat ); \
|
rtems_test_exit( _stat ); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
@@ -166,7 +161,6 @@ extern "C" {
|
|||||||
check_dispatch_disable_level( 0 ); \
|
check_dispatch_disable_level( 0 ); \
|
||||||
printf( "\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \
|
printf( "\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \
|
||||||
(_msg), _ptr, errno, strerror(errno) ); \
|
(_msg), _ptr, errno, strerror(errno) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( -1 ); \
|
rtems_test_exit( -1 ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +172,6 @@ extern "C" {
|
|||||||
check_dispatch_disable_level( 0 ); \
|
check_dispatch_disable_level( 0 ); \
|
||||||
printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
|
printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
|
||||||
(_msg), _ptr, errno, strerror(errno) ); \
|
(_msg), _ptr, errno, strerror(errno) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( -1 ); \
|
rtems_test_exit( -1 ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +195,6 @@ extern "C" {
|
|||||||
if ( (_stat) != (_desired) ) { \
|
if ( (_stat) != (_desired) ) { \
|
||||||
printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
|
printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
|
||||||
(_msg), (_desired), (_stat) ); \
|
(_msg), (_desired), (_stat) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
rtems_test_exit( _stat ); \
|
rtems_test_exit( _stat ); \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
@@ -229,7 +221,6 @@ extern "C" {
|
|||||||
#define put_dot( _c ) \
|
#define put_dot( _c ) \
|
||||||
do { \
|
do { \
|
||||||
putchar( _c ); \
|
putchar( _c ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
#define new_line puts( "" )
|
#define new_line puts( "" )
|
||||||
@@ -240,20 +231,17 @@ extern "C" {
|
|||||||
#define rtems_test_pause() \
|
#define rtems_test_pause() \
|
||||||
do { \
|
do { \
|
||||||
printf( "<pause>\n" ); \
|
printf( "<pause>\n" ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
#define rtems_test_pause_and_screen_number( _screen ) \
|
#define rtems_test_pause_and_screen_number( _screen ) \
|
||||||
do { \
|
do { \
|
||||||
printf( "<pause - screen %d>\n", (_screen) ); \
|
printf( "<pause - screen %d>\n", (_screen) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
#else
|
#else
|
||||||
#define rtems_test_pause() \
|
#define rtems_test_pause() \
|
||||||
do { \
|
do { \
|
||||||
char buffer[ 80 ]; \
|
char buffer[ 80 ]; \
|
||||||
printf( "<pause>" ); \
|
printf( "<pause>" ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
gets( buffer ); \
|
gets( buffer ); \
|
||||||
puts( "" ); \
|
puts( "" ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
@@ -262,7 +250,6 @@ extern "C" {
|
|||||||
do { \
|
do { \
|
||||||
char buffer[ 80 ]; \
|
char buffer[ 80 ]; \
|
||||||
printf( "<pause - screen %d>", (_screen) ); \
|
printf( "<pause - screen %d>", (_screen) ); \
|
||||||
FLUSH_OUTPUT(); \
|
|
||||||
gets( buffer ); \
|
gets( buffer ); \
|
||||||
puts( "" ); \
|
puts( "" ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user