summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-08 16:28:24 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-08 16:28:24 +0000
commit644c0fa6184bafa0ca8cd560ce9b5b4224863ee6 (patch)
tree41aec637559fa46505bc90895ed29b824769dffb
parent_MPCI_Register_packet_processor: changed protoype first parameter type to MP_... (diff)
downloadrtems-644c0fa6184bafa0ca8cd560ce9b5b4224863ee6.tar.bz2
added complete test cases for pthread_once.
-rw-r--r--c/src/tests/psxtests/psx01/init.c16
-rw-r--r--c/src/tests/psxtests/psx01/system.h1
-rw-r--r--c/src/tests/psxtests/psx01/task.c43
-rw-r--r--testsuites/psxtests/psx01/init.c16
-rw-r--r--testsuites/psxtests/psx01/system.h1
-rw-r--r--testsuites/psxtests/psx01/task.c43
6 files changed, 88 insertions, 32 deletions
diff --git a/c/src/tests/psxtests/psx01/init.c b/c/src/tests/psxtests/psx01/init.c
index 75aa73ac65..e62030c295 100644
--- a/c/src/tests/psxtests/psx01/init.c
+++ b/c/src/tests/psxtests/psx01/init.c
@@ -62,7 +62,7 @@ void *POSIX_Init(
/* check the time remaining */
- printf( "seconds remaining (%d)\n", (int)remaining );
+ printf( "Init: seconds remaining (%d)\n", (int)remaining );
assert( !remaining );
/* use nanosleep to delay */
@@ -82,33 +82,33 @@ void *POSIX_Init(
/* check the time remaining */
- printf( "sec (%d), nsec (%d) remaining\n", (int)tr.tv_sec, (int)tr.tv_nsec );
+ printf( "Init: sec (%ld), nsec (%ld) remaining\n", tr.tv_sec, tr.tv_nsec );
assert( !tr.tv_sec && !tr.tv_nsec );
/* get id of this thread */
Init_id = pthread_self();
- printf( "Init's ID is 0x%08x\n", Init_id );
+ printf( "Init: ID is 0x%08x\n", Init_id );
/* print the minimum priority */
priority = sched_get_priority_min( SCHED_FIFO );
- printf( "Minimum priority for FIFO is %d\n", priority );
+ printf( "Init: Minimum priority for FIFO is %d\n", priority );
assert( priority != -1 );
/* print the maximum priority */
priority = sched_get_priority_max( SCHED_FIFO );
- printf( "Maximum priority for FIFO is %d\n", priority );
+ printf( "Init: Maximum priority for FIFO is %d\n", priority );
assert( priority != -1 );
/* print the round robin time quantum */
status = sched_rr_get_interval( getpid(), &tr );
printf(
- "Round Robin quantum is %d seconds, %d nanoseconds\n",
- (int) tr.tv_sec,
- (int) tr.tv_nsec
+ "Init: Round Robin quantum is %ld seconds, %ld nanoseconds\n",
+ tr.tv_sec,
+ tr.tv_nsec
);
assert( !status );
diff --git a/c/src/tests/psxtests/psx01/system.h b/c/src/tests/psxtests/psx01/system.h
index 3abfff0e19..a0e2220827 100644
--- a/c/src/tests/psxtests/psx01/system.h
+++ b/c/src/tests/psxtests/psx01/system.h
@@ -18,6 +18,7 @@
#include <pmacros.h>
#include <unistd.h>
+#include <errno.h>
void *POSIX_Init(
void *argument
diff --git a/c/src/tests/psxtests/psx01/task.c b/c/src/tests/psxtests/psx01/task.c
index 4ff3d8e450..d9ee2e781a 100644
--- a/c/src/tests/psxtests/psx01/task.c
+++ b/c/src/tests/psxtests/psx01/task.c
@@ -21,36 +21,63 @@
#include "system.h"
+void Test_init_routine( void )
+{
+ puts( "Test_init_routine: invoked" );
+}
+
+
void *Task_1_through_3(
void *argument
)
{
int status;
+ pthread_once_t once = PTHREAD_ONCE_INIT;
- /* XXX temporary */
+ empty_line();
/* get id of this thread */
Task_id = pthread_self();
- printf( "Task's ID is 0x%08x\n", Task_id );
+ printf( "Task_1: ID is 0x%08x\n", Task_id );
+
+ /* exercise pthread_equal */
status = pthread_equal( Task_id, Task_id );
if ( status )
- puts( "pthread_equal match case passed" );
+ puts( "Task_1: pthread_equal match case passed" );
assert( status );
status = pthread_equal( Init_id, Task_id );
if ( !status )
- puts( "pthread_equal different case passed" );
+ puts( "Task_1: pthread_equal different case passed" );
assert( !status );
- puts( "pthread_equal first id bad" );
+ puts( "Task_1: pthread_equal first id bad" );
status = pthread_equal( -1, Task_id );
- assert( status == 0);
+ assert( !status );
- puts( "pthread_equal second id bad" );
+ puts( "Task_1: pthread_equal second id bad" );
status = pthread_equal( Init_id, -1 );
- assert( status == 0);
+ assert( !status );
+
+ /* exercise pthread_once */
+
+ puts( "Task_1: pthread_once - EINVAL (NULL once_control)" );
+ status = pthread_once( NULL, Test_init_routine );
+ assert( status == EINVAL );
+
+ puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" );
+ status = pthread_once( &once, NULL );
+ assert( status == EINVAL );
+
+ puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" );
+ status = pthread_once( &once, Test_init_routine );
+ assert( !status );
+
+ puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" );
+ status = pthread_once( &once, Test_init_routine );
+ assert( !status );
puts( "*** END OF POSIX TEST 1 ***" );
exit( 0 );
diff --git a/testsuites/psxtests/psx01/init.c b/testsuites/psxtests/psx01/init.c
index 75aa73ac65..e62030c295 100644
--- a/testsuites/psxtests/psx01/init.c
+++ b/testsuites/psxtests/psx01/init.c
@@ -62,7 +62,7 @@ void *POSIX_Init(
/* check the time remaining */
- printf( "seconds remaining (%d)\n", (int)remaining );
+ printf( "Init: seconds remaining (%d)\n", (int)remaining );
assert( !remaining );
/* use nanosleep to delay */
@@ -82,33 +82,33 @@ void *POSIX_Init(
/* check the time remaining */
- printf( "sec (%d), nsec (%d) remaining\n", (int)tr.tv_sec, (int)tr.tv_nsec );
+ printf( "Init: sec (%ld), nsec (%ld) remaining\n", tr.tv_sec, tr.tv_nsec );
assert( !tr.tv_sec && !tr.tv_nsec );
/* get id of this thread */
Init_id = pthread_self();
- printf( "Init's ID is 0x%08x\n", Init_id );
+ printf( "Init: ID is 0x%08x\n", Init_id );
/* print the minimum priority */
priority = sched_get_priority_min( SCHED_FIFO );
- printf( "Minimum priority for FIFO is %d\n", priority );
+ printf( "Init: Minimum priority for FIFO is %d\n", priority );
assert( priority != -1 );
/* print the maximum priority */
priority = sched_get_priority_max( SCHED_FIFO );
- printf( "Maximum priority for FIFO is %d\n", priority );
+ printf( "Init: Maximum priority for FIFO is %d\n", priority );
assert( priority != -1 );
/* print the round robin time quantum */
status = sched_rr_get_interval( getpid(), &tr );
printf(
- "Round Robin quantum is %d seconds, %d nanoseconds\n",
- (int) tr.tv_sec,
- (int) tr.tv_nsec
+ "Init: Round Robin quantum is %ld seconds, %ld nanoseconds\n",
+ tr.tv_sec,
+ tr.tv_nsec
);
assert( !status );
diff --git a/testsuites/psxtests/psx01/system.h b/testsuites/psxtests/psx01/system.h
index 3abfff0e19..a0e2220827 100644
--- a/testsuites/psxtests/psx01/system.h
+++ b/testsuites/psxtests/psx01/system.h
@@ -18,6 +18,7 @@
#include <pmacros.h>
#include <unistd.h>
+#include <errno.h>
void *POSIX_Init(
void *argument
diff --git a/testsuites/psxtests/psx01/task.c b/testsuites/psxtests/psx01/task.c
index 4ff3d8e450..d9ee2e781a 100644
--- a/testsuites/psxtests/psx01/task.c
+++ b/testsuites/psxtests/psx01/task.c
@@ -21,36 +21,63 @@
#include "system.h"
+void Test_init_routine( void )
+{
+ puts( "Test_init_routine: invoked" );
+}
+
+
void *Task_1_through_3(
void *argument
)
{
int status;
+ pthread_once_t once = PTHREAD_ONCE_INIT;
- /* XXX temporary */
+ empty_line();
/* get id of this thread */
Task_id = pthread_self();
- printf( "Task's ID is 0x%08x\n", Task_id );
+ printf( "Task_1: ID is 0x%08x\n", Task_id );
+
+ /* exercise pthread_equal */
status = pthread_equal( Task_id, Task_id );
if ( status )
- puts( "pthread_equal match case passed" );
+ puts( "Task_1: pthread_equal match case passed" );
assert( status );
status = pthread_equal( Init_id, Task_id );
if ( !status )
- puts( "pthread_equal different case passed" );
+ puts( "Task_1: pthread_equal different case passed" );
assert( !status );
- puts( "pthread_equal first id bad" );
+ puts( "Task_1: pthread_equal first id bad" );
status = pthread_equal( -1, Task_id );
- assert( status == 0);
+ assert( !status );
- puts( "pthread_equal second id bad" );
+ puts( "Task_1: pthread_equal second id bad" );
status = pthread_equal( Init_id, -1 );
- assert( status == 0);
+ assert( !status );
+
+ /* exercise pthread_once */
+
+ puts( "Task_1: pthread_once - EINVAL (NULL once_control)" );
+ status = pthread_once( NULL, Test_init_routine );
+ assert( status == EINVAL );
+
+ puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" );
+ status = pthread_once( &once, NULL );
+ assert( status == EINVAL );
+
+ puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" );
+ status = pthread_once( &once, Test_init_routine );
+ assert( !status );
+
+ puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" );
+ status = pthread_once( &once, Test_init_routine );
+ assert( !status );
puts( "*** END OF POSIX TEST 1 ***" );
exit( 0 );