summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx05
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-07-18 18:47:30 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-07-18 18:47:30 +0000
commitf5119be40abdeaea69e0c9ea09d9ca08e870fee3 (patch)
tree970d458e5842add3d1346c678de151c75776185c /testsuites/psxtests/psx05
parent2008-07-18 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-f5119be40abdeaea69e0c9ea09d9ca08e870fee3.tar.bz2
2008-07-18 Joel Sherrill <joel.sherrill@oarcorp.com>
PR 1291/cpukit * psx05/init.c, psxmsgq01/init.c: As part of addressing timeouts and POSIX services taking relative instead of absolute time for timeouts, these tests were updated.
Diffstat (limited to 'testsuites/psxtests/psx05')
-rw-r--r--testsuites/psxtests/psx05/init.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/testsuites/psxtests/psx05/init.c b/testsuites/psxtests/psx05/init.c
index 5ffe5064c2..24936898f7 100644
--- a/testsuites/psxtests/psx05/init.c
+++ b/testsuites/psxtests/psx05/init.c
@@ -1,5 +1,5 @@
/*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -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( &times, 0, (TOD_NANOSECONDS_PER_SECOND / 2) );
+
status = pthread_mutex_timedlock( &Mutex_id, &times );
- if ( status != EAGAIN )
+ if ( status != ETIMEDOUT )
printf( "status = %d\n", status );
- assert( status == EAGAIN );
+ assert( status == ETIMEDOUT );
/* switch to idle */