]> rtime.felk.cvut.cz Git - rtems-pluggable-edf.git/commitdiff
Test application draft for EDF added in src/test_edf/.
authorPetr Benes <benesp16@fel.cvut.cz>
Wed, 13 Apr 2011 15:54:37 +0000 (17:54 +0200)
committerPetr Benes <benesp16@fel.cvut.cz>
Wed, 13 Apr 2011 15:54:37 +0000 (17:54 +0200)
It is just a copy-paste, thus requires the actual refactoring in order
to test the deadline API.

src/test_edf/Makefile [new file with mode: 0644]
src/test_edf/Makefile.omk [new file with mode: 0644]
src/test_edf/init.c [new file with mode: 0644]
src/test_edf/system.h [new file with mode: 0644]
src/test_edf/task.c [new file with mode: 0644]

diff --git a/src/test_edf/Makefile b/src/test_edf/Makefile
new file mode 100644 (file)
index 0000000..76b56fd
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or parent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/src/test_edf/Makefile.omk b/src/test_edf/Makefile.omk
new file mode 100644 (file)
index 0000000..5eee69d
--- /dev/null
@@ -0,0 +1,17 @@
+default_CONFIG += CONFIG_OC_BUILD4RTEMS=y
+default_CONFIG += CONFIG_OC_GDBSTUB=n
+
+bin_PROGRAMS = test_edf
+
+#lib_LIBRARIES = 
+
+#include_HEADERS = 
+
+test_edf_SOURCES += init.c task.c
+
+#test_edf_EMBEDTARFILES = rootfs
+
+lib_LOADLIBES += bar
+
+test_edf_LIBS = edf
+
diff --git a/src/test_edf/init.c b/src/test_edf/init.c
new file mode 100644 (file)
index 0000000..f117781
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * The EDF scheduler functionality test
+ *
+ *
+ *  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.   
+ *  
+ *  Input parameters:
+ *    argument - task argument
+ *
+ *  Output parameters:  NONE
+ *
+ */
+
+#define TEST_INIT
+#include "system.h"
+#define CONFIGURE_MICROSECONDS_PER_TICK RTEMS_MILLISECONDS_TO_MICROSECONDS(10)
+
+rtems_task Init(
+  rtems_task_argument argument
+)
+{
+  rtems_time_of_day time;
+  rtems_status_code status;
+
+  puts( "\n\n*** TEST ***" );
+
+  Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
+  Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
+
+  status = rtems_task_create(
+     Task_name[ 1 ],
+     9,
+     RTEMS_MINIMUM_STACK_SIZE * 4,
+     RTEMS_DEFAULT_MODES,
+     RTEMS_DEFAULT_ATTRIBUTES,
+     &Task_id[ 1 ]
+  );
+  directive_failed( status, "rtems_task_create of TA1" );
+
+  status = rtems_task_create(
+     Task_name[ 2 ],
+     11,
+     RTEMS_MINIMUM_STACK_SIZE * 4,
+     RTEMS_DEFAULT_MODES,
+     RTEMS_DEFAULT_ATTRIBUTES,
+     &Task_id[ 2 ]
+  );
+  directive_failed( status, "rtems_task_create of TA2" );
+
+  status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
+  directive_failed( status, "rtems_task_start of TA1" );
+
+  status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
+  directive_failed( status, "rtems_task_start of TA2" );
+
+  status = rtems_task_delete( RTEMS_SELF );
+  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
diff --git a/src/test_edf/system.h b/src/test_edf/system.h
new file mode 100644 (file)
index 0000000..1816172
--- /dev/null
@@ -0,0 +1,46 @@
+/*  system.h
+ *
+ *  This include file contains information that is included in every
+ *  function in the test set.
+ *
+ */
+
+#include <tmacros.h>
+
+/* functions */
+
+rtems_task Init(
+  rtems_task_argument argument
+);
+
+rtems_task Task_1(
+  rtems_task_argument argument
+);
+
+rtems_task Task_2(
+  rtems_task_argument argument
+);
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#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 * 3 * RTEMS_MINIMUM_STACK_SIZE)
+
+#include <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 */
+
+/* end of include file */
diff --git a/src/test_edf/task.c b/src/test_edf/task.c
new file mode 100644 (file)
index 0000000..7152ca4
--- /dev/null
@@ -0,0 +1,120 @@
+#include "system.h"
+
+rtems_task Task_1(
+  rtems_task_argument argument
+)
+{
+  rtems_name name;
+  rtems_id period;
+  rtems_status_code status;
+  char output1[50];
+  char output2[50];
+  unsigned32 start, stop, period_length, max_i, max_j;
+  unsigned32 i,j,k,l;
+  
+  name = rtems_build_name( 'P', 'E', 'R', 'A' );
+  status = rtems_rate_monotonic_create( name, &period );
+  if ( status != RTEMS_SUCCESSFUL ) {
+        printf( "rtems_monotonic_create failed with status of %d.\n", status);
+           exit( 1 );
+  }
+  
+  period_length = 7;
+  max_i = 10000; max_j = 4000;
+  while ( 1 ) {
+         if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
+                    puts("P1 - Deadline miss");
+
+         rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
+         sprintf(output1,"P1-S  ticks:%d",start);
+         puts(output1);
+         
+         if ( start >= 30 ) break;
+          
+         /* active computing */ 
+         for ( i = 1 ; i < max_i; i++) 
+         { 
+                 j =  i/12 ; j++;
+                 for ( j = 1; j < max_j; j++) 
+                 {
+                         k = j/ 3; 
+                         k++;                    
+                }
+         }
+        
+         rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
+         sprintf(output2,"P1-F  ticks:%d",stop);
+         puts(output2);
+  }
+  
+  /* missed period so delete period and SELF */
+  status = rtems_rate_monotonic_delete( period );
+  if ( status != RTEMS_SUCCESSFUL ) {
+         printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
+         rtems_test_exit( 0 );
+  }
+  
+  puts( "*** END OF TEST - edf***" );
+  rtems_test_exit( 0 );
+}
+
+rtems_task Task_2(
+  rtems_task_argument argument
+)
+{
+  rtems_name name;
+  rtems_id period;
+  rtems_status_code status;
+  char output1[50];
+  char output2[50];
+  unsigned32 start, stop, period_length, max_i, max_j;
+  unsigned32 i,j,k,l;
+         
+  name = rtems_build_name( 'P', 'E', 'R', 'B' );
+  status = rtems_rate_monotonic_create( name, &period );
+  if ( status != RTEMS_SUCCESSFUL ) {
+        printf( "rtems_monotonic_create failed with status of %d.\n", status );
+           exit( 1 );
+  }
+  
+  period_length = 10;
+  max_i = 10000; max_j = 6000;
+  while ( 1 ) {
+         if (rtems_rate_monotonic_period(period,period_length)==RTEMS_TIMEOUT)
+                 puts("P2 - Deadline miss");
+        
+         rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start);
+         sprintf(output1,"P2-S  ticks:%d",start);
+         puts(output1);
+         
+         if ( _Watchdog_Ticks_since_boot >= 30 ) {
+                 break;
+         }
+  
+         /* active computing */
+         
+         for ( i = 1 ; i < max_i; i++) 
+         { 
+                 j =  i/12 ; j++;
+                 for ( j = 1; j < max_j; j++) 
+                 {
+                         k = j/ 3; 
+                         k++;                    
+                }
+         }
+         
+         rtems_clock_get(RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &stop);
+         sprintf(output2,"P2-F  ticks:%d",stop);
+         puts(output2); 
+  }
+
+  /* missed period so delete period and SELF */
+  status = rtems_rate_monotonic_delete( period );
+  if ( status != RTEMS_SUCCESSFUL ) {
+         printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
+         rtems_test_exit( 0 );
+  }
+  
+  puts( "*** END OF TEST - edf***" );
+  rtems_test_exit( 0 );
+}