From 19962562df4b4ff52dbff87b39a23fb61b72d906 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 3 Jun 1996 16:30:44 +0000 Subject: added test code for nanosleep and return code from sleep. --- testsuites/psxtests/psx01/init.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'testsuites/psxtests/psx01') diff --git a/testsuites/psxtests/psx01/init.c b/testsuites/psxtests/psx01/init.c index 19e1f28e2b..82f57cf9a6 100644 --- a/testsuites/psxtests/psx01/init.c +++ b/testsuites/psxtests/psx01/init.c @@ -53,10 +53,11 @@ void *POSIX_Init( time_t seconds; struct tm tm; struct timespec tv; + struct timespec tr; puts( "\n\n*** POSIX TEST 1 ***" ); - /* set the time of day */ + /* set the time of day, and print our buffer in multiple ways */ build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); @@ -71,7 +72,12 @@ void *POSIX_Init( printf( asctime( &tm ) ); printf( ctime( &tv.tv_sec ) ); - sleep( 3 ); + /* use sleep to delay */ + + seconds = sleep( 3 ); + assert( !seconds ); + + /* print new times to make sure it has changed and we can get the realtime */ status = clock_gettime( CLOCK_REALTIME, &tv ); assert( !status ); @@ -81,6 +87,25 @@ void *POSIX_Init( seconds = time( NULL ); printf( ctime( &seconds ) ); + /* use nanosleep to delay */ + + tv.tv_sec = 3; + tv.tv_nsec = 500000; + + status = nanosleep ( &tv, &tr ); + assert( !status ); + + /* print the current real time again */ + + status = clock_gettime( CLOCK_REALTIME, &tv ); + assert( !status ); + + printf( ctime( &tv.tv_sec ) ); + + /* check the time remaining */ + + assert( !tr.tv_sec && !tr.tv_nsec ); + /* create a thread */ status = pthread_create( &thread_id, NULL, Task_1_through_3, NULL ); -- cgit v1.2.3