summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psxrwlock01/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/psxtests/psxrwlock01/test.c')
-rw-r--r--testsuites/psxtests/psxrwlock01/test.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c
index af17da1abe..433d8b2e36 100644
--- a/testsuites/psxtests/psxrwlock01/test.c
+++ b/testsuites/psxtests/psxrwlock01/test.c
@@ -37,11 +37,11 @@ void *ReadLockThread(void *arg)
puts( "ReadThread - pthread_rwlock_rdlock(RWLock) blocking -- OK" );
status = pthread_rwlock_rdlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
puts( "ReadThread - pthread_rwlock_rdlock(RWLock) unblocked -- OK" );
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
return NULL;
}
@@ -54,14 +54,14 @@ void *WriteLockThread(void *arg)
puts( "WriteThread - pthread_rwlock_wrlock(RWLock) blocking -- OK" );
status = pthread_rwlock_wrlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
puts( "WriteThread - pthread_rwlock_wrlock(RWLock) unblocked -- OK" );
sleep( 1 );
puts( "WriteThread - pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
return NULL;
}
@@ -90,75 +90,75 @@ int main(
/*************** NULL POINTER CHECKS *****************/
puts( "pthread_rwlockattr_init( NULL ) -- EINVAL" );
status = pthread_rwlockattr_init( NULL );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_setpshared( NULL, private ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_PRIVATE );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_setpshared( NULL, shared ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( NULL, PTHREAD_PROCESS_SHARED );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_getpshared( NULL, &p ) -- EINVAL" );
status = pthread_rwlockattr_getpshared( NULL, &p );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_destroy( NULL ) -- EINVAL" );
status = pthread_rwlockattr_destroy( NULL );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
/*************** NOT INITIALIZED CHECKS *****************/
/* cheat visibility */
attr.is_initialized = 0;
puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_getpshared( &attr, NULL ) -- EINVAL" );
status = pthread_rwlockattr_getpshared( &attr, NULL );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlockattr_destroy( &attr ) -- EINVAL" );
status = pthread_rwlockattr_destroy( &attr );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
/*************** BAD PSHARED CHECK *****************/
puts( "pthread_rwlockattr_setpshared( &attr, private ) -- EINVAL" );
status = pthread_rwlockattr_setpshared( &attr, ~PTHREAD_PROCESS_PRIVATE );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
/*************** ACTUALLY WORK THIS TIME *****************/
puts( "pthread_rwlockattr_init( &attr ) -- OK" );
status = pthread_rwlockattr_init( &attr );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_setpshared( &attr, private ) -- OK" );
status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" );
status = pthread_rwlockattr_getpshared( &attr, &p );
- rtems_test_assert( status == 0 );
- rtems_test_assert( p == PTHREAD_PROCESS_PRIVATE );
+ rtems_test_assert( status == 0 );
+ rtems_test_assert( p == PTHREAD_PROCESS_PRIVATE );
puts( "pthread_rwlockattr_setpshared( &attr, shared ) -- OK" );
status = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_getpshared( &attr, &p ) -- OK" );
status = pthread_rwlockattr_getpshared( &attr, &p );
- rtems_test_assert( status == 0 );
- rtems_test_assert( p == PTHREAD_PROCESS_SHARED );
+ rtems_test_assert( status == 0 );
+ rtems_test_assert( p == PTHREAD_PROCESS_SHARED );
/*************** DESTROY/REUSE CHECK *****************/
puts( "pthread_rwlockattr_destroy( &attr ) -- OK" );
status = pthread_rwlockattr_destroy( &attr );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlockattr_getpshared( &attr, &p ) destroyed -- EINVAL" );
status = pthread_rwlockattr_getpshared( &attr, &p );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
/*************** NULL ARGUMENT CHECKS *****************/
abstime.tv_sec = 0;
@@ -166,87 +166,87 @@ int main(
puts( "pthread_rwlock_init(NULL, &attr) -- EINVAL" );
status = pthread_rwlock_init(NULL, &attr);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_destroy(NULL) -- EINVAL" );
status = pthread_rwlock_destroy(NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_rdlock(NULL) -- EINVAL" );
status = pthread_rwlock_rdlock(NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedrdlock( NULL, &abstime) -- EINVAL" );
status = pthread_rwlock_timedrdlock( NULL, &abstime);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedrdlock( &rwlock, NULL) -- EINVAL" );
status = pthread_rwlock_timedrdlock( &rwlock, NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_tryrdlock(NULL) -- EINVAL" );
status = pthread_rwlock_tryrdlock(NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_wrlock(NULL) -- EINVAL" );
status = pthread_rwlock_wrlock(NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedwrlock( NULL, &abstime) -- EINVAL" );
status = pthread_rwlock_timedwrlock( NULL, &abstime );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedwrlock( &rwlock, NULL) -- EINVAL" );
status = pthread_rwlock_timedwrlock( &rwlock, NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_trywrlock(NULL) -- EINVAL" );
status = pthread_rwlock_trywrlock(NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_unlock(NULL) -- EINVAL" );
status = pthread_rwlock_unlock(NULL);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
/*************** BAD ID CHECK *****************/
rwlock = 1;
/* make a valid abstime */
puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" );
status = clock_gettime( CLOCK_REALTIME, &abstime );
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
abstime.tv_sec += 5;
puts( "pthread_rwlock_destroy(BadId) -- EINVAL" );
status = pthread_rwlock_destroy(&rwlock);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_rdlock(BadId) -- EINVAL" );
status = pthread_rwlock_rdlock(&rwlock);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedrdlock(BadId, &abstime) -- EINVAL" );
status = pthread_rwlock_timedrdlock( &rwlock, &abstime);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_tryrdlock(BadId) -- EINVAL" );
status = pthread_rwlock_tryrdlock(&rwlock);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_wrlock(BadId) -- EINVAL" );
status = pthread_rwlock_wrlock(&rwlock);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_timedwrlock(BadId, &abstime) -- EINVAL" );
status = pthread_rwlock_timedwrlock( &rwlock, &abstime );
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_trywrlock(BadId) -- EINVAL" );
status = pthread_rwlock_trywrlock(&rwlock);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
puts( "pthread_rwlock_unlock(BadId) -- EINVAL" );
status = pthread_rwlock_unlock(&rwlock);
- rtems_test_assert( status == EINVAL );
+ rtems_test_assert( status == EINVAL );
/*************** BAD ABSTIME CHECK *****************/
@@ -263,66 +263,66 @@ int main(
/*************** ACTUALLY CREATE ONE CHECK *****************/
puts( "pthread_rwlockattr_init( &attr ) -- OK" );
status = pthread_rwlockattr_init( &attr );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlock_init( &rwlock, &attr ) -- OK" );
status = pthread_rwlock_init( &rwlock, &attr );
- rtems_test_assert( status == 0 );
- rtems_test_assert( rwlock != 0 );
+ rtems_test_assert( status == 0 );
+ rtems_test_assert( rwlock != 0 );
puts( "pthread_rwlock_init( &rwlock, &attr ) -- EAGAIN" );
status = pthread_rwlock_init( &rwlock, &attr );
- rtems_test_assert( status == EAGAIN );
+ rtems_test_assert( status == EAGAIN );
puts( "pthread_rwlock_destroy( &rwlock ) -- OK" );
status = pthread_rwlock_destroy( &rwlock );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
/********* CREATE RWLOCK WITH DEFAULT ATTRIBUTES AND DESTROY IT *********/
puts( "pthread_rwlock_init( &rwlock, NULL ) -- OK" );
status = pthread_rwlock_init( &rwlock, NULL );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlock_destroy( &rwlock ) -- OK" );
status = pthread_rwlock_destroy( &rwlock );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
/*************** CREATE THREADS AND LET THEM OBTAIN READLOCK ***************/
puts( "pthread_rwlock_init( &RWLock, &attr ) -- OK" );
status = pthread_rwlock_init( &RWLock, &attr );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlock_tryrdlock(RWLock) -- OK" );
status = pthread_rwlock_tryrdlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
for (i=0 ; i<NUMBER_THREADS ; i++ ) {
printf( "Init: pthread_create - thread %d OK\n", i+1 );
status = pthread_create(&ThreadIds[i], NULL, ReadLockThread, &ThreadIds[i]);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
sleep(1);
}
puts( "pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
sleep(1);
/*************** CREATE THREADS AND LET THEM OBTAIN READLOCK ***************/
puts( "pthread_rwlock_trywrlock(RWLock) -- OK" );
status = pthread_rwlock_trywrlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
puts( "pthread_rwlock_tryrdlock(&RWLock) -- EBUSY" );
status = pthread_rwlock_tryrdlock(&RWLock);
- rtems_test_assert( status == EBUSY );
+ rtems_test_assert( status == EBUSY );
for (i=0 ; i<NUMBER_THREADS ; i++ ) {
printf( "Init: pthread_create - thread %d OK\n", i+1 );
status = pthread_create(&ThreadIds[i], NULL, ReadLockThread, &ThreadIds[i]);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
sleep(1);
}
@@ -330,101 +330,101 @@ int main(
/* Attempt delete while threads are blocked */
puts( "pthread_rwlock_destroy( &RWLock ) -- EBUSY" );
status = pthread_rwlock_destroy( &RWLock );
- rtems_test_assert( status == EBUSY );
+ rtems_test_assert( status == EBUSY );
/* now unlock it so the threads can continue */
puts( "pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
sleep(2);
/*************** CREATE THREADS AND LET THEM OBTAIN WRITE LOCK *************/
puts( "pthread_rwlock_trywrlock(RWLock) -- OK" );
status = pthread_rwlock_trywrlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
puts( "pthread_rwlock_trywrlock(&RWLock) -- EBUSY" );
status = pthread_rwlock_trywrlock(&RWLock);
- rtems_test_assert( status == EBUSY );
+ rtems_test_assert( status == EBUSY );
for (i=0 ; i<NUMBER_THREADS ; i++ ) {
printf( "Init: pthread_create - thread %d OK\n", i+1 );
status =
pthread_create(&ThreadIds[i], NULL, WriteLockThread, &ThreadIds[i]);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
sleep(1);
}
puts( "pthread_rwlock_unlock(RWLock) -- OK" );
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
sleep(2);
/*************** TIMEOUT ON RWLOCK ***************/
puts( "clock_gettime(CLOCK_REALTIME, &abstime) -- OK" );
status = clock_gettime( CLOCK_REALTIME, &abstime );
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
abstime.tv_sec += 1;
puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- OK" );
status = pthread_rwlock_timedwrlock( &RWLock, &abstime );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
abstime.tv_sec += 1;
puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" );
status = pthread_rwlock_timedrdlock( &RWLock, &abstime );
- rtems_test_assert( status == ETIMEDOUT );
+ rtems_test_assert( status == ETIMEDOUT );
abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" );
status = pthread_rwlock_timedrdlock( &RWLock, &abstime );
- rtems_test_assert( status == ETIMEDOUT );
+ rtems_test_assert( status == ETIMEDOUT );
abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- ETIMEDOUT" );
status = pthread_rwlock_timedwrlock( &RWLock, &abstime );
- rtems_test_assert( status == ETIMEDOUT );
+ rtems_test_assert( status == ETIMEDOUT );
/*************** OBTAIN RWLOCK WITH ABSTIME IN PAST ***************/
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- in past -- OK" );
status = pthread_rwlock_timedrdlock( &RWLock, &abstime );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
/*************** OBTAIN RWLOCK FOR WRITE WITH ABSTIME IN PAST ***************/
status = pthread_rwlock_unlock(&RWLock);
- rtems_test_assert( !status );
+ rtems_test_assert( !status );
abstime.tv_sec -= 1;
puts( "pthread_rwlock_timedwrlock( &RWLock, &abstime) -- in past -- OK" );
status = pthread_rwlock_timedwrlock( &RWLock, &abstime );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
/*************** DESTROY RWLOCK ***************/
puts( "pthread_rwlock_destroy( &RWLock ) -- OK" );
status = pthread_rwlock_destroy( &RWLock );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
/*************** OBTAIN A LOCK AND THEN RELEASE IT TWICE ***************/
puts( "pthread_rwlock_init( &rwlock, NULL ) -- OK" );
status = pthread_rwlock_init( &rwlock, NULL );
- rtems_test_assert( status == 0 );
- rtems_test_assert( rwlock != 0 );
+ rtems_test_assert( status == 0 );
+ rtems_test_assert( rwlock != 0 );
puts( "pthread_rwlock_unlock ( &rwlock ) -- OK" );
status = pthread_rwlock_unlock( &rwlock );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
puts( "pthread_rwlock_unlock ( &rwlock ) -- OK" );
status = pthread_rwlock_unlock( &rwlock );
- rtems_test_assert( status == 0 );
+ rtems_test_assert( status == 0 );
/*************** END OF TEST *****************/
puts( "*** END OF POSIX RWLOCK TEST 01 ***" );