diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 3bc9dc45e6..2517771a65 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,9 @@ +2009-06-30 Joel Sherrill + + * psxrwlock01/psxrwlock01.scn, psxrwlock01/test.c: Add test case for + obtaining rwlock for read with a timed lock operation when the + abstime timeout is in the past. + 2009-06-29 Joel Sherrill * psx05/init.c, psx05/psx05.scn: Add test case for process scope now diff --git a/testsuites/psxtests/psxrwlock01/psxrwlock01.scn b/testsuites/psxtests/psxrwlock01/psxrwlock01.scn index 5155dcbbb1..4f563d7a70 100644 --- a/testsuites/psxtests/psxrwlock01/psxrwlock01.scn +++ b/testsuites/psxtests/psxrwlock01/psxrwlock01.scn @@ -73,6 +73,8 @@ WriteThread - pthread_rwlock_wrlock(RWLock) unblocked -- OK clock_gettime(CLOCK_REALTIME, &abstime) -- OK pthread_rwlock_timedwrlock( &RWLock, &abstime) -- OK WriteThread - pthread_rwlock_unlock(RWLock) -- OK -pthread_rwlock_timedrdlock( &RWLock, &abstime) -- OK +pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT +pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT +pthread_rwlock_timedrdlock( &RWLock, &abstime) -- in past -- OK pthread_rwlock_destroy( &RWLock ) -- OK *** END OF POSIX RWLOCK TEST 01 *** diff --git a/testsuites/psxtests/psxrwlock01/test.c b/testsuites/psxtests/psxrwlock01/test.c index a03e032235..75f84eab66 100644 --- a/testsuites/psxtests/psxrwlock01/test.c +++ b/testsuites/psxtests/psxrwlock01/test.c @@ -328,6 +328,7 @@ int main( status = pthread_rwlock_destroy( &RWLock ); assert( status == EBUSY ); + /* now unlock it so the threads can continue */ puts( "pthread_rwlock_unlock(RWLock) -- OK" ); status = pthread_rwlock_unlock(&RWLock); assert( !status ); @@ -369,10 +370,24 @@ int main( assert( status == 0 ); abstime.tv_sec += 1; - puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- OK" ); + puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" ); status = pthread_rwlock_timedrdlock( &RWLock, &abstime ); assert( status == ETIMEDOUT ); + abstime.tv_sec -= 1; + puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- ETIMEDOUT" ); + status = pthread_rwlock_timedrdlock( &RWLock, &abstime ); + assert( status == ETIMEDOUT ); + + /*************** OBTAIN RWLOCK WITH ABSTIME IN PAST ***************/ + status = pthread_rwlock_unlock(&RWLock); + assert( !status ); + + abstime.tv_sec -= 1; + puts( "pthread_rwlock_timedrdlock( &RWLock, &abstime) -- in past -- OK" ); + status = pthread_rwlock_timedrdlock( &RWLock, &abstime ); + assert( status == 0 ); + /*************** DESTROY RWLOCK ***************/ puts( "pthread_rwlock_destroy( &RWLock ) -- OK" ); status = pthread_rwlock_destroy( &RWLock );