summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx07
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-08 21:46:40 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-08 21:46:40 +0000
commit76de65b3715ff4f953faa0beda6f5e1d66a0ff0c (patch)
treee4e2006c3982c713922679fde8306c48d2e322e9 /testsuites/psxtests/psx07
parentadded test to complete coverage of pthread_setschedparam and increase (diff)
downloadrtems-76de65b3715ff4f953faa0beda6f5e1d66a0ff0c.tar.bz2
added cases to increase coverage of pthread_create. cases added tested
error paths as well as inherit scheduling attributes.
Diffstat (limited to 'testsuites/psxtests/psx07')
-rw-r--r--testsuites/psxtests/psx07/init.c59
-rw-r--r--testsuites/psxtests/psx07/system.h5
-rw-r--r--testsuites/psxtests/psx07/task.c34
3 files changed, 98 insertions, 0 deletions
diff --git a/testsuites/psxtests/psx07/init.c b/testsuites/psxtests/psx07/init.c
index 62dbe76cce..e46331d34f 100644
--- a/testsuites/psxtests/psx07/init.c
+++ b/testsuites/psxtests/psx07/init.c
@@ -84,10 +84,69 @@ void *POSIX_Init(
status = pthread_attr_destroy( &destroyed_attr );
assert( status == EINVAL );
+ /* check some errors in pthread_create */
+
+ puts( "Init: pthread_create - EINVAL (attr not initialized)" );
+ status = pthread_create( &Task_id, &destroyed_attr, Task_1, NULL );
+ assert( status == EINVAL );
+
+ /* junk stack address */
+ status = pthread_attr_setstackaddr( &attr, (void *)&schedparam );
+ assert( !status );
+
+ /* must go around pthread_attr_setstacksize to set a bad stack size */
+ attr.stacksize = 0;
+
+ puts( "Init: pthread_create - EINVAL (stacksize too small)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( status == EINVAL );
+
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
+ /* must go around pthread_attr_set routines to set a bad value */
+ attr.inheritsched = -1;
+
+ puts( "Init: pthread_create - EINVAL (invalid inherit scheduler)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( status == EINVAL );
+
+ /* check out the error case for system scope not supported */
+
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
+ /* must go around pthread_attr_set routines to set a bad value */
+ attr.contentionscope = PTHREAD_SCOPE_SYSTEM;
+
+ puts( "Init: pthread_create - ENOSYS (unsupported system contention scope)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( status == ENOSYS );
+
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
+ /* now check out pthread_create for inherit scheduler */
+
+ status = pthread_attr_setinheritsched( &attr, PTHREAD_INHERIT_SCHED );
+ assert( !status );
+
+ puts( "Init: pthread_create - SUCCESSFUL (inherit scheduler)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( !status );
+
+ status = pthread_join( Task_id, NULL );
+ assert( !status );
+
+ /* switch to Task_1 */
+
/* exercise get and set scope */
empty_line();
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
puts( "Init: pthread_attr_setscope - EINVAL (NULL attr)" );
status = pthread_attr_setscope( NULL, PTHREAD_SCOPE_PROCESS );
assert( status == EINVAL );
diff --git a/testsuites/psxtests/psx07/system.h b/testsuites/psxtests/psx07/system.h
index 893310ec67..fab0c2c822 100644
--- a/testsuites/psxtests/psx07/system.h
+++ b/testsuites/psxtests/psx07/system.h
@@ -22,6 +22,10 @@ void *POSIX_Init(
void *argument
);
+void *Task_1(
+ void *argument
+);
+
/* configuration information */
#define CONFIGURE_SPTEST
@@ -42,5 +46,6 @@ void *POSIX_Init(
#endif
TEST_EXTERN pthread_t Init_id;
+TEST_EXTERN pthread_t Task_id;
/* end of include file */
diff --git a/testsuites/psxtests/psx07/task.c b/testsuites/psxtests/psx07/task.c
new file mode 100644
index 0000000000..5e3c0b7a35
--- /dev/null
+++ b/testsuites/psxtests/psx07/task.c
@@ -0,0 +1,34 @@
+/* Task_1
+ *
+ * This routine serves as a test task. It verifies the basic task
+ * switching capabilities of the executive.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+#include <time.h>
+#include <sched.h>
+
+void *Task_1(
+ void *argument
+)
+{
+ puts( "Task_1: exitting" );
+ pthread_exit( NULL );
+
+ return NULL; /* just so the compiler thinks we returned something */
+}