From 5222488573e3ba8c2eceffe29f878a73a3a81694 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 26 Sep 2017 07:49:17 +0200 Subject: posix: Implement self-contained POSIX condvar POSIX condition variables are now available in all configurations and no longer depend on --enable-posix. Update #2514. Update #3113. --- testsuites/psxtests/psxautoinit02/init.c | 63 +++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 9 deletions(-) (limited to 'testsuites/psxtests/psxautoinit02/init.c') diff --git a/testsuites/psxtests/psxautoinit02/init.c b/testsuites/psxtests/psxautoinit02/init.c index 967b9b86d5..bba4e24ea4 100644 --- a/testsuites/psxtests/psxautoinit02/init.c +++ b/testsuites/psxtests/psxautoinit02/init.c @@ -25,20 +25,65 @@ void *POSIX_Init( ) { int sc; - pthread_cond_t cond1; - pthread_cond_t cond2; + pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER; + pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER; + pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER; + pthread_cond_t cond4 = PTHREAD_COND_INITIALIZER; + pthread_cond_t cond5 = PTHREAD_COND_INITIALIZER; + pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; + struct timespec to; TEST_BEGIN(); - cond1 = PTHREAD_COND_INITIALIZER; - cond2 = PTHREAD_COND_INITIALIZER; puts( "Init - pthread_cond_broadcast - auto initialize - OK" ); sc = pthread_cond_broadcast( &cond1 ); fatal_posix_service_status( sc, 0, "cond broadcast OK" ); - puts( "Init - pthread_cond_broadcast - auto initialize - EINVAL" ); - sc = pthread_cond_broadcast( &cond2 ); - fatal_posix_service_status( sc, EINVAL, "cond lock EINVAL" ); + puts( "Init - pthread_cond_signal - auto initialize - OK" ); + sc = pthread_cond_signal( &cond2 ); + fatal_posix_service_status( sc, 0, "cond signal OK" ); + + puts( "Init - pthread_cond_init - auto initialize - OK" ); + sc = pthread_cond_init( &cond3, NULL ); + fatal_posix_service_status( sc, 0, "cond init OK" ); + + puts( "Init - pthread_mutex_lock - OK" ); + sc = pthread_mutex_lock( &mtx ); + fatal_posix_service_status( sc, 0, "mtx lock OK" ); + + puts( "Init - pthread_cond_timedwait - auto initialize - OK" ); + to.tv_sec = 1; + to.tv_nsec = 1; + sc = pthread_cond_timedwait( &cond4, &mtx, &to ); + fatal_posix_service_status( sc, ETIMEDOUT, "cond timedwait OK" ); + + puts( "Init - pthread_mutex_unlock - OK" ); + sc = pthread_mutex_unlock( &mtx ); + fatal_posix_service_status( sc, 0, "mtx unlock OK" ); + + puts( "Init - pthread_mutex_destroy - OK" ); + sc = pthread_mutex_destroy( &mtx ); + fatal_posix_service_status( sc, 0, "mtx destroy OK" ); + + puts( "Init - pthread_cond_destroy - OK" ); + sc = pthread_cond_destroy( &cond5 ); + fatal_posix_service_status( sc, 0, "cond destroy OK" ); + + puts( "Init - pthread_cond_destroy - EINVAL" ); + sc = pthread_cond_destroy( &cond5 ); + fatal_posix_service_status( sc, EINVAL, "cond destroy EINVAL" ); + + puts( "Init - pthread_cond_destroy - OK" ); + sc = pthread_cond_destroy( &cond4 ); + fatal_posix_service_status( sc, 0, "cond destroy OK" ); + + puts( "Init - pthread_cond_destroy - OK" ); + sc = pthread_cond_destroy( &cond3 ); + fatal_posix_service_status( sc, 0, "cond destroy OK" ); + + puts( "Init - pthread_cond_destroy - OK" ); + sc = pthread_cond_destroy( &cond2 ); + fatal_posix_service_status( sc, 0, "cond destroy OK" ); puts( "Init - pthread_cond_destroy - OK" ); sc = pthread_cond_destroy( &cond1 ); @@ -51,12 +96,12 @@ void *POSIX_Init( } #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER -#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 -#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1 +#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1 #define CONFIGURE_POSIX_INIT_THREAD_TABLE -- cgit v1.2.3