summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-26 07:49:17 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-05 14:29:02 +0200
commit5222488573e3ba8c2eceffe29f878a73a3a81694 (patch)
tree4b4ca72268b8f40da493ca252780c197bd23a5ef /testsuites/psxtests
parentposix: Implement self-contained POSIX rwlocks (diff)
downloadrtems-5222488573e3ba8c2eceffe29f878a73a3a81694.tar.bz2
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.
Diffstat (limited to 'testsuites/psxtests')
-rw-r--r--testsuites/psxtests/psx10/init.c129
-rw-r--r--testsuites/psxtests/psx10/psx10.scn2
-rw-r--r--testsuites/psxtests/psx10/system.h1
-rw-r--r--testsuites/psxtests/psxaio01/system.h1
-rw-r--r--testsuites/psxtests/psxaio02/system.h1
-rw-r--r--testsuites/psxtests/psxaio03/system.h1
-rw-r--r--testsuites/psxtests/psxautoinit02/init.c63
-rw-r--r--testsuites/psxtests/psxautoinit02/psxautoinit02.scn15
-rw-r--r--testsuites/psxtests/psxcleanup/system.h1
-rw-r--r--testsuites/psxtests/psxcond01/init.c1
-rw-r--r--testsuites/psxtests/psxconfig01/init.c14
-rw-r--r--testsuites/psxtests/psxkey07/init.c1
-rw-r--r--testsuites/psxtests/psxsignal06/init.c1
-rw-r--r--testsuites/psxtests/psxtimer01/system.h1
14 files changed, 185 insertions, 47 deletions
diff --git a/testsuites/psxtests/psx10/init.c b/testsuites/psxtests/psx10/init.c
index 24265ba0ad..ad4e60e385 100644
--- a/testsuites/psxtests/psx10/init.c
+++ b/testsuites/psxtests/psx10/init.c
@@ -17,6 +17,121 @@
const char rtems_test_name[] = "PSX 10";
+static void test_cond_null( void )
+{
+ pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
+ int eno;
+ struct timespec to;
+
+ eno = pthread_cond_init( NULL, NULL );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_mutex_lock( &mtx );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_cond_wait( NULL, &mtx );
+ rtems_test_assert( eno == EINVAL );
+
+ to.tv_sec = 1;
+ to.tv_nsec = 1;
+ eno = pthread_cond_timedwait( NULL, &mtx, &to );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_mutex_unlock( &mtx );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_cond_signal( NULL );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_broadcast( NULL );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_destroy( NULL );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_mutex_destroy( &mtx );
+ rtems_test_assert( eno == 0 );
+}
+
+static void test_cond_not_initialized( void )
+{
+ pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
+ pthread_cond_t cond;
+ int eno;
+ struct timespec to;
+
+ memset( &cond, 0xff, sizeof( cond ) );
+
+ eno = pthread_mutex_lock( &mtx );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_cond_wait( &cond, &mtx );
+ rtems_test_assert( eno == EINVAL );
+
+ to.tv_sec = 1;
+ to.tv_nsec = 1;
+ eno = pthread_cond_timedwait( &cond, &mtx, &to );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_mutex_unlock( &mtx );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_cond_signal( &cond );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_broadcast( &cond );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_destroy( &cond );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_mutex_destroy( &mtx );
+ rtems_test_assert( eno == 0 );
+}
+
+static void test_cond_invalid_copy( void )
+{
+ pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
+ pthread_cond_t cond;
+ pthread_cond_t cond2;
+ int eno;
+ struct timespec to;
+
+ eno = pthread_cond_init( &cond, NULL );
+ rtems_test_assert( eno == 0 );
+
+ memcpy( &cond2, &cond, sizeof( cond2 ) );
+
+ eno = pthread_mutex_lock( &mtx );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_cond_wait( &cond2, &mtx );
+ rtems_test_assert( eno == EINVAL );
+
+ to.tv_sec = 1;
+ to.tv_nsec = 1;
+ eno = pthread_cond_timedwait( &cond2, &mtx, &to );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_mutex_unlock( &mtx );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_cond_signal( &cond2 );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_broadcast( &cond2 );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_destroy( &cond2 );
+ rtems_test_assert( eno == EINVAL );
+
+ eno = pthread_cond_destroy( &cond );
+ rtems_test_assert( eno == 0 );
+
+ eno = pthread_mutex_destroy( &mtx );
+ rtems_test_assert( eno == 0 );
+}
+
void *POSIX_Init(
void *argument
)
@@ -30,6 +145,10 @@ void *POSIX_Init(
TEST_BEGIN();
+ test_cond_null();
+ test_cond_not_initialized();
+ test_cond_invalid_copy();
+
puts( "Init: pthread_condattr_init" );
status = pthread_condattr_init( &attr );
rtems_test_assert( !status );
@@ -97,16 +216,6 @@ void *POSIX_Init(
rtems_test_assert( status == EINVAL );
puts( "Init: pthread_cond_init - EINVAL (attr not initialized)" );
- status = pthread_cond_init( &cond, NULL );
- if ( status != ENOMEM )
- printf( "status = %d\n", status );
- rtems_test_assert( status == ENOMEM );
- puts( "Init: pthread_cond_init - ENOMEM (too many conds)" );
-
- puts( "Init: pthread_cond_destroy" );
- status = pthread_cond_destroy( &cond );
- rtems_test_assert( !status );
-
/* error for bad condition variable passed */
status = pthread_cond_destroy( NULL );
diff --git a/testsuites/psxtests/psx10/psx10.scn b/testsuites/psxtests/psx10/psx10.scn
index 2c70df8713..3d5680c9b5 100644
--- a/testsuites/psxtests/psx10/psx10.scn
+++ b/testsuites/psxtests/psx10/psx10.scn
@@ -12,8 +12,6 @@ Init: pthread_condattr_getpshared - 0
Init: pthread_condattr_getpshared - EINVAL (attribute invalid)
Init: pthread_cond_init - NULL attr
Init: pthread_cond_init - EINVAL (attr not initialized)
-Init: pthread_cond_init - ENOMEM (too many conds)
-Init: pthread_cond_destroy
Init: pthread_cond_destroy - EINVAL (cond invalid)
Init: pthread_cond_init - EINVAL (invalid pshared)
Init: pthread_condattr_setpshared - PTHREAD_PROCESS_SHARED
diff --git a/testsuites/psxtests/psx10/system.h b/testsuites/psxtests/psx10/system.h
index 573a065c26..ee7e9c4dcf 100644
--- a/testsuites/psxtests/psx10/system.h
+++ b/testsuites/psxtests/psx10/system.h
@@ -41,7 +41,6 @@ void *Task_3(
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_MAXIMUM_POSIX_THREADS 4
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
diff --git a/testsuites/psxtests/psxaio01/system.h b/testsuites/psxtests/psxaio01/system.h
index 91a8658988..e17f7cab6d 100644
--- a/testsuites/psxtests/psxaio01/system.h
+++ b/testsuites/psxtests/psxaio01/system.h
@@ -29,7 +29,6 @@ void *POSIX_Init (void *argument);
#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
diff --git a/testsuites/psxtests/psxaio02/system.h b/testsuites/psxtests/psxaio02/system.h
index 4137251d66..e3e1333964 100644
--- a/testsuites/psxtests/psxaio02/system.h
+++ b/testsuites/psxtests/psxaio02/system.h
@@ -29,7 +29,6 @@ void *POSIX_Init (void *argument);
#define CONFIGURE_MAXIMUM_POSIX_THREADS 10
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10
#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
diff --git a/testsuites/psxtests/psxaio03/system.h b/testsuites/psxtests/psxaio03/system.h
index fbea6f0e02..c809bc7045 100644
--- a/testsuites/psxtests/psxaio03/system.h
+++ b/testsuites/psxtests/psxaio03/system.h
@@ -30,7 +30,6 @@ void *POSIX_Init (void *argument);
#define CONFIGURE_MAXIMUM_POSIX_THREADS 30
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 30
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 30
#define CONFIGURE_MAXIMUM_POSIX_KEYS 30
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
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
diff --git a/testsuites/psxtests/psxautoinit02/psxautoinit02.scn b/testsuites/psxtests/psxautoinit02/psxautoinit02.scn
index bfe3067468..047088a6d9 100644
--- a/testsuites/psxtests/psxautoinit02/psxautoinit02.scn
+++ b/testsuites/psxtests/psxautoinit02/psxautoinit02.scn
@@ -1,5 +1,14 @@
-*** POSIX TEST -- AUTOMATIC INITIALIZAITON 02 ***
+*** BEGIN OF TEST PSXAUTOINIT 2 ***
Init - pthread_cond_broadcast - auto initialize - OK
-Init - pthread_cond_broadcast - auto initialize - EINVAL
+Init - pthread_cond_signal - auto initialize - OK
+Init - pthread_cond_init - auto initialize - OK
+Init - pthread_mutex_lock - OK
+Init - pthread_cond_timedwait - auto initialize - OK
+Init - pthread_mutex_unlock - OK
+Init - pthread_mutex_destroy - OK
Init - pthread_cond_destroy - OK
-*** END OF POSIX TEST AUTOMATIC INITIALIZATION 02 ***
+Init - pthread_cond_destroy - OK
+Init - pthread_cond_destroy - OK
+Init - pthread_cond_destroy - OK
+Init - pthread_cond_destroy - OK
+*** END OF TEST PSXAUTOINIT 2 ***
diff --git a/testsuites/psxtests/psxcleanup/system.h b/testsuites/psxtests/psxcleanup/system.h
index 04818f8add..2111c9fab5 100644
--- a/testsuites/psxtests/psxcleanup/system.h
+++ b/testsuites/psxtests/psxcleanup/system.h
@@ -45,7 +45,6 @@ void *task_c(
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 4
#define CONFIGURE_MAXIMUM_TIMERS 4
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
#include <rtems/confdefs.h>
diff --git a/testsuites/psxtests/psxcond01/init.c b/testsuites/psxtests/psxcond01/init.c
index 395443a3c7..37fd4fdbb4 100644
--- a/testsuites/psxtests/psxcond01/init.c
+++ b/testsuites/psxtests/psxcond01/init.c
@@ -96,7 +96,6 @@ void *POSIX_Init(
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
diff --git a/testsuites/psxtests/psxconfig01/init.c b/testsuites/psxtests/psxconfig01/init.c
index 154b4d1bd6..f62c2d5508 100644
--- a/testsuites/psxtests/psxconfig01/init.c
+++ b/testsuites/psxtests/psxconfig01/init.c
@@ -60,7 +60,6 @@ const char rtems_test_name[] = "PSXCONFIG 1";
#define CONFIGURE_MAXIMUM_TIMERS 59
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 17
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 29
#define POSIX_MQ_COUNT 5
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 19
#define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 7
@@ -429,19 +428,6 @@ static rtems_task Init(rtems_task_argument argument)
);
#endif
-#ifdef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES
- for (i = 0; i < CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES; ++i) {
- pthread_cond_t cond;
- eno = pthread_cond_init(&cond, NULL);
- rtems_test_assert(eno == 0);
- }
- rtems_resource_snapshot_take(&snapshot);
- rtems_test_assert(
- snapshot.posix_api.active_condition_variables
- == CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES
- );
-#endif
-
#ifdef POSIX_MQ_COUNT
for (i = 0; i < POSIX_MQ_COUNT; ++i) {
int oflag = O_RDWR | O_CREAT | O_EXCL;
diff --git a/testsuites/psxtests/psxkey07/init.c b/testsuites/psxtests/psxkey07/init.c
index ac7e0253d8..3790ea36aa 100644
--- a/testsuites/psxtests/psxkey07/init.c
+++ b/testsuites/psxtests/psxkey07/init.c
@@ -198,7 +198,6 @@ rtems_task Init(rtems_task_argument argument)
#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(10)
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
#define CONFIGURE_UNIFIED_WORK_AREAS
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/psxtests/psxsignal06/init.c b/testsuites/psxtests/psxsignal06/init.c
index decab51e78..0177a2acea 100644
--- a/testsuites/psxtests/psxsignal06/init.c
+++ b/testsuites/psxtests/psxsignal06/init.c
@@ -126,7 +126,6 @@ void *POSIX_Init(void *argument)
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
diff --git a/testsuites/psxtests/psxtimer01/system.h b/testsuites/psxtests/psxtimer01/system.h
index 57462e7622..3fb71cadae 100644
--- a/testsuites/psxtests/psxtimer01/system.h
+++ b/testsuites/psxtests/psxtimer01/system.h
@@ -45,7 +45,6 @@ void *task_c(
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 5
#define CONFIGURE_MAXIMUM_TIMERS 4
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 2
-#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 2
#include <rtems/confdefs.h>