Changeset 09093ee in rtems


Ignore:
Timestamp:
Sep 12, 1996, 8:41:27 PM (24 years ago)
Author:
Mark Johannes <Mark.Johannes@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
ded66f8
Parents:
cda277f
Message:

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.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/psxtests/psx10/init.c

    rcda277f r09093ee  
    168168/* set timeout to 3 seconds */
    169169
    170   timeout.tv_sec = 3;
     170  status = clock_gettime( CLOCK_REALTIME, &timeout );
     171  assert( !status );
     172  timeout.tv_sec += 3;
    171173  timeout.tv_nsec = 0;
    172174
     
    178180  puts( "Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)" );
    179181
     182  status = pthread_mutex_unlock( &Mutex_id );
     183  assert( !status );
     184
    180185/* remaining error messages */
    181186
     
    231236  puts( "Init: pthread_cond_timedwait - EINVAL (abstime NULL)" );
    232237
    233   timeout.tv_sec = -1;
     238  status = clock_gettime( CLOCK_REALTIME, &timeout );
     239  assert( !status );
     240  timeout.tv_sec -= 1;
    234241  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    235   if ( status != EINVAL )
    236     printf( "status = %d\n", status );
    237   assert( status == EINVAL );
    238   puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_sec invalid)" );
    239 
    240   timeout.tv_sec = 2;
    241   timeout.tv_nsec = -1;
     242  if ( status != ETIMEDOUT )
     243    printf( "status = %d\n", status );
     244  assert( status == ETIMEDOUT );
     245  puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_sec < current time)" );
     246  status = pthread_mutex_unlock( &Mutex_id );
     247  assert( !status );
     248
     249  status = pthread_mutex_lock( &Mutex_id );
     250  assert( !status );
     251  status = clock_gettime( CLOCK_REALTIME, &timeout );
     252  assert( !status );
     253  timeout.tv_nsec -= 1;
    242254  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    243   if ( status != EINVAL )
    244     printf( "status = %d\n", status );
    245   assert( status == EINVAL );
    246   puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_nsec invalid)" );
    247 
    248   timeout.tv_sec = 2;
    249   timeout.tv_nsec = 2;
    250   timeout.tv_nsec = 0x7FFFFFFF;
    251   status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    252   if ( status != EINVAL )
    253     printf( "status = %d\n", status );
    254   assert( status == EINVAL );
    255   puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_nsec to large)" );
    256 
    257 /* unlock mutex for rest of test */
    258 
     255  if ( status != ETIMEDOUT )
     256    printf( "status = %d\n", status );
     257  assert( status == ETIMEDOUT );
     258  puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)" );
    259259  status = pthread_mutex_unlock( &Mutex_id );
    260260  assert( !status );
     
    271271  puts( "Init: pthread_cond_wait - EINVAL (mutex not locked before call)" );
    272272
    273   status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    274   if ( status != EINVAL )
    275     printf( "status = %d\n", status );
    276   assert( status == EINVAL );
     273/* XXX - this case is commented out in the code pending review
     274 *
     275 *  status = clock_gettime( CLOCK_REALTIME, &timeout );
     276 *  assert( !status );
     277 *  timeout.tv_sec += 1;
     278 *  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
     279 *  if ( status != EINVAL )
     280 *    printf( "status = %d\n", status );
     281 *  assert( status == EINVAL );
     282 */
    277283  puts( "Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)");
    278284
  • testsuites/psxtests/psx10/init.c

    rcda277f r09093ee  
    168168/* set timeout to 3 seconds */
    169169
    170   timeout.tv_sec = 3;
     170  status = clock_gettime( CLOCK_REALTIME, &timeout );
     171  assert( !status );
     172  timeout.tv_sec += 3;
    171173  timeout.tv_nsec = 0;
    172174
     
    178180  puts( "Init: pthread_cond_timedwait - ETIMEDOUT - (mutex not acquired)" );
    179181
     182  status = pthread_mutex_unlock( &Mutex_id );
     183  assert( !status );
     184
    180185/* remaining error messages */
    181186
     
    231236  puts( "Init: pthread_cond_timedwait - EINVAL (abstime NULL)" );
    232237
    233   timeout.tv_sec = -1;
     238  status = clock_gettime( CLOCK_REALTIME, &timeout );
     239  assert( !status );
     240  timeout.tv_sec -= 1;
    234241  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    235   if ( status != EINVAL )
    236     printf( "status = %d\n", status );
    237   assert( status == EINVAL );
    238   puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_sec invalid)" );
    239 
    240   timeout.tv_sec = 2;
    241   timeout.tv_nsec = -1;
     242  if ( status != ETIMEDOUT )
     243    printf( "status = %d\n", status );
     244  assert( status == ETIMEDOUT );
     245  puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_sec < current time)" );
     246  status = pthread_mutex_unlock( &Mutex_id );
     247  assert( !status );
     248
     249  status = pthread_mutex_lock( &Mutex_id );
     250  assert( !status );
     251  status = clock_gettime( CLOCK_REALTIME, &timeout );
     252  assert( !status );
     253  timeout.tv_nsec -= 1;
    242254  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    243   if ( status != EINVAL )
    244     printf( "status = %d\n", status );
    245   assert( status == EINVAL );
    246   puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_nsec invalid)" );
    247 
    248   timeout.tv_sec = 2;
    249   timeout.tv_nsec = 2;
    250   timeout.tv_nsec = 0x7FFFFFFF;
    251   status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    252   if ( status != EINVAL )
    253     printf( "status = %d\n", status );
    254   assert( status == EINVAL );
    255   puts( "Init: pthread_cond_timedwait - EINVAL (abstime->tv_nsec to large)" );
    256 
    257 /* unlock mutex for rest of test */
    258 
     255  if ( status != ETIMEDOUT )
     256    printf( "status = %d\n", status );
     257  assert( status == ETIMEDOUT );
     258  puts( "Init: pthread_cond_timedwait - ETIMEDOUT (abstime->tv_nsec < current time)" );
    259259  status = pthread_mutex_unlock( &Mutex_id );
    260260  assert( !status );
     
    271271  puts( "Init: pthread_cond_wait - EINVAL (mutex not locked before call)" );
    272272
    273   status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
    274   if ( status != EINVAL )
    275     printf( "status = %d\n", status );
    276   assert( status == EINVAL );
     273/* XXX - this case is commented out in the code pending review
     274 *
     275 *  status = clock_gettime( CLOCK_REALTIME, &timeout );
     276 *  assert( !status );
     277 *  timeout.tv_sec += 1;
     278 *  status = pthread_cond_timedwait( &Cond1_id, &Mutex_id, &timeout );
     279 *  if ( status != EINVAL )
     280 *    printf( "status = %d\n", status );
     281 *  assert( status == EINVAL );
     282 */
    277283  puts( "Init: pthread_cond_timedwait - EINVAL (mutex not locked before call)");
    278284
Note: See TracChangeset for help on using the changeset viewer.