diff options
author | Chris Johns <chrisj@rtems.org> | 2016-05-20 18:39:50 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2016-05-25 15:47:34 +1000 |
commit | 24d0ee57a4d95f99be6e7e60bd162a30daf0638d (patch) | |
tree | 94239c8cc6b21813ca44b6ca89da73f9038914cc /testsuites/support | |
parent | b1860df53df538c28104f3161ae98d08f07dd4bf (diff) |
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.
Diffstat (limited to 'testsuites/support')
-rw-r--r-- | testsuites/support/include/buffer_test_io.h | 16 | ||||
-rw-r--r-- | testsuites/support/include/test_support.h | 2 | ||||
-rw-r--r-- | testsuites/support/src/locked_print.c | 42 |
3 files changed, 32 insertions, 28 deletions
diff --git a/testsuites/support/include/buffer_test_io.h b/testsuites/support/include/buffer_test_io.h index e5fbd2b0f3..0ae3909d4d 100644 --- a/testsuites/support/include/buffer_test_io.h +++ b/testsuites/support/include/buffer_test_io.h @@ -24,7 +24,7 @@ extern "C" { */ #if defined(TESTS_USE_PRINTK) -#include <rtems/bspIo.h> +#include <rtems/print.h> #undef printf #define printf(...) \ @@ -54,9 +54,9 @@ extern "C" { do { \ } while (0) - #define TEST_BEGIN() rtems_test_begink() + #define TEST_BEGIN() printk(TEST_BEGIN_STRING) - #define TEST_END() rtems_test_endk() + #define TEST_END() printk(TEST_END_STRING) /* * BUFFER TEST OUTPUT @@ -156,9 +156,9 @@ extern "C" { fflush(stdout); \ } while (0) - #define TEST_BEGIN() rtems_test_begin() + #define TEST_BEGIN() printf(TEST_BEGIN_STRING) - #define TEST_END() rtems_test_end() + #define TEST_END() printf(TEST_END_STRING) /* * USE IPRINT @@ -205,11 +205,9 @@ extern "C" { fflush(stdout); \ } while (0) - #define TEST_BEGIN() \ - rtems_test_begin_with_plugin((rtems_printk_plugin_t) fiprintf, stderr) + #define TEST_BEGIN() fiprintf( stderr, TEST_BEGIN_STRING) - #define TEST_END() \ - rtems_test_end_with_plugin((rtems_printk_plugin_t) fiprintf, stderr) + #define TEST_END() fiprintf( stderr, TEST_END_STRING) #endif diff --git a/testsuites/support/include/test_support.h b/testsuites/support/include/test_support.h index 7c459ff1d9..d6870b2ded 100644 --- a/testsuites/support/include/test_support.h +++ b/testsuites/support/include/test_support.h @@ -74,8 +74,6 @@ int locked_printf(const char *fmt, ...); int locked_vprintf(const char *fmt, va_list ap); -int locked_printf_plugin(void *context, const char *fmt, ...); - void locked_printk(const char *fmt, ...); #ifdef __cplusplus diff --git a/testsuites/support/src/locked_print.c b/testsuites/support/src/locked_print.c index 8414479061..7c0df667f8 100644 --- a/testsuites/support/src/locked_print.c +++ b/testsuites/support/src/locked_print.c @@ -1,4 +1,4 @@ -/* +/* * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * @@ -14,7 +14,23 @@ #include "test_support.h" #include "tmacros.h" -static rtems_id locked_print_semaphore; /* synchronisation semaphore */ +static rtems_id locked_print_semaphore; /* synchronisation semaphore */ + +rtems_printer rtems_test_printer; + +static int locked_printf_plugin(void *context, const char *fmt, ...) +{ + int rv; + va_list ap; + + (void) context; + + va_start(ap, fmt); + rv = locked_vprintf(fmt, ap); + va_end(ap); + + return rv; +} void locked_print_initialize(void) { @@ -29,7 +45,7 @@ void locked_print_initialize(void) /* Create/verify synchronisation semaphore */ sc = rtems_semaphore_create( rtems_build_name ('S', 'E', 'M', '1'), - 1, + 1, RTEMS_LOCAL | RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY_CEILING | @@ -38,6 +54,12 @@ void locked_print_initialize(void) &locked_print_semaphore ); directive_failed( sc, "rtems_semaphore_create" ); + + /* + * Set up the printer to use the locked printf printer. + */ + rtems_test_printer.context = NULL; + rtems_test_printer.context = locked_printf_plugin; } int locked_vprintf(const char *fmt, va_list ap) @@ -60,20 +82,6 @@ int locked_vprintf(const char *fmt, va_list ap) return rv; } -int locked_printf_plugin(void *context, const char *fmt, ...) -{ - int rv; - va_list ap; - - (void) context; - - va_start(ap, fmt); - rv = locked_vprintf(fmt, ap); - va_end(ap); - - return rv; -} - int locked_printf(const char *fmt, ...) { int rv; |