added test cases for clock_getres

This commit is contained in:
Joel Sherrill
1996-08-12 21:15:15 +00:00
parent 1087564111
commit 5da2ae8b72
2 changed files with 54 additions and 18 deletions

View File

@@ -30,15 +30,6 @@ void *POSIX_Init(
puts( "\n\n*** POSIX TEST 1 ***" );
/* set the time of day, and print our buffer in multiple ways */
build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
tv.tv_sec = mktime( &tm );
assert( tv.tv_sec != -1 );
tv.tv_nsec = 0;
/* error cases in clock_gettime and clock_settime */
puts( "Init: clock_gettime - EINVAL (invalid clockid)" );
@@ -51,8 +42,34 @@ void *POSIX_Init(
assert( status == -1 );
assert( errno == EINVAL );
/* exercise clock_getres */
puts( "Init: clock_getres - EINVAL (invalid clockid)" );
status = clock_getres( -1, &tv );
assert( status == -1 );
assert( errno == EINVAL );
puts( "Init: clock_getres - EINVAL (NULL resolution)" );
status = clock_getres( CLOCK_REALTIME, NULL );
assert( status == -1 );
assert( errno == EINVAL );
puts( "Init: clock_getres - SUCCESSFUL" );
status = clock_getres( CLOCK_REALTIME, &tv );
printf( "Init: resolution = sec (%ld), nsec (%ld)\n", tv.tv_sec, tv.tv_nsec );
assert( !status );
/* set the time of day, and print our buffer in multiple ways */
tv.tv_sec = mktime( &tm );
assert( tv.tv_sec != -1 );
tv.tv_nsec = 0;
/* now set the time of day */
empty_line();
printf( asctime( &tm ) );
puts( "Init: clock_settime - SUCCESSFUL" );
status = clock_settime( CLOCK_REALTIME, &tv );
@@ -88,6 +105,7 @@ void *POSIX_Init(
/* error cases in nanosleep */
empty_line();
puts( "Init: nanosleep - EINVAL (NULL time)" );
status = nanosleep ( NULL, &tr );
assert( status == -1 );

View File

@@ -30,15 +30,6 @@ void *POSIX_Init(
puts( "\n\n*** POSIX TEST 1 ***" );
/* set the time of day, and print our buffer in multiple ways */
build_time( &tm, TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
tv.tv_sec = mktime( &tm );
assert( tv.tv_sec != -1 );
tv.tv_nsec = 0;
/* error cases in clock_gettime and clock_settime */
puts( "Init: clock_gettime - EINVAL (invalid clockid)" );
@@ -51,8 +42,34 @@ void *POSIX_Init(
assert( status == -1 );
assert( errno == EINVAL );
/* exercise clock_getres */
puts( "Init: clock_getres - EINVAL (invalid clockid)" );
status = clock_getres( -1, &tv );
assert( status == -1 );
assert( errno == EINVAL );
puts( "Init: clock_getres - EINVAL (NULL resolution)" );
status = clock_getres( CLOCK_REALTIME, NULL );
assert( status == -1 );
assert( errno == EINVAL );
puts( "Init: clock_getres - SUCCESSFUL" );
status = clock_getres( CLOCK_REALTIME, &tv );
printf( "Init: resolution = sec (%ld), nsec (%ld)\n", tv.tv_sec, tv.tv_nsec );
assert( !status );
/* set the time of day, and print our buffer in multiple ways */
tv.tv_sec = mktime( &tm );
assert( tv.tv_sec != -1 );
tv.tv_nsec = 0;
/* now set the time of day */
empty_line();
printf( asctime( &tm ) );
puts( "Init: clock_settime - SUCCESSFUL" );
status = clock_settime( CLOCK_REALTIME, &tv );
@@ -88,6 +105,7 @@ void *POSIX_Init(
/* error cases in nanosleep */
empty_line();
puts( "Init: nanosleep - EINVAL (NULL time)" );
status = nanosleep ( NULL, &tr );
assert( status == -1 );