diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-06-30 17:50:15 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-06-30 17:50:15 +0000 |
commit | 94ccbb7b3d992ca83150f6dc984e08581019101f (patch) | |
tree | 6ba3716baaa9100ecda12ed21609c4c28329015e /testsuites/psxtests/psxrwlock01 | |
parent | 2009-06-29 Xi Yang <hiyangxi@gmail.com> (diff) | |
download | rtems-94ccbb7b3d992ca83150f6dc984e08581019101f.tar.bz2 |
2009-06-30 Joel Sherrill <joel.sherrill@OARcorp.com>
* 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.
Diffstat (limited to 'testsuites/psxtests/psxrwlock01')
-rw-r--r-- | testsuites/psxtests/psxrwlock01/psxrwlock01.scn | 4 | ||||
-rw-r--r-- | testsuites/psxtests/psxrwlock01/test.c | 17 |
2 files changed, 19 insertions, 2 deletions
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 ); |