summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-12 19:54:12 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-12 19:54:12 +0000
commitc4f5e752e643099200b941d180b1d665f701449a (patch)
treea76d6264313068c123832a9243809d432f257e4a /testsuites
parentadded test case for non-NULL parameter to time() (diff)
downloadrtems-c4f5e752e643099200b941d180b1d665f701449a.tar.bz2
added test cases for clock_gettime (invalid id), clock_settime (invalid_id),
nanosleep (yield cpu), and numerous error cases in nanosleep
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/psxtests/psx01/init.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/testsuites/psxtests/psx01/init.c b/testsuites/psxtests/psx01/init.c
index 466446e6db..35788eceb7 100644
--- a/testsuites/psxtests/psx01/init.c
+++ b/testsuites/psxtests/psx01/init.c
@@ -39,6 +39,22 @@ void *POSIX_Init(
tv.tv_nsec = 0;
+ /* error cases in clock_gettime and clock_settime */
+
+ puts( "Init: clock_gettime - EINVAL (invalid clockid)" );
+ status = clock_settime( -1, &tv );
+ assert( status == -1 );
+ assert( errno == EINVAL );
+
+ puts( "Init: clock_settime - EINVAL (invalid clockid)" );
+ status = clock_settime( -1, &tv );
+ assert( status == -1 );
+ assert( errno == EINVAL );
+
+ /* now set the time of day */
+
+ printf( asctime( &tm ) );
+ puts( "Init: clock_settime - SUCCESSFUL" );
status = clock_settime( CLOCK_REALTIME, &tv );
assert( !status );
@@ -70,11 +86,43 @@ void *POSIX_Init(
printf( "Init: seconds remaining (%d)\n", (int)remaining );
assert( !remaining );
+ /* error cases in nanosleep */
+
+ puts( "Init: nanosleep - EINVAL (NULL time)" );
+ status = nanosleep ( NULL, &tr );
+ assert( status == -1 );
+ assert( errno == EINVAL );
+
+ tv.tv_sec = -1;
+ puts( "Init: nanosleep - EAGAIN (negative seconds)" );
+ status = nanosleep ( &tv, &tr );
+ assert( status == -1 );
+ assert( errno == EAGAIN );
+
+ tv.tv_sec = 0;
+ tv.tv_nsec = TOD_NANOSECONDS_PER_SECOND * 2;
+ puts( "Init: nanosleep - EINVAL (too many nanoseconds)" );
+ status = nanosleep ( &tv, &tr );
+ assert( status == -1 );
+ assert( errno == EINVAL );
+
+ /* use nanosleep to yield */
+
+ tv.tv_sec = 0;
+ tv.tv_nsec = 0;
+
+ puts( "Init: nanosleep - yield" );
+ status = nanosleep ( &tv, &tr );
+ assert( !status );
+ assert( !tr.tv_sec );
+ assert( !tr.tv_nsec );
+
/* use nanosleep to delay */
tv.tv_sec = 3;
tv.tv_nsec = 500000;
+ puts( "Init: nanosleep - 3.05 seconds" );
status = nanosleep ( &tv, &tr );
assert( !status );