diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-07-22 17:21:59 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-07-22 17:21:59 +0000 |
commit | 1016b7751495a3598ec29ce07f30d975bed131c0 (patch) | |
tree | 9a4190cb5dbe84ed0338eb84e710b81ae7d18146 | |
parent | e5c0540d6aa94583ca59b7e1cfe346e576069d38 (diff) |
2008-07-22 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1291/cpukit
* psx05/init.c, psxmsgq01/init.c: Update tests to reflect absolute
time.
-rw-r--r-- | testsuites/psxtests/ChangeLog | 6 | ||||
-rw-r--r-- | testsuites/psxtests/psx05/init.c | 29 | ||||
-rw-r--r-- | testsuites/psxtests/psxmsgq01/init.c | 38 |
3 files changed, 48 insertions, 25 deletions
diff --git a/testsuites/psxtests/ChangeLog b/testsuites/psxtests/ChangeLog index 113eb7677d..202f1d7a6f 100644 --- a/testsuites/psxtests/ChangeLog +++ b/testsuites/psxtests/ChangeLog @@ -1,3 +1,9 @@ +2008-07-22 Joel Sherrill <joel.sherrill@OARcorp.com> + + PR 1291/cpukit + * psx05/init.c, psxmsgq01/init.c: Update tests to reflect absolute + time. + 2007-11-27 Glenn Humphrey <glenn.humphrey@OARcorp.com> * psxbarrier01/psxbarrier01.scn, psxbarrier01/test.c, diff --git a/testsuites/psxtests/psx05/init.c b/testsuites/psxtests/psx05/init.c index 5ffe5064c2..9a79f253dc 100644 --- a/testsuites/psxtests/psx05/init.c +++ b/testsuites/psxtests/psx05/init.c @@ -72,6 +72,27 @@ void Print_mutexattr( } } +void calculate_abstimeout( + struct timespec *times, + uint32_t seconds, + uint32_t nanoseconds +) +{ + struct timeval tv1; + struct timezone tz1; + + gettimeofday( &tv1, &tz1 ); + + times->tv_sec = seconds + tv1.tv_sec; + times->tv_nsec = nanoseconds + (tv1.tv_usec * 1000); + + while ( times->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) { + times->tv_sec++; + times->tv_nsec - TOD_NANOSECONDS_PER_SECOND; + } + +} + void *POSIX_Init( void *argument ) @@ -343,13 +364,13 @@ void *POSIX_Init( printf( "status = %d\n", status ); assert( status == EPERM ); - times.tv_sec = 0; - times.tv_nsec = 500000000; puts( "Init: pthread_mutex_timedlock - time out in 1/2 second" ); + calculate_abstimeout( ×, 0, (TOD_NANOSECONDS_PER_SECOND / 2) ); + status = pthread_mutex_timedlock( &Mutex_id, × ); - if ( status != EAGAIN ) + if ( status != ETIMEDOUT ) printf( "status = %d\n", status ); - assert( status == EAGAIN ); + assert( status == ETIMEDOUT ); /* switch to idle */ diff --git a/testsuites/psxtests/psxmsgq01/init.c b/testsuites/psxtests/psxmsgq01/init.c index b152ffc6fb..7ddb5827c8 100644 --- a/testsuites/psxtests/psxmsgq01/init.c +++ b/testsuites/psxtests/psxmsgq01/init.c @@ -750,29 +750,26 @@ void verify_timed_send_queue( int status; char *msg; - timeout.tv_sec = 1; - timeout.tv_nsec = 0; - printf( "Init: mq_timedsend - on queue %s ", Test_q[que].name); len = Predefined_Msgs[MAXMSG].size; msg = Predefined_Msgs[MAXMSG].msg; + gettimeofday( &tv1, &tz1 ); + timeout.tv_sec = tv1.tv_sec + 1; + timeout.tv_nsec = tv1.tv_usec * 1000; + status = mq_timedsend( Test_q[que].mq, msg, len , 0, &timeout ); + gettimeofday( &tv2, &tz2 ); tv3.tv_sec = tv2.tv_sec - tv1.tv_sec; tv3.tv_usec = tv2.tv_usec - tv1.tv_usec; if ( is_blocking ) { /* Don't verify the non-blocking queue */ - fatal_int_service_status( status, -1, "mq_timedsend status"); - fatal_posix_service_status( errno, ETIMEDOUT, "errno ETIMEDOUT"); + fatal_int_service_status( status, -1, "mq_timedsend status" ); + fatal_posix_service_status( errno, ETIMEDOUT, "errno ETIMEDOUT" ); } - printf("Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec ); - - if ( is_blocking ) /* non-blocking queue */ - assert( tv3.tv_sec == 1 ); - else - assert( tv3.tv_sec == 0 ); + printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec ); if ( que == DEFAULT_RW ) Test_q[que].count++; @@ -805,13 +802,18 @@ void verify_timed_receive_queue( struct timezone tz1, tz2; int status; - tm.tv_sec = 1; - tm.tv_nsec = 0; - - printf( "Init: %s mq_timedreceive - on queue %s ", task_name, Test_q[que].name); + printf( + "Init: %s mq_timedreceive - on queue %s ", + task_name, + Test_q[que].name + ); gettimeofday( &tv1, &tz1 ); + tm.tv_sec = tv1.tv_sec + 1; + tm.tv_nsec = tv1.tv_usec * 1000; + status = mq_timedreceive( Test_q[ que ].mq, message, 100, &priority, &tm ); + gettimeofday( &tv2, &tz2 ); tv3.tv_sec = tv2.tv_sec - tv1.tv_sec; tv3.tv_usec = tv2.tv_usec - tv1.tv_usec; @@ -821,14 +823,8 @@ void verify_timed_receive_queue( fatal_posix_service_status( errno, ETIMEDOUT, "errno ETIMEDOUT"); printf( "Init: %ld sec %ld us\n", (long)tv3.tv_sec, (long)tv3.tv_usec ); - if ( is_blocking ) - assert( tv3.tv_sec == 1 ); - else - assert( tv3.tv_sec == 0 ); } - - void verify_timed_receive() { int que; |