From 4484112216c4126dad1404785ffcc6f59a08c8d7 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Tue, 18 Mar 2014 16:25:34 +0100 Subject: psxonce01: Add call counter to check if init function has been called. --- testsuites/psxtests/psxonce01/init.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'testsuites/psxtests/psxonce01') 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 ); -- cgit v1.2.3