summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spedfsched02
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-09-11 20:56:45 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-09-11 20:56:45 +0000
commit0d6aee4e35fc675f975a679dc1fd58d873d093e1 (patch)
tree29413772e49aa1f3749be945f3f9e19fe375a0ff /testsuites/sptests/spedfsched02
parent2011-09-11 Petr Benes <benesp16@fel.cvut.cz> (diff)
downloadrtems-0d6aee4e35fc675f975a679dc1fd58d873d093e1.tar.bz2
2011-09-11 Petr Benes <benesp16@fel.cvut.cz>
PR 1897/testing * Makefile.am, configure.ac: Add tests for Earliest Deadline First (EDF) Scheduling Algorithm implementation. * spedfsched01/.cvsignore, spedfsched01/Makefile.am, spedfsched01/init.c, spedfsched01/spedfsched01.doc, spedfsched01/spedfsched01.scn, spedfsched01/system.h, spedfsched01/task1.c, spedfsched02/.cvsignore, spedfsched02/Makefile.am, spedfsched02/getall.c, spedfsched02/init.c, spedfsched02/spedfsched02.doc, spedfsched02/spedfsched02.scn, spedfsched02/system.h, spedfsched02/task1.c, spedfsched03/.cvsignore, spedfsched03/Makefile.am, spedfsched03/edfparams.h, spedfsched03/init.c, spedfsched03/spedfsched03.doc, spedfsched03/spedfsched03.scn, spedfsched03/system.h, spedfsched03/tasks_aperiodic.c, spedfsched03/tasks_periodic.c: New files.
Diffstat (limited to 'testsuites/sptests/spedfsched02')
-rw-r--r--testsuites/sptests/spedfsched02/.cvsignore2
-rw-r--r--testsuites/sptests/spedfsched02/Makefile.am28
-rw-r--r--testsuites/sptests/spedfsched02/getall.c47
-rw-r--r--testsuites/sptests/spedfsched02/init.c69
-rw-r--r--testsuites/sptests/spedfsched02/spedfsched02.doc22
-rw-r--r--testsuites/sptests/spedfsched02/spedfsched02.scn40
-rw-r--r--testsuites/sptests/spedfsched02/system.h65
-rw-r--r--testsuites/sptests/spedfsched02/task1.c158
8 files changed, 431 insertions, 0 deletions
diff --git a/testsuites/sptests/spedfsched02/.cvsignore b/testsuites/sptests/spedfsched02/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/sptests/spedfsched02/Makefile.am b/testsuites/sptests/spedfsched02/Makefile.am
new file mode 100644
index 0000000000..3f17b97978
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/Makefile.am
@@ -0,0 +1,28 @@
+##
+## $Id$
+##
+
+MANAGERS = io rate_monotonic semaphore clock
+
+rtems_tests_PROGRAMS = spedfsched02
+spedfsched02_SOURCES = init.c getall.c task1.c system.h
+
+dist_rtems_tests_DATA = spedfsched02.scn
+dist_rtems_tests_DATA += spedfsched02.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+spedfsched02_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(spedfsched02_OBJECTS) $(spedfsched02_LDADD)
+LINK_LIBS = $(spedfsched02_LDLIBS)
+
+spedfsched02$(EXEEXT): $(spedfsched02_OBJECTS) $(spedfsched02_DEPENDENCIES)
+ @rm -f spedfsched02$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/spedfsched02/getall.c b/testsuites/sptests/spedfsched02/getall.c
new file mode 100644
index 0000000000..3409ca9d26
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/getall.c
@@ -0,0 +1,47 @@
+/* Get_all_counters
+ *
+ * This routine allows TA5 to atomically obtain the iteration counters.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+
+void Get_all_counters()
+{
+ rtems_mode previous_mode;
+ rtems_status_code status;
+
+ status = rtems_task_mode(
+ RTEMS_NO_PREEMPT,
+ RTEMS_PREEMPT_MASK,
+ &previous_mode
+ );
+ directive_failed( status, "rtems_task_mode to RTEMS_NO_PREEMPT" );
+
+ Temporary_count = Count;
+ Count.count[ 1 ] = 0;
+ Count.count[ 2 ] = 0;
+ Count.count[ 3 ] = 0;
+ Count.count[ 4 ] = 0;
+ Count.count[ 5 ] = 0;
+ Count.count[ 6 ] = 0;
+
+ status = rtems_task_mode(
+ RTEMS_PREEMPT,
+ RTEMS_PREEMPT_MASK,
+ &previous_mode
+ );
+ directive_failed( status, "rtems_task_mode to RTEMS_PREEMPT" );
+}
diff --git a/testsuites/sptests/spedfsched02/init.c b/testsuites/sptests/spedfsched02/init.c
new file mode 100644
index 0000000000..5172d16700
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/init.c
@@ -0,0 +1,69 @@
+/* Init
+ *
+ * This routine is the initialization task for this test program.
+ * It is a user initialization task and has the responsibility for creating
+ * and starting the tasks that make up the test. If the time of day
+ * clock is required for the test, it should also be set to a known
+ * value by this function.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#define CONFIGURE_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ uint32_t index;
+ rtems_status_code status;
+
+ puts( "\n\n*** TEST EDF Scheduler 2 ***" );
+
+ Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
+ Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
+ Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
+ Task_name[ 4 ] = rtems_build_name( 'T', 'A', '4', ' ' );
+ Task_name[ 5 ] = rtems_build_name( 'T', 'A', '5', ' ' );
+ Task_name[ 6 ] = rtems_build_name( 'T', 'A', '6', ' ' );
+
+ for ( index = 1 ; index <= 6 ; index++ ) {
+ status = rtems_task_create(
+ Task_name[ index ],
+ Priorities[ index ],
+ RTEMS_MINIMUM_STACK_SIZE * 4,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ index ]
+ );
+ directive_failed( status, "rtems_task_create loop" );
+ }
+
+ for ( index = 1 ; index <= 6 ; index++ ) {
+ status = rtems_task_start( Task_id[ index ], Task_1_through_6, index );
+ directive_failed( status, "rtems_task_start loop" );
+ }
+
+ Count.count[ 1 ] = 0;
+ Count.count[ 2 ] = 0;
+ Count.count[ 3 ] = 0;
+ Count.count[ 4 ] = 0;
+ Count.count[ 5 ] = 0;
+ Count.count[ 6 ] = 0;
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
diff --git a/testsuites/sptests/spedfsched02/spedfsched02.doc b/testsuites/sptests/spedfsched02/spedfsched02.doc
new file mode 100644
index 0000000000..f57dd55af1
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/spedfsched02.doc
@@ -0,0 +1,22 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2010.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: spedfsched02
+
+directives:
+
+
+concepts:
+
+ a. Verifies EDF Scheduling behavior.
diff --git a/testsuites/sptests/spedfsched02/spedfsched02.scn b/testsuites/sptests/spedfsched02/spedfsched02.scn
new file mode 100644
index 0000000000..9b82692b29
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/spedfsched02.scn
@@ -0,0 +1,40 @@
+*** TEST EDF Scheduler 2 ***
+TA1 - rtems_rate_monotonic_create id = 0x42010001
+TA1 - rtems_rate_monotonic_ident id = 0x42010001
+TA1 - (0x42010001) period 2
+TA2 - rtems_rate_monotonic_create id = 0x42010002
+TA2 - rtems_rate_monotonic_ident id = 0x42010002
+TA2 - (0x42010002) period 2
+TA3 - rtems_rate_monotonic_create id = 0x42010003
+TA3 - rtems_rate_monotonic_ident id = 0x42010003
+TA3 - (0x42010003) period 2
+TA4 - rtems_rate_monotonic_create id = 0x42010004
+TA4 - rtems_rate_monotonic_ident id = 0x42010004
+TA4 - (0x42010004) period 2
+TA6 - rtems_rate_monotonic_create id = 0x42010005
+TA6 - rtems_rate_monotonic_ident id = 0x42010005
+TA6 - (0x42010005) period 0
+TA5 - rtems_rate_monotonic_create id = 0x42010006
+TA5 - rtems_rate_monotonic_ident id = 0x42010006
+TA5 - (0x42010006) period 100
+TA5 - PERIODS CHECK OK (1)
+TA5 - PERIODS CHECK OK (2)
+TA5 - PERIODS CHECK OK (3)
+TA5 - PERIODS CHECK OK (4)
+TA5 - PERIODS CHECK OK (5)
+TA6 - Actual: 10 Expected: 10 - OK
+TA6 - Actual: 20 Expected: 20 - OK
+TA6 - Actual: 30 Expected: 30 - OK
+TA6 - Actual: 40 Expected: 40 - OK
+TA6 - Actual: 50 Expected: 50 - OK
+TA6 - Actual: 60 Expected: 60 - OK
+TA6 - Actual: 70 Expected: 70 - OK
+TA6 - Actual: 80 Expected: 80 - OK
+TA6 - Actual: 90 Expected: 90 - OK
+TA6 - Actual: 100 Expected: 100 - OK
+TA5 - PERIODS CHECK OK (6)
+TA5 - PERIODS CHECK OK (7)
+TA5 - PERIODS CHECK OK (8)
+TA5 - PERIODS CHECK OK (9)
+TA5 - PERIODS CHECK OK (10)
+*** END OF TEST EDF SCHEDULER 2 ***
diff --git a/testsuites/sptests/spedfsched02/system.h b/testsuites/sptests/spedfsched02/system.h
new file mode 100644
index 0000000000..d397050dbd
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/system.h
@@ -0,0 +1,65 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <tmacros.h>
+
+/* types */
+
+struct counters {
+ uint32_t count[7];
+};
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+rtems_task Task_1_through_6(
+ rtems_task_argument argument
+);
+
+void Get_all_counters( void );
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 100000
+
+#define CONFIGURE_MAXIMUM_TASKS 7
+#define CONFIGURE_MAXIMUM_PERIODS 10
+
+#define CONFIGURE_INIT_TASK_PRIORITY 10
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXTRA_TASK_STACKS (6 * 4 * RTEMS_MINIMUM_STACK_SIZE)
+
+#define CONFIGURE_SCHEDULER_EDF
+
+#include <rtems/confdefs.h>
+
+/* global variables */
+
+TEST_EXTERN rtems_id Task_id[ 7 ]; /* array of task ids */
+TEST_EXTERN rtems_name Task_name[ 7 ]; /* array of task names */
+
+TEST_EXTERN struct counters Count; /* iteration counters */
+TEST_EXTERN struct counters Temporary_count;
+extern rtems_task_priority Priorities[ 7 ];
+
+/* end of include file */
diff --git a/testsuites/sptests/spedfsched02/task1.c b/testsuites/sptests/spedfsched02/task1.c
new file mode 100644
index 0000000000..e516eaeafe
--- /dev/null
+++ b/testsuites/sptests/spedfsched02/task1.c
@@ -0,0 +1,158 @@
+/* Task_1_through_6
+ *
+ * This routine serves as a test task for the EDF scheduling
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+
+/*
+ runtime of TA6 should be shorter than TA5
+ */
+#define TA6_ITERATIONS 10
+#define TA6_PERIOD_FACTOR 10
+
+uint32_t Periods[7] = { 0, 2, 2, 2, 2, 100, 0 };
+uint32_t Iterations[7] = { 0, 50, 50, 50, 50, 1, TA6_ITERATIONS };
+rtems_task_priority Priorities[7] = { 0, 2, 2, 2, 2, 100, 1 };
+
+rtems_task Task_1_through_6(
+ rtems_task_argument argument
+)
+{
+ rtems_id rmid;
+ rtems_id test_rmid;
+ int index;
+ int pass;
+ uint32_t failed;
+ rtems_status_code status;
+
+ status = rtems_rate_monotonic_create( argument, &rmid );
+ directive_failed( status, "rtems_rate_monotonic_create" );
+ put_name( Task_name[ argument ], FALSE );
+ printf( "- rtems_rate_monotonic_create id = 0x%08" PRIxrtems_id "\n",
+ rmid );
+
+ status = rtems_rate_monotonic_ident( argument, &test_rmid );
+ directive_failed( status, "rtems_rate_monotonic_ident" );
+ put_name( Task_name[ argument ], FALSE );
+ printf( "- rtems_rate_monotonic_ident id = 0x%08" PRIxrtems_id "\n",
+ test_rmid );
+
+ if ( rmid != test_rmid ) {
+ printf( "RMID's DO NOT MATCH (0x%" PRIxrtems_id " and 0x%" PRIxrtems_id ")\n",
+ rmid, test_rmid );
+ rtems_test_exit( 0 );
+ }
+
+ put_name( Task_name[ argument ], FALSE );
+ printf( "- (0x%08" PRIxrtems_id ") period %" PRIu32 "\n",
+ rmid, Periods[ argument ] );
+
+ status = rtems_task_wake_after( 2 );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ switch ( argument ) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ while ( FOREVER ) {
+ status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
+ directive_failed( status, "rtems_rate_monotonic_period" );
+
+ Count.count[ argument ]++;
+ }
+ break;
+ case 5:
+ pass = 0;
+ failed = 0;
+
+ status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
+ directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
+
+ Get_all_counters();
+
+ while ( FOREVER ) {
+
+ status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
+ directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
+
+ Get_all_counters();
+
+ for( index = 1 ; index <= 4 ; index++ ) {
+ if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
+ puts_nocr( "FAIL -- " );
+ put_name ( Task_name[ index ], FALSE );
+ printf ( " Actual=%" PRIu32 ", Expected=%" PRIu32 "\n",
+ Temporary_count.count[ index ],
+ Iterations[ index ]
+ );
+ failed += 1;
+ }
+ }
+
+ if ( failed == 5 )
+ rtems_test_exit( 0 );
+
+ pass += 1;
+
+ printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
+
+ fflush( stdout );
+
+ if ( pass == 10 ) {
+ puts( "*** END OF TEST EDF SCHEDULER 2 ***" );
+ rtems_test_exit( 0 );
+ }
+
+ }
+ break;
+ case 6:
+ /* test changing periods */
+ {
+ uint32_t time[TA6_ITERATIONS+1];
+ rtems_interval period;
+
+ period = 1*TA6_PERIOD_FACTOR;
+ status = rtems_rate_monotonic_period( rmid, period);
+ directive_failed( status, "rtems_rate_monotonic_period of TA6" );
+ time[0] = _Watchdog_Ticks_since_boot; /* timestamp */
+ /*printf("%d - %d\n", period, time[0]);*/
+
+ for (index = 1; index <= TA6_ITERATIONS; index++)
+ {
+ period = (index+1)*TA6_PERIOD_FACTOR;
+ status = rtems_rate_monotonic_period( rmid, period);
+ directive_failed( status, "rtems_rate_monotonic_period of TA6" );
+ time[index] = _Watchdog_Ticks_since_boot; /* timestamp */
+ /*printf("%d - %d\n", period, time[index]);*/
+ }
+
+ for (index = 1; index <= TA6_ITERATIONS; index++)
+ {
+ rtems_interval meas = time[index] - time[index-1];
+ period = index*TA6_PERIOD_FACTOR;
+ printf( "TA6 - Actual: %" PRIdrtems_interval " Expected: %"
+ PRIdrtems_interval, meas, period );
+ if (period == meas) printf(" - OK\n");
+ else printf(" - FAILED\n");
+ }
+ }
+ rtems_task_suspend(RTEMS_SELF);
+ break;
+ }
+}