[rtems-libbsd commit] testsuite: Simplify tests

Sebastian Huber sebh at rtems.org
Wed Nov 13 16:38:35 UTC 2013


Module:    rtems-libbsd
Branch:    master
Commit:    fafa9e271659e6ff1f714f034ab64aa608a8ca81
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=fafa9e271659e6ff1f714f034ab64aa608a8ca81

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Nov 13 17:20:01 2013 +0100

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 06e27a5..c84ba77 100644
--- a/testsuite/commands01/test_main.c
+++ b/testsuite/commands01/test_main.c
@@ -40,22 +40,12 @@
 #include <machine/rtems-bsd-commands.h>
 
 #include <rtems/libcsupport.h>
-#include <rtems/stackchk.h>
 
 #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)
 {
 	rtems_resource_snapshot snapshot;
@@ -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 8554de1..788ba71 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 <bsp.h>
+#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <rtems/stackchk.h>
 #include <rtems/bsd/bsd.h>
 
+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 88de064..61d7836 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 ec4ad7d..edc5ab0 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 b56d830..e0eabe8 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 53919d3..8f2cffc 100644
--- a/testsuite/rwlock01/test_main.c
+++ b/testsuite/rwlock01/test_main.c
@@ -43,7 +43,6 @@
 #include <string.h>
 
 #include <rtems/libcsupport.h>
-#include <rtems/stackchk.h>
 #include <rtems.h>
 
 #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 468095e..0475d4d 100644
--- a/testsuite/selectpollkqueue01/test_main.c
+++ b/testsuite/selectpollkqueue01/test_main.c
@@ -53,7 +53,6 @@
 #include <machine/rtems-bsd-commands.h>
 
 #include <rtems/libcsupport.h>
-#include <rtems/stackchk.h>
 #include <rtems.h>
 
 #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 e5120c0..8dbfad1 100644
--- a/testsuite/sleep01/test_main.c
+++ b/testsuite/sleep01/test_main.c
@@ -43,7 +43,6 @@
 #include <inttypes.h>
 
 #include <rtems/libcsupport.h>
-#include <rtems/stackchk.h>
 
 #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 4fc669c..07b7381 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 223d21c..27f8c73 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);
 }
 




More information about the vc mailing list