[rtems commit] psxonce01: Add call counter to check if init function has been called.

Sebastian Huber sebh at rtems.org
Wed Mar 19 07:31:16 UTC 2014


Module:    rtems
Branch:    master
Commit:    4484112216c4126dad1404785ffcc6f59a08c8d7
Changeset: http://git.rtems.org/rtems/commit/?id=4484112216c4126dad1404785ffcc6f59a08c8d7

Author:    Christian Mauderer <Christian.Mauderer at embedded-brains.de>
Date:      Tue Mar 18 16:25:34 2014 +0100

psxonce01: Add call counter to check if init function has been called.

---

 testsuites/psxtests/psxonce01/init.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/testsuites/psxtests/psxonce01/init.c b/testsuites/psxtests/psxonce01/init.c
index 6fd6579..9b6a5ee 100644
--- a/testsuites/psxtests/psxonce01/init.c
+++ b/testsuites/psxtests/psxonce01/init.c
@@ -14,23 +14,23 @@
 #define CONFIGURE_INIT
 #include "system.h"
 
-pthread_once_t nesting_once = PTHREAD_ONCE_INIT;
+static pthread_once_t nesting_once = PTHREAD_ONCE_INIT;
 
-void Test_init_routine_nesting( void );
-
-void Test_init_routine_nesting( void )
+static void Test_init_routine_nesting( void )
 {
   int status;
   puts( "Test_init_routine_nesting: invoked" );
+  puts( "Test_init_routine_nesting: pthread_once - EINVAL (init_routine_nesting does not execute)" );
   status = pthread_once( &nesting_once, Test_init_routine_nesting );
   rtems_test_assert( status == EINVAL );
 }
 
-void Test_init_routine( void );
+static int test_init_routine_call_counter = 0;
 
-void Test_init_routine( void )
+static void Test_init_routine( void )
 {
   puts( "Test_init_routine: invoked" );
+  ++test_init_routine_call_counter;
 }
 
 rtems_task Init(rtems_task_argument argument)
@@ -40,13 +40,6 @@ rtems_task Init(rtems_task_argument argument)
 
   puts( "\n\n*** TEST POSIX ONCE 01 ***" );
 
-  /* once nesting */
-  puts( "Init: pthread_once - SUCCESSFUL (init_routine_nesting executes)" );
-  status = pthread_once( &nesting_once, Test_init_routine_nesting );
-  rtems_test_assert( !status );
-
-  /* exercise pthread_once */
-
   puts( "Init: pthread_once - EINVAL (NULL once_control)" );
   status = pthread_once( NULL, Test_init_routine );
   rtems_test_assert( status == EINVAL );
@@ -58,10 +51,18 @@ rtems_task Init(rtems_task_argument argument)
   puts( "Init: pthread_once - SUCCESSFUL (init_routine executes)" );
   status = pthread_once( &once, Test_init_routine );
   rtems_test_assert( !status );
+  printf( "Init: call counter: %d\n", test_init_routine_call_counter );
+  rtems_test_assert( test_init_routine_call_counter == 1 );
 
   puts( "Init: pthread_once - SUCCESSFUL (init_routine does not execute)" );
   status = pthread_once( &once, Test_init_routine );
   rtems_test_assert( !status );
+  printf( "Init: call counter: %d\n", test_init_routine_call_counter );
+  rtems_test_assert( test_init_routine_call_counter == 1 );
+
+  puts( "Init: pthread_once - SUCCESSFUL (init_routine_nesting executes)" );
+  status = pthread_once( &nesting_once, Test_init_routine_nesting );
+  rtems_test_assert( !status );
 
   puts( "*** END OF TEST POSIX ONCE 01 ***" );
   rtems_test_exit( 0 );




More information about the vc mailing list