forked from Imagelibrary/rtems
@@ -19,6 +19,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/posix/condimpl.h>
|
#include <rtems/posix/condimpl.h>
|
||||||
|
#include <rtems/posix/posixapi.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 11.4.2 Initializing and Destroying a Condition Variable,
|
* 11.4.2 Initializing and Destroying a Condition Variable,
|
||||||
@@ -38,12 +39,14 @@ int pthread_cond_init(
|
|||||||
/*
|
/*
|
||||||
* Be careful about attributes when global!!!
|
* Be careful about attributes when global!!!
|
||||||
*/
|
*/
|
||||||
if ( the_attr->process_shared == PTHREAD_PROCESS_SHARED )
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
if ( !the_attr->is_initialized )
|
if ( !the_attr->is_initialized )
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
if ( !_POSIX_Is_valid_pshared( the_attr->process_shared ) ) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
the_cond = _POSIX_Condition_variables_Allocate();
|
the_cond = _POSIX_Condition_variables_Allocate();
|
||||||
|
|
||||||
if ( !the_cond ) {
|
if ( !the_cond ) {
|
||||||
|
|||||||
@@ -115,6 +115,25 @@ void *POSIX_Init(
|
|||||||
rtems_test_assert( status == EINVAL );
|
rtems_test_assert( status == EINVAL );
|
||||||
puts( "Init: pthread_cond_destroy - EINVAL (cond invalid)" );
|
puts( "Init: pthread_cond_destroy - EINVAL (cond invalid)" );
|
||||||
|
|
||||||
|
/* pshared tests */
|
||||||
|
|
||||||
|
puts( "Init: pthread_cond_init - EINVAL (invalid pshared)" );
|
||||||
|
attr.process_shared = -1;
|
||||||
|
status = pthread_cond_init( &cond, &attr );
|
||||||
|
rtems_test_assert( status == EINVAL );
|
||||||
|
|
||||||
|
puts( "Init: pthread_condattr_setpshared - PTHREAD_PROCESS_SHARED" );
|
||||||
|
status = pthread_condattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
|
||||||
|
rtems_test_assert( status == 0 );
|
||||||
|
|
||||||
|
puts( "Init: pthread_cond_init - OK" );
|
||||||
|
status = pthread_cond_init( &cond, &attr );
|
||||||
|
rtems_test_assert( status == 0 );
|
||||||
|
|
||||||
|
puts( "Init: pthread_cond_destroy - OK" );
|
||||||
|
status = pthread_cond_destroy( &cond );
|
||||||
|
rtems_test_assert( status == 0 );
|
||||||
|
|
||||||
/* initiailize the attribute for the rest of the test */
|
/* initiailize the attribute for the rest of the test */
|
||||||
|
|
||||||
puts( "Init: pthread_cond_init - attr" );
|
puts( "Init: pthread_cond_init - attr" );
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
*** POSIX TEST 10 ***
|
*** BEGIN OF TEST PSX 10 ***
|
||||||
Init: pthread_condattr_init
|
Init: pthread_condattr_init
|
||||||
Init: pthread_condattr_init - EINVAL (attribute invalid)
|
Init: pthread_condattr_init - EINVAL (attribute invalid)
|
||||||
Init: pthread_condattr_destroy
|
Init: pthread_condattr_destroy
|
||||||
@@ -15,12 +15,18 @@ Init: pthread_cond_init - EINVAL (attr not initialized)
|
|||||||
Init: pthread_cond_init - ENOMEM (too many conds)
|
Init: pthread_cond_init - ENOMEM (too many conds)
|
||||||
Init: pthread_cond_destroy
|
Init: pthread_cond_destroy
|
||||||
Init: pthread_cond_destroy - EINVAL (cond invalid)
|
Init: pthread_cond_destroy - EINVAL (cond invalid)
|
||||||
|
Init: pthread_cond_init - EINVAL (invalid pshared)
|
||||||
|
Init: pthread_condattr_setpshared - PTHREAD_PROCESS_SHARED
|
||||||
|
Init: pthread_cond_init - OK
|
||||||
|
Init: pthread_cond_destroy - OK
|
||||||
Init: pthread_cond_init - attr
|
Init: pthread_cond_init - attr
|
||||||
|
|
||||||
Init: sleep to switch to Task_1
|
Init: sleep to switch to Task_1
|
||||||
Task_1: ID is 0x0b010002
|
Task_1: ID is 0x0b010002
|
||||||
Task_1: pthread_cond_wait
|
Task_1: pthread_cond_wait
|
||||||
Init: pthread_cond_destroy - EBUSY (task1 waiting)
|
Init: pthread_cond_destroy - EBUSY (task1 waiting)
|
||||||
Init: pthread_cond_signal
|
Init: pthread_cond_signal
|
||||||
|
|
||||||
Init: sleep - switch to Task_1 and Task_2
|
Init: sleep - switch to Task_1 and Task_2
|
||||||
Task_1: back from pthread_cond_wait release mutex
|
Task_1: back from pthread_cond_wait release mutex
|
||||||
Task_1: pthread_cond_wait
|
Task_1: pthread_cond_wait
|
||||||
@@ -34,6 +40,7 @@ Task_2: back from pthread_cond_wait release mutex
|
|||||||
Task_2: task exit
|
Task_2: task exit
|
||||||
Init: pthread_cond_timedwait for 3 seconds
|
Init: pthread_cond_timedwait for 3 seconds
|
||||||
Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)
|
Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)
|
||||||
|
|
||||||
Init: pthread_cond_signal - EINVAL (cond invalid)
|
Init: pthread_cond_signal - EINVAL (cond invalid)
|
||||||
Init: pthread_cond_broadcast - EINVAL (cond invalid)
|
Init: pthread_cond_broadcast - EINVAL (cond invalid)
|
||||||
Init: pthread_cond_wait - EINVAL (cond invalid)
|
Init: pthread_cond_wait - EINVAL (cond invalid)
|
||||||
@@ -45,6 +52,7 @@ Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_sec < current time)
|
|||||||
Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)
|
Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)
|
||||||
Init: pthread_cond_wait - EINVAL (mutex not locked before call)
|
Init: pthread_cond_wait - EINVAL (mutex not locked before call)
|
||||||
Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)
|
Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)
|
||||||
|
|
||||||
Init: sleep - switch to Task_3
|
Init: sleep - switch to Task_3
|
||||||
Task_3: ID is 0x0b010004
|
Task_3: ID is 0x0b010004
|
||||||
Task_3: pthread_cond_wait
|
Task_3: pthread_cond_wait
|
||||||
@@ -52,4 +60,4 @@ Init: pthread_cond_signal
|
|||||||
Init: sleep - switch to Task_3
|
Init: sleep - switch to Task_3
|
||||||
Task_3: pthread_cond_wait - EINVAL (mutex not locked after signal)
|
Task_3: pthread_cond_wait - EINVAL (mutex not locked after signal)
|
||||||
Task_3: task exit
|
Task_3: task exit
|
||||||
*** END OF POSIX TEST 10 ***
|
*** END OF TEST PSX 10 ***
|
||||||
|
|||||||
Reference in New Issue
Block a user