summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psx12
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-08 23:02:13 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-08 23:02:13 +0000
commit54e34e7a47b08c583e8bda302ca9b8afbc12ce49 (patch)
treee17de498b6b23c808501eaf5393b54e94e3abec6 /testsuites/psxtests/psx12
parentInit: Original file - tests for condition variables. (diff)
downloadrtems-54e34e7a47b08c583e8bda302ca9b8afbc12ce49.tar.bz2
new test to test scheduling policy and paremeter paths in pthread_create.
Diffstat (limited to 'testsuites/psxtests/psx12')
-rw-r--r--testsuites/psxtests/psx12/init.c135
-rw-r--r--testsuites/psxtests/psx12/psx12.scn0
-rw-r--r--testsuites/psxtests/psx12/system.h54
-rw-r--r--testsuites/psxtests/psx12/task.c34
4 files changed, 223 insertions, 0 deletions
diff --git a/testsuites/psxtests/psx12/init.c b/testsuites/psxtests/psx12/init.c
new file mode 100644
index 0000000000..53f646e5c2
--- /dev/null
+++ b/testsuites/psxtests/psx12/init.c
@@ -0,0 +1,135 @@
+/*
+ * 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$
+ */
+
+#define CONFIGURE_INIT
+#include "system.h"
+#include <errno.h>
+
+void print_schedparam(
+ char *prefix,
+ struct sched_param *schedparam
+)
+{
+ printf( "%ssched priority = %d\n", prefix, schedparam->sched_priority );
+#if defined(_POSIX_SPORADIC_SERVER)
+ printf( "%sss_low_priority = %d\n", prefix, schedparam->ss_low_priority );
+ printf( "%sss_replenish_period = (%ld, %ld)\n", prefix,
+ schedparam->ss_replenish_period.tv_sec,
+ schedparam->ss_replenish_period.tv_nsec );
+ printf( "%sss_initial_budget = (%ld, %ld)\n", prefix,
+ schedparam->ss_initial_budget.tv_sec,
+ schedparam->ss_initial_budget.tv_nsec );
+#else
+ printf( "%s_POSIX_SPORADIC_SERVER is not defined\n" );
+#endif
+}
+
+void *POSIX_Init(
+ void *argument
+)
+{
+ int status;
+ pthread_attr_t attr;
+ struct sched_param schedparam;
+
+ puts( "\n\n*** POSIX TEST 12 ***" );
+
+ /* set the time of day, and print our buffer in multiple ways */
+
+ set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
+
+ /* get id of this thread */
+
+ Init_id = pthread_self();
+ printf( "Init's ID is 0x%08x\n", Init_id );
+
+ /* invalid scheduling policy error */
+
+ puts( "Init: pthread_attr_init - SUCCESSFUL" );
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
+ attr.schedpolicy = -1;
+
+ puts( "Init: pthread_create - EINVAL (invalid scheduling policy)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( status == EINVAL );
+
+ /* replenish period < budget error */
+
+ puts( "Init: pthread_attr_init - SUCCESSFUL" );
+ status = pthread_attr_init( &attr );
+ assert( !status );
+
+ puts( "Init: set scheduling parameter attributes for sporadic server" );
+ status = pthread_attr_setschedpolicy( &attr, SCHED_SPORADIC );
+ assert( !status );
+
+ schedparam.ss_replenish_period.tv_sec = 1;
+ schedparam.ss_replenish_period.tv_nsec = 0;
+ schedparam.ss_initial_budget.tv_sec = 2;
+ schedparam.ss_initial_budget.tv_nsec = 0;
+
+ schedparam.sched_priority = 200;
+ schedparam.ss_low_priority = 100;
+
+ status = pthread_attr_setschedparam( &attr, &schedparam );
+ assert( !status );
+
+ puts( "Init: pthread_create - EINVAL (replenish < budget)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( status == EINVAL );
+
+ /* invalid ss_low_priority error */
+
+ schedparam.ss_replenish_period.tv_sec = 2;
+ schedparam.ss_replenish_period.tv_nsec = 0;
+ schedparam.ss_initial_budget.tv_sec = 1;
+ schedparam.ss_initial_budget.tv_nsec = 0;
+
+ schedparam.sched_priority = 200;
+ schedparam.ss_low_priority = -1;
+
+ status = pthread_attr_setschedparam( &attr, &schedparam );
+ assert( !status );
+
+ puts( "Init: pthread_create - EINVAL (invalid ss_low_priority)" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( status == EINVAL );
+
+ /* create a thread as a sporadic server */
+
+ schedparam.ss_replenish_period.tv_sec = 2;
+ schedparam.ss_replenish_period.tv_nsec = 0;
+ schedparam.ss_initial_budget.tv_sec = 1;
+ schedparam.ss_initial_budget.tv_nsec = 0;
+
+ schedparam.sched_priority = 200;
+ schedparam.ss_low_priority = 100;
+
+ status = pthread_attr_setschedparam( &attr, &schedparam );
+ assert( !status );
+
+ puts( "Init: pthread_create - SUCCESSFUL" );
+ status = pthread_create( &Task_id, &attr, Task_1, NULL );
+ assert( !status );
+
+ status = pthread_join( Task_id, NULL );
+ assert( status );
+
+ /* switch to Task_1 */
+
+ puts( "*** END OF POSIX TEST 12 ***" );
+ exit( 0 );
+
+ return NULL; /* just so the compiler thinks we returned something */
+}
diff --git a/testsuites/psxtests/psx12/psx12.scn b/testsuites/psxtests/psx12/psx12.scn
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuites/psxtests/psx12/psx12.scn
diff --git a/testsuites/psxtests/psx12/system.h b/testsuites/psxtests/psx12/system.h
new file mode 100644
index 0000000000..6827f3d327
--- /dev/null
+++ b/testsuites/psxtests/psx12/system.h
@@ -0,0 +1,54 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * 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$
+ */
+
+/* functions */
+
+#include <pmacros.h>
+
+void *POSIX_Init(
+ void *argument
+);
+
+void *Task_1(
+ void *argument
+);
+
+/* configuration information */
+
+#define CONFIGURE_SPTEST
+
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
+
+#include <confdefs.h>
+
+/* global variables */
+
+#ifdef CONFIGURE_INIT
+#define TEST_EXTERN
+#else
+#define TEST_EXTERN extern
+#endif
+
+TEST_EXTERN pthread_t Init_id;
+TEST_EXTERN pthread_t Task_id;
+
+/* end of include file */
diff --git a/testsuites/psxtests/psx12/task.c b/testsuites/psxtests/psx12/task.c
new file mode 100644
index 0000000000..5e3c0b7a35
--- /dev/null
+++ b/testsuites/psxtests/psx12/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 */
+}