summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxonce01
diff options
context:
space:
mode:
authorChristian Mauderer <Christian.Mauderer@embedded-brains.de>2014-03-18 16:25:34 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-19 08:34:28 +0100
commit4484112216c4126dad1404785ffcc6f59a08c8d7 (patch)
tree843ba236f834f7326446451d9b4750730572b885 /testsuites/psxtests/psxonce01
parentpsxtests: move pthread_once tests into an extra test. (diff)
downloadrtems-4484112216c4126dad1404785ffcc6f59a08c8d7.tar.bz2
psxonce01: Add call counter to check if init function has been called.
Diffstat (limited to 'testsuites/psxtests/psxonce01')
-rw-r--r--testsuites/psxtests/psxonce01/init.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/testsuites/psxtests/psxonce01/init.c b/testsuites/psxtests/psxonce01/init.c
index 6fd65794ab..9b6a5ee1a5 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 );