forked from Imagelibrary/rtems
2009-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
* include/pmacros.h, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx03/task.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxclock/init.c, psxfile01/test.c, psxfile01/test_cat.c, psxfile01/test_extend.c, psxfile01/test_write.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxreaddir/test.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstat/test.c, psxtime/test.c, psxualarm/init.c: Use rtems_test_assert() consistently instead of system assert(). rtems_test_assert() is designed to integrate into the RTEMS test suite infrastructure.
This commit is contained in:
@@ -42,7 +42,7 @@ void Print_mutexattr(
|
||||
/* protocol */
|
||||
|
||||
status = pthread_mutexattr_getprotocol( attr, &protocol );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
printf( "%smutex protocol is (%d) -- ", msg, protocol );
|
||||
switch ( protocol ) {
|
||||
@@ -57,20 +57,20 @@ void Print_mutexattr(
|
||||
break;
|
||||
default:
|
||||
puts( "UNKNOWN" );
|
||||
assert( 0 );
|
||||
rtems_test_assert( 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
/* priority ceiling */
|
||||
|
||||
status = pthread_mutexattr_getprioceiling( attr, &prioceiling );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf( "%smutex priority ceiling is %d\n", msg, prioceiling );
|
||||
|
||||
/* process shared */
|
||||
|
||||
status = pthread_mutexattr_getpshared( attr, &pshared );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf( "%smutex process shared is (%d) -- ", msg, pshared );
|
||||
switch ( pshared ) {
|
||||
case PTHREAD_PROCESS_PRIVATE:
|
||||
@@ -81,7 +81,7 @@ void Print_mutexattr(
|
||||
break;
|
||||
default:
|
||||
puts( "UNKNOWN" );
|
||||
assert( 0 );
|
||||
rtems_test_assert( 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void *POSIX_Init(
|
||||
int old_ceiling;
|
||||
int priority;
|
||||
|
||||
assert( MUTEX_BAD_ID != PTHREAD_MUTEX_INITIALIZER );
|
||||
rtems_test_assert( MUTEX_BAD_ID != PTHREAD_MUTEX_INITIALIZER );
|
||||
Mutex_bad_id = MUTEX_BAD_ID;
|
||||
|
||||
puts( "\n\n*** POSIX TEST 5 ***" );
|
||||
@@ -141,30 +141,30 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_init - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_init( NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
Print_mutexattr( "Init: ", &attr );
|
||||
|
||||
/* create an "uninitialized" attribute structure */
|
||||
|
||||
status = pthread_mutexattr_init( &destroyed_attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_destroy( &destroyed_attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutexattr_destroy - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_destroy( NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_destroy - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_destroy( &destroyed_attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* error cases for set and get pshared attribute */
|
||||
|
||||
@@ -172,25 +172,25 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_getpshared( NULL, &pshared );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_getpshared - EINVAL (NULL pshared)" );
|
||||
status = pthread_mutexattr_getpshared( &attr, NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_getpshared - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_getpshared( &destroyed_attr, &pshared );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
puts( "Init: pthread_mutexattr_setpshared - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_setpshared( NULL, pshared );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
puts( "Init: pthread_mutexattr_setpshared - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_setpshared( &destroyed_attr, pshared );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* error cases for set and get protocol attribute */
|
||||
|
||||
@@ -198,27 +198,27 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_getprotocol( NULL, &protocol );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_getprotocol - EINVAL (NULL protocol)" );
|
||||
status = pthread_mutexattr_getprotocol( &attr, NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_getprotocol - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_getprotocol( &destroyed_attr, &protocol );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_setprotocol - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_setprotocol( NULL, PTHREAD_PRIO_NONE );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_setprotocol - EINVAL (invalid protocol)" );
|
||||
status = pthread_mutexattr_setprotocol( &attr, -1 );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_setprotocol - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_setprotocol( &destroyed_attr, -1 );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* error cases for set and get prioceiling attribute */
|
||||
|
||||
@@ -226,34 +226,34 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_getprioceiling( NULL, &ceiling );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (NULL prioceiling)" );
|
||||
status = pthread_mutexattr_getprioceiling( &attr, NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_getprioceiling - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_getprioceiling( &destroyed_attr, &ceiling );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (NULL attr)" );
|
||||
status = pthread_mutexattr_setprioceiling( NULL, 128 );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (invalid priority)" );
|
||||
status = pthread_mutexattr_setprioceiling( &attr, 512 );
|
||||
if ( status != EINVAL )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutexattr_setprioceiling - EINVAL (not initialized)" );
|
||||
status = pthread_mutexattr_setprioceiling( &destroyed_attr, -1 );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* create a thread */
|
||||
|
||||
status = pthread_create( &Task_id, NULL, Task_1, NULL );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* now try some basic mutex operations */
|
||||
|
||||
@@ -261,18 +261,18 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutex_init - EINVAL (NULL mutex_id)" );
|
||||
status = pthread_mutex_init( NULL, &attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_init - EINVAL (not initialized attr)" );
|
||||
status = pthread_mutex_init( &Mutex_id, &destroyed_attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* must get around error checks in attribute set routines */
|
||||
attr.protocol = -1;
|
||||
|
||||
puts( "Init: pthread_mutex_init - EINVAL (bad protocol)" );
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* must get around error checks in attribute set routines */
|
||||
attr.protocol = PTHREAD_PRIO_INHERIT;
|
||||
@@ -280,56 +280,56 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutex_init - EINVAL (bad priority ceiling)" );
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* must get around various error checks before checking bad scope */
|
||||
puts( "Init: Resetting mutex attributes" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - ENOSYS (process wide scope)" );
|
||||
attr.process_shared = PTHREAD_PROCESS_SHARED;
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
assert( status == ENOSYS );
|
||||
rtems_test_assert( status == ENOSYS );
|
||||
|
||||
puts( "Init: pthread_mutex_init - EINVAL (invalid scope)" );
|
||||
attr.process_shared = -1;
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* bad kind */
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - EINVAL (invalid type)" );
|
||||
attr.type = -1;
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* now set up for a success pthread_mutex_init */
|
||||
|
||||
puts( "Init: Resetting mutex attributes" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: Changing mutex attributes" );
|
||||
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
status = pthread_mutexattr_setprioceiling(
|
||||
&attr,
|
||||
(sched_get_priority_max(SCHED_FIFO) / 2) + 1
|
||||
);
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
status = pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
Print_mutexattr( "Init: ", &attr );
|
||||
|
||||
puts( "Init: Resetting mutex attributes" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/*
|
||||
* Set the protocol to priority ceiling so the owner check happens
|
||||
@@ -337,13 +337,13 @@ void *POSIX_Init(
|
||||
*/
|
||||
|
||||
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - SUCCESSFUL" );
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
if ( status )
|
||||
printf( "status = %d\n", status );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/*
|
||||
* This is not required to be an error and when it is, there are
|
||||
@@ -355,44 +355,44 @@ void *POSIX_Init(
|
||||
status = pthread_mutex_init( &Mutex_id, &attr );
|
||||
if ( !status )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EBUSY );
|
||||
rtems_test_assert( status == EBUSY );
|
||||
#endif
|
||||
|
||||
puts( "Init: pthread_mutex_trylock - EINVAL (illegal ID)" );
|
||||
status = pthread_mutex_trylock( &Mutex_bad_id );
|
||||
if ( status != EINVAL )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
|
||||
status = pthread_mutex_trylock( &Mutex_id );
|
||||
if ( status )
|
||||
printf( "status = %d\n", status );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_trylock - EDEADLK (already locked)" );
|
||||
status = pthread_mutex_trylock( &Mutex_id );
|
||||
if ( status != EDEADLK )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EDEADLK );
|
||||
rtems_test_assert( status == EDEADLK );
|
||||
|
||||
puts( "Init: pthread_mutex_lock - EINVAL (NULL id)" );
|
||||
status = pthread_mutex_lock( NULL );
|
||||
if ( status != EINVAL )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_unlock - EINVAL (NULL id)" );
|
||||
status = pthread_mutex_unlock( NULL );
|
||||
if ( status != EINVAL )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_lock - EDEADLK (already locked)" );
|
||||
status = pthread_mutex_lock( &Mutex_id );
|
||||
if ( status != EDEADLK )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EDEADLK );
|
||||
rtems_test_assert( status == EDEADLK );
|
||||
|
||||
puts( "Init: Sleep 1 second" );
|
||||
|
||||
@@ -404,19 +404,19 @@ void *POSIX_Init(
|
||||
status = pthread_mutex_unlock( &Mutex_bad_id );
|
||||
if ( status != EINVAL )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
|
||||
status = pthread_mutex_unlock( &Mutex_id );
|
||||
if ( status )
|
||||
printf( "status = %d\n", status );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_unlock - EPERM (not owner)" );
|
||||
status = pthread_mutex_unlock( &Mutex_id );
|
||||
if ( status != EPERM )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EPERM );
|
||||
rtems_test_assert( status == EPERM );
|
||||
|
||||
puts( "Init: pthread_mutex_timedlock - time out in 1/2 second" );
|
||||
calculate_abstimeout( ×, 0, (TOD_NANOSECONDS_PER_SECOND / 2) );
|
||||
@@ -424,7 +424,7 @@ void *POSIX_Init(
|
||||
status = pthread_mutex_timedlock( &Mutex_id, × );
|
||||
if ( status != ETIMEDOUT )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == ETIMEDOUT );
|
||||
rtems_test_assert( status == ETIMEDOUT );
|
||||
|
||||
puts( "Init: pthread_mutex_timedlock - time out in the past" );
|
||||
calculate_abstimeout( ×, -1, (TOD_NANOSECONDS_PER_SECOND / 2) );
|
||||
@@ -432,7 +432,7 @@ void *POSIX_Init(
|
||||
status = pthread_mutex_timedlock( &Mutex_id, × );
|
||||
if ( status != EBUSY )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EBUSY );
|
||||
rtems_test_assert( status == EBUSY );
|
||||
|
||||
/* switch to idle */
|
||||
|
||||
@@ -446,23 +446,23 @@ void *POSIX_Init(
|
||||
status = pthread_mutex_init( &Mutex2_id, &attr );
|
||||
if ( status )
|
||||
printf( "status = %d\n", status );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - EAGAIN (too many)" );
|
||||
status = pthread_mutex_init( &Mutex3_id, &attr );
|
||||
assert( status == EAGAIN );
|
||||
rtems_test_assert( status == EAGAIN );
|
||||
|
||||
puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_destroy( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
|
||||
status = pthread_mutex_destroy( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_destroy - EINVAL (invalid id)" );
|
||||
status = pthread_mutex_destroy( &Mutex_bad_id );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* destroy a busy mutex */
|
||||
|
||||
@@ -470,31 +470,31 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - SUCCESSFUL" );
|
||||
status = pthread_mutex_init( &Mutex2_id, &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
|
||||
status = pthread_mutex_trylock( &Mutex2_id );
|
||||
if ( status )
|
||||
printf( "status = %d\n", status );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_destroy - EBUSY (already locked)" );
|
||||
status = pthread_mutex_destroy( &Mutex2_id );
|
||||
if ( status != EBUSY )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EBUSY );
|
||||
rtems_test_assert( status == EBUSY );
|
||||
|
||||
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
|
||||
status = pthread_mutex_unlock( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
|
||||
status = pthread_mutex_destroy( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* priority inherit mutex */
|
||||
|
||||
@@ -502,26 +502,26 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts(
|
||||
"Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_INHERIT)"
|
||||
);
|
||||
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_INHERIT );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - SUCCESSFUL" );
|
||||
status = pthread_mutex_init( &Mutex2_id, &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
|
||||
status = pthread_mutex_trylock( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* create a thread at a lower priority */
|
||||
|
||||
status = pthread_create( &Task2_id, NULL, Task_2, NULL );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* set priority of Task2 to highest priority */
|
||||
|
||||
@@ -529,25 +529,25 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_setschedparam - Setting Task2 priority to highest" );
|
||||
status = pthread_setschedparam( Task2_id, SCHED_FIFO, ¶m );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* switching to Task2 */
|
||||
|
||||
status = pthread_getschedparam( pthread_self(), &policy, ¶m );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf( "Init: pthread_getschedparam - priority = %d\n", param.sched_priority);
|
||||
|
||||
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
|
||||
status = pthread_mutex_unlock( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutexattr_destroy - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_destroy( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_destroy - SUCCESSFUL" );
|
||||
status = pthread_mutex_destroy( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* priority ceiling mutex */
|
||||
|
||||
@@ -555,41 +555,41 @@ void *POSIX_Init(
|
||||
|
||||
puts( "Init: pthread_mutexattr_init - SUCCESSFUL" );
|
||||
status = pthread_mutexattr_init( &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts(
|
||||
"Init: pthread_mutexattr_setprotocol - SUCCESSFUL (PTHREAD_PRIO_PROTECT)"
|
||||
);
|
||||
status = pthread_mutexattr_setprotocol( &attr, PTHREAD_PRIO_PROTECT );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_init - SUCCESSFUL" );
|
||||
status = pthread_mutex_init( &Mutex2_id, &attr );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "Init: pthread_mutex_getprioceiling - EINVAL (invalid id)" );
|
||||
status = pthread_mutex_getprioceiling( &Mutex_bad_id, &ceiling );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_getprioceiling - EINVAL (NULL ceiling)" );
|
||||
status = pthread_mutex_getprioceiling( &Mutex2_id, NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf( "Init: pthread_mutex_getprioceiling - %d\n", ceiling );
|
||||
|
||||
puts( "Init: pthread_mutex_setprioceiling - EINVAL (invalid id)" );
|
||||
status = pthread_mutex_setprioceiling( &Mutex_bad_id, 200, &old_ceiling );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_setprioceiling - EINVAL (illegal priority)" );
|
||||
status = pthread_mutex_setprioceiling( &Mutex2_id, 512, &old_ceiling );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
puts( "Init: pthread_mutex_setprioceiling - EINVAL (NULL ceiling)" );
|
||||
status = pthread_mutex_setprioceiling( &Mutex2_id, 128, NULL );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* normal cases of set priority ceiling */
|
||||
|
||||
@@ -598,23 +598,23 @@ void *POSIX_Init(
|
||||
|
||||
printf( "Init: pthread_mutex_setprioceiling - new ceiling = %d\n", priority );
|
||||
status = pthread_mutex_setprioceiling( &Mutex2_id, priority, &old_ceiling );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf(
|
||||
"Init: pthread_mutex_setprioceiling - old ceiling = %d\n",old_ceiling
|
||||
);
|
||||
|
||||
status = pthread_getschedparam( pthread_self(), &policy, ¶m );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf(
|
||||
"Init: pthread_getschedparam - priority = %d\n", param.sched_priority
|
||||
);
|
||||
|
||||
puts( "Init: pthread_mutex_trylock - SUCCESSFUL" );
|
||||
status = pthread_mutex_trylock( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
status = pthread_getschedparam( pthread_self(), &policy, ¶m );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf(
|
||||
"Init: pthread_getschedparam - priority = %d\n", param.sched_priority
|
||||
);
|
||||
@@ -622,30 +622,30 @@ void *POSIX_Init(
|
||||
/* create a thread at a higher priority */
|
||||
|
||||
status = pthread_create( &Task3_id, NULL, Task_3, NULL );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
/* set priority of Task3 to highest priority */
|
||||
|
||||
param.sched_priority = --priority;
|
||||
|
||||
status = pthread_setschedparam( Task3_id, SCHED_FIFO, ¶m );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
puts( "Init: pthread_setschedparam - set Task3 priority to highest" );
|
||||
|
||||
/* DOES NOT SWITCH to Task3 */
|
||||
|
||||
puts( "Init: Sleep 1 second" );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
sleep( 1 );
|
||||
|
||||
/* switch to task 3 */
|
||||
|
||||
puts( "Init: pthread_mutex_unlock - SUCCESSFUL" );
|
||||
status = pthread_mutex_unlock( &Mutex2_id );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
status = pthread_mutex_getprioceiling( &Mutex2_id, &ceiling );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
printf( "Init: pthread_mutex_getprioceiling- ceiling = %d\n", ceiling );
|
||||
|
||||
/* set priority of Init to highest priority */
|
||||
@@ -653,14 +653,14 @@ void *POSIX_Init(
|
||||
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
|
||||
status = pthread_setschedparam( Init_id, SCHED_FIFO, ¶m );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
puts( "Init: pthread_setschedparam - set Init priority to highest" );
|
||||
|
||||
puts( "Init: pthread_mutex_lock - EINVAL (priority ceiling violation)" );
|
||||
status = pthread_mutex_lock( &Mutex2_id );
|
||||
if ( status != EINVAL )
|
||||
printf( "status = %d\n", status );
|
||||
assert( status == EINVAL );
|
||||
rtems_test_assert( status == EINVAL );
|
||||
|
||||
/* mutexinit.c: Initialising recursive mutex */
|
||||
|
||||
@@ -678,7 +678,7 @@ void *POSIX_Init(
|
||||
status = pthread_mutex_init( &Mutex2_id, &attr );
|
||||
if ( status )
|
||||
printf( "status recursive mutex :%d\n", status );
|
||||
assert( !status );
|
||||
rtems_test_assert( !status );
|
||||
|
||||
puts( "*** END OF POSIX TEST 5 ***" );
|
||||
rtems_test_exit( 0 );
|
||||
|
||||
Reference in New Issue
Block a user