From 24d0ee57a4d95f99be6e7e60bd162a30daf0638d Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Fri, 20 May 2016 18:39:50 +1000 Subject: cpukit, testsuite: Add rtems_printf and rtems_printer support. This change adds rtems_printf and related functions and wraps the RTEMS print plugin support into a user API. All references to the plugin are removed and replaced with the rtems_printer interface. Printk and related functions are made to return a valid number of characters formatted and output. The function attribute to check printf functions has been added to rtems_printf and printk. No changes to remove warrnings are part of this patch set. The testsuite has been moved over to the rtems_printer. The testsuite has a mix of rtems_printer access and direct print control via the tmacros.h header file. The support for begink/endk has been removed as it served no purpose and only confused the code base. The testsuite has not been refactored to use rtems_printf. This is future work. --- testsuites/sptests/sperror01/init.c | 4 +++- testsuites/sptests/sperror02/init.c | 6 ++++-- testsuites/sptests/sperror03/init.c | 5 +++-- testsuites/sptests/spextensions01/init.c | 9 +++++---- testsuites/sptests/spfatal07/testcase.h | 2 +- testsuites/sptests/spfatal16/testcase.h | 4 ++-- testsuites/sptests/spfatal26/init.c | 5 +++-- testsuites/sptests/spfatal_support/init.c | 5 ++--- testsuites/sptests/spfatal_support/system.h | 6 ++++-- testsuites/sptests/spinternalerror01/init.c | 9 +++++---- testsuites/sptests/spprintk/init.c | 17 ++++++++++++----- testsuites/sptests/spprofiling01/init.c | 4 +++- testsuites/sptests/spsysinit01/init.c | 8 +++++--- testsuites/sptests/sptimecounter01/init.c | 9 +++++---- 14 files changed, 57 insertions(+), 36 deletions(-) (limited to 'testsuites/sptests') diff --git a/testsuites/sptests/sperror01/init.c b/testsuites/sptests/sperror01/init.c index 4c40be5299..a84eaf9293 100644 --- a/testsuites/sptests/sperror01/init.c +++ b/testsuites/sptests/sperror01/init.c @@ -11,7 +11,9 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include + #include "test_support.h" #include "rtems/error.h" #include @@ -32,7 +34,7 @@ static void fatal_extension( && !is_internal && error == ENOMEM ) { - rtems_test_endk(); + TEST_END(); } } diff --git a/testsuites/sptests/sperror02/init.c b/testsuites/sptests/sperror02/init.c index dca2219305..0bb7ceaf34 100644 --- a/testsuites/sptests/sperror02/init.c +++ b/testsuites/sptests/sperror02/init.c @@ -11,7 +11,9 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include + #include "test_support.h" #include #include @@ -32,7 +34,7 @@ static void fatal_extension( && !is_internal && error == 1 ) { - rtems_test_endk(); + TEST_END(); } } @@ -44,7 +46,7 @@ rtems_task Init( errno = ENOMEM; rtems_error( - RTEMS_NO_MEMORY | RTEMS_ERROR_ABORT, + RTEMS_NO_MEMORY | RTEMS_ERROR_ABORT, "Dummy: Resources unavailable\n" ); diff --git a/testsuites/sptests/sperror03/init.c b/testsuites/sptests/sperror03/init.c index 818b90755c..aecdb79288 100644 --- a/testsuites/sptests/sperror03/init.c +++ b/testsuites/sptests/sperror03/init.c @@ -11,7 +11,8 @@ #include "config.h" #endif -#include +#define TESTS_USE_PRINTK +#include "tmacros.h" #include "test_support.h" const char rtems_test_name[] = "SPERROR 3"; @@ -30,7 +31,7 @@ static void fatal_extension( && !is_internal && error == 0 ) { - rtems_test_endk(); + TEST_END(); } } diff --git a/testsuites/sptests/spextensions01/init.c b/testsuites/sptests/spextensions01/init.c index d8593b9980..091d66f0ab 100644 --- a/testsuites/sptests/spextensions01/init.c +++ b/testsuites/sptests/spextensions01/init.c @@ -16,12 +16,13 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include #include #include -#include - #include const char rtems_test_name[] = "SPEXTENSIONS 1"; @@ -199,7 +200,7 @@ static void two_fatal( if (source == RTEMS_FATAL_SOURCE_EXIT) { assert_reverse_order(2); assert(counter == 72); - rtems_test_endk(); + TEST_END(); } } @@ -424,7 +425,7 @@ static void test(void) static void Init(rtems_task_argument arg) { - rtems_test_begink(); + TEST_BEGIN(); test(); diff --git a/testsuites/sptests/spfatal07/testcase.h b/testsuites/sptests/spfatal07/testcase.h index 5ccaaa48d5..7cc9a5f468 100644 --- a/testsuites/sptests/spfatal07/testcase.h +++ b/testsuites/sptests/spfatal07/testcase.h @@ -50,7 +50,7 @@ void force_error() "WARNING - Test not applicable on this target architecture.\n" "WARNING - Only applicable when CPU_ALLOCATE_INTERRUPT_STACK == TRUE.\n" ); - rtems_test_endk(); + TEST_END(); rtems_test_exit(0); #endif } diff --git a/testsuites/sptests/spfatal16/testcase.h b/testsuites/sptests/spfatal16/testcase.h index 65af957b83..743b2be9b5 100644 --- a/testsuites/sptests/spfatal16/testcase.h +++ b/testsuites/sptests/spfatal16/testcase.h @@ -7,7 +7,7 @@ * http://www.rtems.org/license/LICENSE. */ -/* generate fatal errors in termios.c +/* generate fatal errors in termios.c * rtems_semaphore_create( rtems_build_name ('T', 'R', 'r', c),...); */ @@ -25,6 +25,6 @@ void force_error() { /* This fatal error depends on the Termios device configuration */ - rtems_test_endk(); + TEST_END(); rtems_test_exit(0); } diff --git a/testsuites/sptests/spfatal26/init.c b/testsuites/sptests/spfatal26/init.c index 7235f8d25a..4013b948fc 100644 --- a/testsuites/sptests/spfatal26/init.c +++ b/testsuites/sptests/spfatal26/init.c @@ -16,6 +16,7 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include "tmacros.h" #include @@ -51,7 +52,7 @@ static void provoke_aligment_or_data_access_exception( void ) static void Init( rtems_task_argument arg ) { - rtems_test_begink(); + TEST_BEGIN(); provoke_aligment_or_data_access_exception(); @@ -69,7 +70,7 @@ static void fatal_extension( rtems_exception_frame_print( (const rtems_exception_frame *) code ); - rtems_test_endk(); + TEST_END(); } #define CONFIGURE_INITIAL_EXTENSIONS \ diff --git a/testsuites/sptests/spfatal_support/init.c b/testsuites/sptests/spfatal_support/init.c index 1052da4289..f048d4b3c1 100644 --- a/testsuites/sptests/spfatal_support/init.c +++ b/testsuites/sptests/spfatal_support/init.c @@ -22,7 +22,7 @@ static void print_test_begin_message(void) if (!done) { done = true; - rtems_test_begink(); + TEST_BEGIN(); } } @@ -107,7 +107,6 @@ void Fatal_extension( && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL && is_expected_error( error ) ) { - rtems_test_endk(); + TEST_END(); } } - diff --git a/testsuites/sptests/spfatal_support/system.h b/testsuites/sptests/spfatal_support/system.h index 19adb47e7d..0a01e21d70 100644 --- a/testsuites/sptests/spfatal_support/system.h +++ b/testsuites/sptests/spfatal_support/system.h @@ -14,9 +14,11 @@ /* * Some of the fatal error cases require the ability to peek inside RTEMS */ + +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include -#include -#include /* functions */ diff --git a/testsuites/sptests/spinternalerror01/init.c b/testsuites/sptests/spinternalerror01/init.c index a1ddc14eae..e864db169a 100644 --- a/testsuites/sptests/spinternalerror01/init.c +++ b/testsuites/sptests/spinternalerror01/init.c @@ -16,11 +16,12 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include #include -#include - const char rtems_test_name[] = "SPINTERNALERROR 1"; #define FATAL_SOURCE 0xdeadbeef @@ -40,14 +41,14 @@ static void fatal_extension( Internal_errors_t error ) { - rtems_test_begink(); + TEST_BEGIN(); if ( source == FATAL_SOURCE && is_internal == FATAL_IS_INTERNAL && error == FATAL_ERROR ) { - rtems_test_endk(); + TEST_END(); } } diff --git a/testsuites/sptests/spprintk/init.c b/testsuites/sptests/spprintk/init.c index eea17adcf2..8086a1ae10 100644 --- a/testsuites/sptests/spprintk/init.c +++ b/testsuites/sptests/spprintk/init.c @@ -13,11 +13,19 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include -#include +#include const char rtems_test_name[] = "SPPRINTK"; +/* + * Undefined the RTEMS_PRINTF_ATTRIBUTE and make it nothing. The test code + * contained in the file is suppose to be wrong. + */ +#undef RTEMS_PRINTF_ATTRIBUTE +#define RTEMS_PRINTF_ATTRIBUTE(_a, _b) + /* forward declarations to avoid warnings */ rtems_task Init(rtems_task_argument argument); int test_getchar(void); @@ -38,7 +46,7 @@ void do_getchark(void) poll_char = BSP_poll_char; BSP_poll_char = NULL; - + putk( "getchark - NULL getchar method - return -1" ); sc = getchark(); rtems_test_assert( sc == -1 ); @@ -124,7 +132,7 @@ rtems_task Init( rtems_task_argument argument ) { - rtems_test_begink(); + TEST_BEGIN(); do_putk(); putk(""); @@ -134,7 +142,7 @@ rtems_task Init( do_getchark(); - rtems_test_endk(); + TEST_END(); rtems_test_exit( 0 ); } @@ -151,4 +159,3 @@ rtems_task Init( #define CONFIGURE_INIT #include - diff --git a/testsuites/sptests/spprofiling01/init.c b/testsuites/sptests/spprofiling01/init.c index afbe2c74db..60f6bd50ed 100644 --- a/testsuites/sptests/spprofiling01/init.c +++ b/testsuites/sptests/spprofiling01/init.c @@ -115,13 +115,15 @@ static void test_iterate(void) static void test_report_xml(void) { + rtems_printer printer; rtems_status_code sc; int rv; sc = rtems_task_wake_after(3); rtems_test_assert(sc == RTEMS_SUCCESSFUL); - rv = rtems_profiling_report_xml("X", rtems_printf_plugin, NULL, 1, " "); + rtems_print_printer_printf(&printer); + rv = rtems_profiling_report_xml("X", &printer, 1, " "); printf("characters produced by rtems_profiling_report_xml(): %i\n", rv); } diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c index e12f7f3bc1..c598ee5acf 100644 --- a/testsuites/sptests/spsysinit01/init.c +++ b/testsuites/sptests/spsysinit01/init.c @@ -16,6 +16,9 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include #include @@ -29,7 +32,6 @@ #include #include #include -#include #include #ifdef RTEMS_POSIX_API @@ -173,7 +175,7 @@ static void next_step(init_step expected) FIRST(RTEMS_SYSINIT_BSP_WORK_AREAS) { - rtems_test_begink(); + TEST_BEGIN(); assert(_Workspace_Area.area_begin == 0); next_step(BSP_WORK_AREAS_PRE); } @@ -674,7 +676,7 @@ static void Init(rtems_task_argument arg) pthread_cleanup_pop(0); #endif /* RTEMS_POSIX_API */ next_step(INIT_TASK); - rtems_test_endk(); + TEST_END(); exit(0); } diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c index d87ffec460..9e396de054 100644 --- a/testsuites/sptests/sptimecounter01/init.c +++ b/testsuites/sptests/sptimecounter01/init.c @@ -16,12 +16,13 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include #include -#include - #include #include #include @@ -54,7 +55,7 @@ void boot_card(const char *cmdline) struct timeval tv; struct timespec ts; - rtems_test_begink(); + TEST_BEGIN(); assert(time(NULL) == TOD_SECONDS_1970_THROUGH_1988); @@ -148,7 +149,7 @@ void boot_card(const char *cmdline) assert(bt.sec == 1); assert(bt.frac == 18446742522092); - rtems_test_endk(); + TEST_END(); _Terminate(RTEMS_FATAL_SOURCE_EXIT, false, 0); } -- cgit v1.2.3