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/libtests | |
parent | psxtests/psxmsgq01: Fix typo (diff) | |
download | rtems-24d0ee57a4d95f99be6e7e60bd162a30daf0638d.tar.bz2 |
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/libtests')
22 files changed, 79 insertions, 42 deletions
diff --git a/testsuites/libtests/block02/init.c b/testsuites/libtests/block02/init.c index f53dacc6d8..863064109b 100644 --- a/testsuites/libtests/block02/init.c +++ b/testsuites/libtests/block02/init.c @@ -24,6 +24,7 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include "tmacros.h" #include <rtems.h> @@ -82,7 +83,7 @@ static void task_low(rtems_task_argument arg) rtems_test_assert(bd->dd == dd_a); - rtems_test_endk(); + TEST_END(); exit(0); } @@ -136,7 +137,7 @@ static rtems_task Init(rtems_task_argument argument) dev_t dev_a = 0; dev_t dev_b = 0; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_disk_io_initialize(); ASSERT_SC(sc); diff --git a/testsuites/libtests/block03/init.c b/testsuites/libtests/block03/init.c index 1da59f0643..f2a18b9a7c 100644 --- a/testsuites/libtests/block03/init.c +++ b/testsuites/libtests/block03/init.c @@ -24,6 +24,7 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include "tmacros.h" #include <rtems.h> @@ -76,7 +77,7 @@ static void task_low(rtems_task_argument arg) rtems_test_assert(bd->block == 0); - rtems_test_endk(); + TEST_END(); exit(0); } @@ -129,7 +130,7 @@ static rtems_task Init(rtems_task_argument argument) rtems_bdbuf_buffer *bd = NULL; dev_t dev = 0; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_disk_io_initialize(); ASSERT_SC(sc); diff --git a/testsuites/libtests/block04/init.c b/testsuites/libtests/block04/init.c index 6731556163..3f448c7605 100644 --- a/testsuites/libtests/block04/init.c +++ b/testsuites/libtests/block04/init.c @@ -24,6 +24,7 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include "tmacros.h" #include <rtems.h> @@ -101,7 +102,7 @@ static void task_high(rtems_task_argument arg) printk("H: release done: 0\n"); - rtems_test_endk(); + TEST_END(); exit(0); } @@ -111,7 +112,7 @@ static rtems_task Init(rtems_task_argument argument) rtems_status_code sc = RTEMS_SUCCESSFUL; dev_t dev = 0; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_disk_io_initialize(); ASSERT_SC(sc); diff --git a/testsuites/libtests/block05/init.c b/testsuites/libtests/block05/init.c index 59889cc556..7cce2acfd0 100644 --- a/testsuites/libtests/block05/init.c +++ b/testsuites/libtests/block05/init.c @@ -24,6 +24,7 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK #include "tmacros.h" #include <stdarg.h> #include <errno.h> @@ -426,7 +427,7 @@ static rtems_task Init(rtems_task_argument argument) rtems_status_code sc = RTEMS_SUCCESSFUL; unsigned i = 0; - rtems_test_begink(); + TEST_BEGIN(); task_id_init = rtems_task_self(); @@ -505,7 +506,7 @@ static rtems_task Init(rtems_task_argument argument) } } - rtems_test_endk(); + TEST_END(); exit(0); } diff --git a/testsuites/libtests/block06/init.c b/testsuites/libtests/block06/init.c index 22340344db..1b91ad7ab2 100644 --- a/testsuites/libtests/block06/init.c +++ b/testsuites/libtests/block06/init.c @@ -32,7 +32,7 @@ #include <bsp.h> -#include <tmacros.h> +#include "tmacros.h" const char rtems_test_name[] = "BLOCK 6"; diff --git a/testsuites/libtests/block07/init.c b/testsuites/libtests/block07/init.c index f34e412302..cd1b64abae 100644 --- a/testsuites/libtests/block07/init.c +++ b/testsuites/libtests/block07/init.c @@ -27,6 +27,8 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> + +#define TESTS_USE_PRINTK #include "tmacros.h" #include <rtems.h> @@ -102,7 +104,7 @@ static void task_low(rtems_task_argument arg) printk("L: release done: 0\n"); - rtems_test_endk(); + TEST_END(); exit(0); } @@ -164,7 +166,7 @@ static rtems_task Init(rtems_task_argument argument) rtems_bdbuf_buffer *bd = NULL; dev_t dev = 0; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_disk_io_initialize(); ASSERT_SC(sc); diff --git a/testsuites/libtests/block08/init.c b/testsuites/libtests/block08/init.c index 84e755fc53..83eaf6d534 100644 --- a/testsuites/libtests/block08/init.c +++ b/testsuites/libtests/block08/init.c @@ -19,6 +19,8 @@ #include "config.h" #endif +#include "tmacros.h" + #define CONFIGURE_INIT #include "system.h" @@ -30,10 +32,9 @@ const char rtems_test_name[] = "BLOCK 8"; rtems_task Init(rtems_task_argument argument) { - rtems_test_begin(); + TEST_BEGIN(); run_bdbuf_tests(); - rtems_test_end(); + TEST_END(); exit(0); } - diff --git a/testsuites/libtests/block09/init.c b/testsuites/libtests/block09/init.c index 2d7cc7aec7..45e3b7ad39 100644 --- a/testsuites/libtests/block09/init.c +++ b/testsuites/libtests/block09/init.c @@ -24,6 +24,9 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include <assert.h> #include <errno.h> #include <stdlib.h> @@ -176,7 +179,7 @@ static rtems_task Init(rtems_task_argument argument) dev_t dev = 0; rtems_disk_device *dd = NULL; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_disk_io_initialize(); ASSERT_SC(sc); @@ -224,7 +227,7 @@ static rtems_task Init(rtems_task_argument argument) sc = rtems_disk_release(dd); ASSERT_SC(sc); - rtems_test_endk(); + TEST_END(); exit(0); } diff --git a/testsuites/libtests/block10/init.c b/testsuites/libtests/block10/init.c index fac6781d1a..1cdc91ebb1 100644 --- a/testsuites/libtests/block10/init.c +++ b/testsuites/libtests/block10/init.c @@ -23,6 +23,9 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include <assert.h> #include <errno.h> #include <stdlib.h> @@ -402,7 +405,7 @@ static rtems_task Init(rtems_task_argument argument) size_t i_rel = 0; size_t i_p = 0; - rtems_test_begink(); + TEST_BEGIN(); task_id_init = rtems_task_self(); @@ -466,7 +469,7 @@ static rtems_task Init(rtems_task_argument argument) } } - rtems_test_endk(); + TEST_END(); exit(0); } diff --git a/testsuites/libtests/block14/init.c b/testsuites/libtests/block14/init.c index 98282bc931..889e853d75 100644 --- a/testsuites/libtests/block14/init.c +++ b/testsuites/libtests/block14/init.c @@ -118,8 +118,11 @@ static int test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg) static void test_actions(rtems_disk_device *dd) { + rtems_printer printer; int i; + rtems_print_printer_printf(&printer); + for (i = 0; i < ACTION_COUNT; ++i) { const test_action *action = &actions [i]; rtems_status_code sc; @@ -155,7 +158,7 @@ static void test_actions(rtems_disk_device *dd) ); } - rtems_blkdev_print_stats(&dd->stats, 0, 1, 2, rtems_printf_plugin, NULL); + rtems_blkdev_print_stats(&dd->stats, 0, 1, 2, &printer); } static void test(void) diff --git a/testsuites/libtests/capture01/init.c b/testsuites/libtests/capture01/init.c index 7957742702..538583e0e6 100644 --- a/testsuites/libtests/capture01/init.c +++ b/testsuites/libtests/capture01/init.c @@ -33,6 +33,7 @@ rtems_task Init(rtems_task_argument argument); const char rtems_test_name[] = "CAPTURE 1"; +rtems_printer rtems_test_printer; rtems_task Init( rtems_task_argument ignored @@ -46,6 +47,8 @@ rtems_task Init( rtems_mode old_mode; rtems_name to_name = rtems_build_name('I', 'D', 'L', 'E');; + rtems_print_printer_printf(&rtems_test_printer); + rtems_test_begin(); rtems_task_set_priority(RTEMS_SELF, 20, &old_priority); diff --git a/testsuites/libtests/complex/init.c b/testsuites/libtests/complex/init.c index 658af91ef2..3d542fb815 100644 --- a/testsuites/libtests/complex/init.c +++ b/testsuites/libtests/complex/init.c @@ -27,6 +27,7 @@ #include <rtems/test.h> const char rtems_test_name[] = "COMPLEX"; +rtems_printer rtems_test_printer; #endif #include <stdio.h> @@ -60,11 +61,12 @@ int main( void ) #endif { #if __rtems__ + rtems_print_printer_printf(&rtems_test_printer); rtems_test_begin(); #endif docomplex(); - docomplexf(); + docomplexf(); docomplexl(); #if __rtems__ rtems_test_end(); diff --git a/testsuites/libtests/devnullfatal01/testcase.h b/testsuites/libtests/devnullfatal01/testcase.h index 87a098eb42..14675da509 100644 --- a/testsuites/libtests/devnullfatal01/testcase.h +++ b/testsuites/libtests/devnullfatal01/testcase.h @@ -13,6 +13,8 @@ #define FATAL_ERROR_EXPECTED_IS_INTERNAL FALSE #define FATAL_ERROR_EXPECTED_ERROR RTEMS_TOO_MANY +#define TESTS_USE_PRINTK + #include <rtems/devnull.h> #include "tmacros.h" @@ -28,4 +30,3 @@ void force_error() /* A fatal error would be raised in previous call */ /* we will not run this far */ } - diff --git a/testsuites/libtests/exit01/init.c b/testsuites/libtests/exit01/init.c index 6fbad6bbc8..b677c3aab9 100644 --- a/testsuites/libtests/exit01/init.c +++ b/testsuites/libtests/exit01/init.c @@ -16,13 +16,15 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include <stdlib.h> /* Use assert() not rtems_test_assert() since it uses exit() */ #include <assert.h> #include <rtems.h> -#include <rtems/test.h> const char rtems_test_name[] = "EXIT 1"; @@ -60,7 +62,7 @@ static void fatal_extension( && error == EXIT_STATUS && counter == 3 ) { - rtems_test_endk(); + TEST_END(); } } @@ -85,7 +87,7 @@ static void Init(rtems_task_argument arg) rtems_status_code sc; rtems_id id; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_task_create( rtems_build_name('E', 'X', 'I', 'T'), diff --git a/testsuites/libtests/exit02/init.c b/testsuites/libtests/exit02/init.c index 88e08749df..f185d0f72e 100644 --- a/testsuites/libtests/exit02/init.c +++ b/testsuites/libtests/exit02/init.c @@ -16,13 +16,15 @@ #include "config.h" #endif +#define TESTS_USE_PRINTK +#include "tmacros.h" + #include <stdlib.h> /* Use assert() not rtems_test_assert() since it uses exit() */ #include <assert.h> #include <rtems.h> -#include <rtems/test.h> const char rtems_test_name[] = "EXIT 2"; @@ -44,7 +46,7 @@ static void fatal_extension( && !is_internal && error == EXIT_STATUS ) { - rtems_test_endk(); + TEST_END(); } } @@ -63,7 +65,7 @@ static void Init(rtems_task_argument arg) rtems_status_code sc; rtems_id id; - rtems_test_begink(); + TEST_BEGIN(); sc = rtems_task_create( rtems_build_name('E', 'X', 'I', 'T'), diff --git a/testsuites/libtests/math/init.c b/testsuites/libtests/math/init.c index 0d4a97e59f..c045735efa 100644 --- a/testsuites/libtests/math/init.c +++ b/testsuites/libtests/math/init.c @@ -22,11 +22,16 @@ #include "config.h" #endif +/* + * @fixme This test should use the test macros but the include paths are + * are wrong in the build system. + */ #if __rtems__ #include <bsp.h> /* for device driver prototypes */ #include <rtems/test.h> const char rtems_test_name[] = "MATH"; +rtems_printer rtems_test_printer; #endif #include <stdio.h> @@ -58,6 +63,7 @@ int main( void ) #endif { #if __rtems__ + rtems_print_printer_printf(&rtems_test_printer); rtems_test_begin(); #endif @@ -68,4 +74,3 @@ int main( void ) #endif exit( 0 ); } - diff --git a/testsuites/libtests/mathf/init.c b/testsuites/libtests/mathf/init.c index 4cb1994af0..c91e6fe67f 100644 --- a/testsuites/libtests/mathf/init.c +++ b/testsuites/libtests/mathf/init.c @@ -27,6 +27,7 @@ #include <rtems/test.h> const char rtems_test_name[] = "MATHF"; +rtems_printer rtems_test_printer; #endif #include <stdio.h> @@ -58,14 +59,14 @@ int main( void ) #endif { #if __rtems__ + rtems_print_printer_printf(&rtems_test_printer); rtems_test_begin(); #endif - domathf(); + domathf(); #if __rtems__ rtems_test_end(); #endif exit( 0 ); } - diff --git a/testsuites/libtests/mathl/init.c b/testsuites/libtests/mathl/init.c index 0dab9da789..ca26f1178f 100644 --- a/testsuites/libtests/mathl/init.c +++ b/testsuites/libtests/mathl/init.c @@ -27,6 +27,7 @@ #include <rtems/test.h> const char rtems_test_name[] = "MATHL"; +rtems_printer rtems_test_printer; #endif #include <stdio.h> @@ -58,10 +59,11 @@ int main( void ) #endif { #if __rtems__ + rtems_print_printer_printf(&rtems_test_printer); rtems_test_begin(); #endif - domathl(); + domathl(); #if __rtems__ rtems_test_end(); diff --git a/testsuites/libtests/mouse01/init.c b/testsuites/libtests/mouse01/init.c index a002f09452..cc33630efd 100644 --- a/testsuites/libtests/mouse01/init.c +++ b/testsuites/libtests/mouse01/init.c @@ -60,7 +60,7 @@ bool enqueue_next_action( return false; termios_test_driver_set_rx_enqueue_now( true ); - + termios_test_driver_set_rx( &actions[Mouse_Index], to_enqueue ); Mouse_Index += to_enqueue; @@ -95,9 +95,10 @@ void printf_uid_message( struct MW_UID_MESSAGE *uid ) { + rtems_printer printer; + rtems_print_printer_printf( &printer ); uid_print_message_with_plugin( - stdout, - (rtems_printk_plugin_t)fprintf, + &printer, uid ); } @@ -135,16 +136,16 @@ rtems_task Init( TEST_BEGIN(); open_it(); - register_it(); + register_it(); do { more_data = enqueue_next_action( Mouse_Actions, - Mouse_Actions_Size, + Mouse_Actions_Size, Mouse_Actions_Per_Iteration ); receive_uid_message(); } while (more_data); - close_it(); + close_it(); TEST_END(); rtems_test_exit( 0 ); } diff --git a/testsuites/libtests/stackchk/init.c b/testsuites/libtests/stackchk/init.c index cc54bf6609..4e1e41cdfb 100644 --- a/testsuites/libtests/stackchk/init.c +++ b/testsuites/libtests/stackchk/init.c @@ -101,6 +101,6 @@ void Fatal_extension( } else if ( error != rtems_build_name( 'T', 'A', '1', ' ' ) ) { printk( "unexpected fatal error\n" ); } else { - rtems_test_endk(); + TEST_END(); } } diff --git a/testsuites/libtests/stackchk/system.h b/testsuites/libtests/stackchk/system.h index 6d9ce276bb..96f56fb22d 100644 --- a/testsuites/libtests/stackchk/system.h +++ b/testsuites/libtests/stackchk/system.h @@ -11,6 +11,7 @@ * http://www.rtems.org/license/LICENSE. */ +#define TESTS_USE_PRINTK #include <tmacros.h> /* macros */ diff --git a/testsuites/libtests/uid01/init.c b/testsuites/libtests/uid01/init.c index 13ec8bab3e..f8ec4bd25d 100644 --- a/testsuites/libtests/uid01/init.c +++ b/testsuites/libtests/uid01/init.c @@ -69,9 +69,10 @@ void printf_uid_message( struct MW_UID_MESSAGE *uid ) { + rtems_printer printer; + rtems_print_printer_printf( &printer ); uid_print_message_with_plugin( - stdout, - (rtems_printk_plugin_t)fprintf, + &printer, uid ); } @@ -111,12 +112,12 @@ rtems_task Init( /* No message should ever be recieved. With a timeout val of 0, this * call will never return. We use this to check if patch was correct * by passing a number of ticks greater than 0 and less than 1. If - * patch was correct, this call will timeout instead of waiting + * patch was correct, this call will timeout instead of waiting * indefinitely. */ receive_uid_message(); - close_it(); + close_it(); TEST_END(); rtems_test_exit( 0 ); } |