From fafa9e271659e6ff1f714f034ab64aa608a8ca81 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 13 Nov 2013 17:20:01 +0100 Subject: testsuite: Simplify tests --- testsuite/commands01/test_main.c | 20 -------------- testsuite/include/rtems/bsd/test/default-init.h | 36 +++++++++++++++++++++++-- testsuite/init01/test_main.c | 1 - testsuite/loopback01/test_main.c | 1 - testsuite/netshell01/test_main.c | 1 - testsuite/rwlock01/test_main.c | 10 ------- testsuite/selectpollkqueue01/test_main.c | 5 ---- testsuite/sleep01/test_main.c | 10 ------- testsuite/syscalls01/test_main.c | 1 - testsuite/thread01/test_main.c | 7 ----- 10 files changed, 34 insertions(+), 58 deletions(-) diff --git a/testsuite/commands01/test_main.c b/testsuite/commands01/test_main.c index 06e27a5c..c84ba775 100644 --- a/testsuite/commands01/test_main.c +++ b/testsuite/commands01/test_main.c @@ -40,21 +40,11 @@ #include #include -#include #define TEST_NAME "LIBBSD COMMANDS 1" #define ARGC(x) (nitems(x) - 1) -static void -set_self_prio(rtems_task_priority prio) -{ - rtems_status_code sc; - - sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio); - assert(sc == RTEMS_SUCCESSFUL); -} - static void test_route_without_if(void) { @@ -270,12 +260,6 @@ test_netstat(void) static void test_main(void) { - /* - * Let other tasks run to complete background work that frees allocated - * resources. - */ - set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1); - test_route_without_if(); test_ifconfig_lo0(); test_route_with_lo0(); @@ -283,10 +267,6 @@ test_main(void) test_ping6(); test_netstat(); - rtems_stack_checker_report_usage_with_plugin(NULL, - rtems_printf_plugin); - - puts("*** END OF " TEST_NAME " TEST ***"); exit(0); } diff --git a/testsuite/include/rtems/bsd/test/default-init.h b/testsuite/include/rtems/bsd/test/default-init.h index 8554de17..788ba715 100644 --- a/testsuite/include/rtems/bsd/test/default-init.h +++ b/testsuite/include/rtems/bsd/test/default-init.h @@ -6,14 +6,38 @@ #define RTEMS_BSD_TEST_DEFAULT_INIT_H #include +#include #include #include +#include #include +static void default_set_self_prio( rtems_task_priority prio ) +{ + rtems_status_code sc; + + sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio); + assert(sc == RTEMS_SUCCESSFUL); +} + +static void default_on_exit( int exit_code, void *arg ) +{ + rtems_stack_checker_report_usage_with_plugin( + NULL, + rtems_printf_plugin + ); + + if ( exit_code == 0 ) { + puts( "*** END OF TEST " TEST_NAME " ***" ); + } +} + rtems_task Init( rtems_task_argument ignored ) { + rtems_status_code sc; + puts( "*** " TEST_NAME " TEST ***" ); /* @@ -22,13 +46,21 @@ rtems_task Init( * just requires including irq-server.[ch] in their build. */ + on_exit( default_on_exit, NULL ); + + /* Let other tasks run to complete background work */ + default_set_self_prio( RTEMS_MAXIMUM_PRIORITY - 1 ); + rtems_bsd_initialize_with_interrupt_server(); + /* Let the callout timer allocate its resources */ + sc = rtems_task_wake_after( 2 ); + assert(sc == RTEMS_SUCCESSFUL); + test_main(); /* should not return */ - printf( "*** Test main returned and should not have ***\n" ); - exit( 5 ); + assert( 0 ); } /* configuration information */ diff --git a/testsuite/init01/test_main.c b/testsuite/init01/test_main.c index 88de0648..61d7836b 100644 --- a/testsuite/init01/test_main.c +++ b/testsuite/init01/test_main.c @@ -14,7 +14,6 @@ static void test_main(void) puts( "Sleeping to see what happens" ); sleep( 5 ); - puts( "*** END OF " TEST_NAME " TEST ***" ); exit( 0 ); } diff --git a/testsuite/loopback01/test_main.c b/testsuite/loopback01/test_main.c index ec4ad7d6..edc5ab04 100644 --- a/testsuite/loopback01/test_main.c +++ b/testsuite/loopback01/test_main.c @@ -295,7 +295,6 @@ static void test_main(void) spawnTask(clientTask, 120, 6); waitForClientEvents(argToClientEvent(4) | argToClientEvent(5) | argToClientEvent(6)); - puts( "*** END OF " TEST_NAME " TEST ***" ); exit( 0 ); } diff --git a/testsuite/netshell01/test_main.c b/testsuite/netshell01/test_main.c index b56d8307..e0eabe8a 100644 --- a/testsuite/netshell01/test_main.c +++ b/testsuite/netshell01/test_main.c @@ -22,7 +22,6 @@ static void test_main(void) rtems_shell_main_loop( &env ); - puts( "*** END OF " TEST_NAME " TEST ***" ); exit( 0 ); } diff --git a/testsuite/rwlock01/test_main.c b/testsuite/rwlock01/test_main.c index 53919d30..8f2cffc8 100644 --- a/testsuite/rwlock01/test_main.c +++ b/testsuite/rwlock01/test_main.c @@ -43,7 +43,6 @@ #include #include -#include #include #define TEST_NAME "LIBBSD RWLOCK 1" @@ -506,12 +505,7 @@ test_rw_sleep_timeout(test_context *ctx) static void alloc_basic_resources(void) { - rtems_status_code sc; - curthread; - - sc = rtems_task_wake_after(2); - assert(sc == RTEMS_SUCCESSFUL); } static void @@ -548,10 +542,6 @@ test_main(void) assert(rtems_resource_snapshot_check(&snapshot_0)); - rtems_stack_checker_report_usage_with_plugin(NULL, - rtems_printf_plugin); - - puts("*** END OF " TEST_NAME " TEST ***"); exit(0); } diff --git a/testsuite/selectpollkqueue01/test_main.c b/testsuite/selectpollkqueue01/test_main.c index 468095ed..0475d4d5 100644 --- a/testsuite/selectpollkqueue01/test_main.c +++ b/testsuite/selectpollkqueue01/test_main.c @@ -53,7 +53,6 @@ #include #include -#include #include #define TEST_NAME "LIBBSD SELECT AND POLL AND KQUEUE 1" @@ -987,10 +986,6 @@ test_main(void) test_kqueue_write(ctx); test_kqueue_close(ctx); - rtems_stack_checker_report_usage_with_plugin(NULL, - rtems_printf_plugin); - - puts("*** END OF " TEST_NAME " TEST ***"); exit(0); } diff --git a/testsuite/sleep01/test_main.c b/testsuite/sleep01/test_main.c index e5120c0f..8dbfad10 100644 --- a/testsuite/sleep01/test_main.c +++ b/testsuite/sleep01/test_main.c @@ -43,7 +43,6 @@ #include #include -#include #define TEST_NAME "LIBBSD SLEEP 1" @@ -209,12 +208,7 @@ test_wakeup(void) static void alloc_basic_resources(void) { - rtems_status_code sc; - curthread; - - sc = rtems_task_wake_after(2); - assert(sc == RTEMS_SUCCESSFUL); } static void @@ -234,10 +228,6 @@ test_main(void) assert(rtems_resource_snapshot_check(&snapshot)); - rtems_stack_checker_report_usage_with_plugin(NULL, - rtems_printf_plugin); - - puts("*** END OF " TEST_NAME " TEST ***"); exit(0); } diff --git a/testsuite/syscalls01/test_main.c b/testsuite/syscalls01/test_main.c index 4fc669c4..07b73816 100644 --- a/testsuite/syscalls01/test_main.c +++ b/testsuite/syscalls01/test_main.c @@ -1718,7 +1718,6 @@ test_main(void) test_warn(); test_err(); - puts("*** END OF " TEST_NAME " TEST ***"); exit(0); } diff --git a/testsuite/thread01/test_main.c b/testsuite/thread01/test_main.c index 223d21c4..27f8c73d 100644 --- a/testsuite/thread01/test_main.c +++ b/testsuite/thread01/test_main.c @@ -283,21 +283,14 @@ test_rtems_bsd_get_curthread_or_null(void) static void test_main(void) { - rtems_status_code sc; - rtems_task_priority prio = RTEMS_MAXIMUM_PRIORITY - 1; - main_task_id = rtems_task_self(); - sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio); - assert(sc == RTEMS_SUCCESSFUL); - test_non_bsd_thread(); test_kproc_start(); test_kthread_start(); test_kthread_add(); test_rtems_bsd_get_curthread_or_null(); - puts("*** END OF " TEST_NAME " TEST ***"); exit(0); } -- cgit v1.2.3