From 6592cabade83930ae03f086afd416a9bcd029197 Mon Sep 17 00:00:00 2001 From: Christian Mauderer Date: Tue, 18 Mar 2014 16:25:33 +0100 Subject: psxtests: move pthread_once tests into an extra test. --- testsuites/psxtests/psxonce01/init.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 testsuites/psxtests/psxonce01/init.c (limited to 'testsuites/psxtests/psxonce01/init.c') diff --git a/testsuites/psxtests/psxonce01/init.c b/testsuites/psxtests/psxonce01/init.c new file mode 100644 index 0000000000..6fd65794ab --- /dev/null +++ b/testsuites/psxtests/psxonce01/init.c @@ -0,0 +1,68 @@ +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define CONFIGURE_INIT +#include "system.h" + +pthread_once_t nesting_once = PTHREAD_ONCE_INIT; + +void Test_init_routine_nesting( void ); + +void Test_init_routine_nesting( void ) +{ + int status; + puts( "Test_init_routine_nesting: invoked" ); + status = pthread_once( &nesting_once, Test_init_routine_nesting ); + rtems_test_assert( status == EINVAL ); +} + +void Test_init_routine( void ); + +void Test_init_routine( void ) +{ + puts( "Test_init_routine: invoked" ); +} + +rtems_task Init(rtems_task_argument argument) +{ + int status; + pthread_once_t once = PTHREAD_ONCE_INIT; + + 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 ); + + puts( "Init: pthread_once - EINVAL (NULL init_routine)" ); + status = pthread_once( &once, NULL ); + rtems_test_assert( status == EINVAL ); + + puts( "Init: pthread_once - SUCCESSFUL (init_routine executes)" ); + status = pthread_once( &once, Test_init_routine ); + rtems_test_assert( !status ); + + puts( "Init: pthread_once - SUCCESSFUL (init_routine does not execute)" ); + status = pthread_once( &once, Test_init_routine ); + rtems_test_assert( !status ); + + puts( "*** END OF TEST POSIX ONCE 01 ***" ); + rtems_test_exit( 0 ); +} -- cgit v1.2.3