summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx10
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/psx10
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/psx10')
-rw-r--r--testsuites/psxtests/psx10/init.c129
-rw-r--r--testsuites/psxtests/psx10/psx10.scn2
-rw-r--r--testsuites/psxtests/psx10/system.h1
3 files changed, 119 insertions, 13 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