diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-06-03 16:30:44 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-06-03 16:30:44 +0000 |
commit | 19962562df4b4ff52dbff87b39a23fb61b72d906 (patch) | |
tree | c4c9f7c6135db2190dd7f6b3d600613652b7a4ac /c/src/tests | |
parent | created ptimer.c and moved the timer_* routines out of time.c into ptimer.c (diff) | |
download | rtems-19962562df4b4ff52dbff87b39a23fb61b72d906.tar.bz2 |
added test code for nanosleep and return code from sleep.
Diffstat (limited to 'c/src/tests')
-rw-r--r-- | c/src/tests/psxtests/psx01/init.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/c/src/tests/psxtests/psx01/init.c b/c/src/tests/psxtests/psx01/init.c index 19e1f28e2b..82f57cf9a6 100644 --- a/c/src/tests/psxtests/psx01/init.c +++ b/c/src/tests/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 ); |