[PATCH 2/2] psxonce01: Add call counter to check if init function has been called.
Gedare Bloom
gedare at rtems.org
Tue Mar 18 15:47:57 UTC 2014
OK to this and the previous.
On Tue, Mar 18, 2014 at 11:25 AM, Christian Mauderer
<christian.mauderer at embedded-brains.de> wrote:
> From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
>
> ---
> testsuites/psxtests/psxonce01/init.c | 27 ++++++++++++++-------------
> 1 file 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 );
> --
> 1.8.4.5
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list