summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx01
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-03 16:30:44 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-03 16:30:44 +0000
commit19962562df4b4ff52dbff87b39a23fb61b72d906 (patch)
treec4c9f7c6135db2190dd7f6b3d600613652b7a4ac /testsuites/psxtests/psx01
parentcreated ptimer.c and moved the timer_* routines out of time.c into ptimer.c (diff)
downloadrtems-19962562df4b4ff52dbff87b39a23fb61b72d906.tar.bz2
added test code for nanosleep and return code from sleep.
Diffstat (limited to 'testsuites/psxtests/psx01')
-rw-r--r--testsuites/psxtests/psx01/init.c29
1 files changed, 27 insertions, 2 deletions
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 );