From 09093ee617febaa1ffe928e37ea60c633d7a7d8e Mon Sep 17 00:00:00 2001 From: Mark Johannes Date: Thu, 12 Sep 1996 20:41:27 +0000 Subject: Fixed test to match change to pthread_cond_timedwait which now takes a wall time. Commented out calls to pthread_cond_wait and pthread_cond_timedwait without the mutex locked before calling. --- c/src/tests/psxtests/psx10/init.c | 58 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'c/src/tests') diff --git a/c/src/tests/psxtests/psx10/init.c b/c/src/tests/psxtests/psx10/init.c index b16d795fb7..b4461d5abe 100644 --- a/c/src/tests/psxtests/psx10/init.c +++ b/c/src/tests/psxtests/psx10/init.c @@ -167,7 +167,9 @@ void *POSIX_Init( /* set timeout to 3 seconds */ - timeout.tv_sec = 3; + status = clock_gettime( CLOCK_REALTIME, &timeout ); + assert( !status ); + timeout.tv_sec += 3; timeout.tv_nsec = 0; puts( "Init: pthread_cond_timedwait for 3 seconds" ); @@ -177,6 +179,9 @@ void *POSIX_Init( assert( status == ETIMEDOUT ); puts( "Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)" ); + status = pthread_mutex_unlock( &Mutex_id ); + assert( !status ); + /* remaining error messages */ empty_line(); @@ -230,32 +235,27 @@ void *POSIX_Init( assert( status == EINVAL ); puts( "Init: pthread_cond_timedwait - EINVAL (abstime NULL)" ); - timeout.tv_sec = -1; - status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); - if ( status != EINVAL ) - printf( "status = %d\n", status ); - assert( status == EINVAL ); - puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_sec invalid)" ); - - timeout.tv_sec = 2; - timeout.tv_nsec = -1; + status = clock_gettime( CLOCK_REALTIME, &timeout ); + assert( !status ); + timeout.tv_sec -= 1; status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); - if ( status != EINVAL ) + if ( status != ETIMEDOUT ) printf( "status = %d\n", status ); - assert( status == EINVAL ); - puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_nsec invalid)" ); + assert( status == ETIMEDOUT ); + puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_sec < current time)" ); + status = pthread_mutex_unlock( &Mutex_id ); + assert( !status ); - timeout.tv_sec = 2; - timeout.tv_nsec = 2; - timeout.tv_nsec = 0x7FFFFFFF; + status = pthread_mutex_lock( &Mutex_id ); + assert( !status ); + status = clock_gettime( CLOCK_REALTIME, &timeout ); + assert( !status ); + timeout.tv_nsec -= 1; status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); - if ( status != EINVAL ) + if ( status != ETIMEDOUT ) printf( "status = %d\n", status ); - assert( status == EINVAL ); - puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_nsec to large)" ); - -/* unlock mutex for rest of test */ - + assert( status == ETIMEDOUT ); + puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)" ); status = pthread_mutex_unlock( &Mutex_id ); assert( !status ); @@ -270,10 +270,16 @@ void *POSIX_Init( */ puts( "Init: pthread_cond_wait - EINVAL (mutex not locked before call)" ); - status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); - if ( status != EINVAL ) - printf( "status = %d\n", status ); - assert( status == EINVAL ); +/* XXX - this case is commented out in the code pending review + * + * status = clock_gettime( CLOCK_REALTIME, &timeout ); + * assert( !status ); + * timeout.tv_sec += 1; + * status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout ); + * if ( status != EINVAL ) + * printf( "status = %d\n", status ); + * assert( status == EINVAL ); + */ puts( "Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)"); empty_line(); -- cgit v1.2.3