summaryrefslogtreecommitdiffstats
path: root/c/src/tests/itrontests/itrontask03
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-09 23:27:05 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-09 23:27:05 +0000
commite0991809991a2c5547d45881978212d5efc0e1de (patch)
tree3f88b84781cec14fee64157792b9f6adf8abf758 /c/src/tests/itrontests/itrontask03
parentAdded nesting count for suspend/resume. (diff)
downloadrtems-e0991809991a2c5547d45881978212d5efc0e1de.tar.bz2
Merged tests from Task group.
Diffstat (limited to 'c/src/tests/itrontests/itrontask03')
-rw-r--r--c/src/tests/itrontests/itrontask03/Makefile.in74
-rw-r--r--c/src/tests/itrontests/itrontask03/init.c94
-rw-r--r--c/src/tests/itrontests/itrontask03/itrontask03.doc40
-rw-r--r--c/src/tests/itrontests/itrontask03/itrontask03.scn13
-rw-r--r--c/src/tests/itrontests/itrontask03/preempt.c31
-rw-r--r--c/src/tests/itrontests/itrontask03/spinit.c152
-rw-r--r--c/src/tests/itrontests/itrontask03/system.h44
-rw-r--r--c/src/tests/itrontests/itrontask03/task1.c59
-rw-r--r--c/src/tests/itrontests/itrontask03/task2.c32
-rw-r--r--c/src/tests/itrontests/itrontask03/task3.c40
10 files changed, 579 insertions, 0 deletions
diff --git a/c/src/tests/itrontests/itrontask03/Makefile.in b/c/src/tests/itrontests/itrontask03/Makefile.in
new file mode 100644
index 0000000000..0435f04407
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/Makefile.in
@@ -0,0 +1,74 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = ..
+subdir = itrontask03
+
+RTEMS_ROOT = @RTEMS_ROOT@
+PROJECT_ROOT = @PROJECT_ROOT@
+
+VPATH = @srcdir@
+
+TEST = itrontask03
+PGM = ${ARCH}/$(TEST).exe
+
+MANAGERS = all
+
+# C source names, if any, go here -- minus the .c
+C_PIECES = init preempt spinit task1 task2 task3
+C_FILES = $(C_PIECES:%=%.c)
+C_O_FILES = $(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES = system.h
+
+DOCTYPES = doc scn
+DOCS = $(DOCTYPES:%=$(TEST).%)
+
+SRCS = $(DOCS) $(C_FILES) $(H_FILES)
+OBJS = $(C_O_FILES)
+
+PRINT_SRCS = $(DOCS)
+
+PGM = ${ARCH}/$(TEST).exe
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(RTEMS_ROOT)/make/leaf.cfg
+
+INSTALL_CHANGE = @INSTALL_CHANGE@
+PACKHEX = @PACKHEX@
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS +=
+LDFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(PGM)
+ @$(INSTALL_VARIANT) -m 755 ${PGM} $(PROJECT_RELEASE)/tests
+
+${PGM}: $(OBJS) $(LINK_FILES)
+ $(make-exe)
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
diff --git a/c/src/tests/itrontests/itrontask03/init.c b/c/src/tests/itrontests/itrontask03/init.c
new file mode 100644
index 0000000000..cc94d6d2f7
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/init.c
@@ -0,0 +1,94 @@
+ /* Init
+ *
+ * This routine is the initialization task for this test program.
+ * It is called from init_exec 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: NONE
+ *
+ * Output parameters: NONE
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#define TEST_INIT
+#include "system.h"
+#include <stdio.h>
+
+void ITRON_Init( void )
+{
+ ER status;
+ T_CTSK pk_ctsk;
+
+ puts( "\n\n*** ITRON TEST 5 ***" );
+
+ pk_ctsk.exinf = NULL;
+ pk_ctsk.tskatr = TA_HLNG;
+ pk_ctsk.stksz = RTEMS_MINIMUM_STACK_SIZE;
+
+ pk_ctsk.itskpri = 1;
+ pk_ctsk.task = Preempt_task;
+ status = cre_tsk( PREEMPT_TASK_ID, &pk_ctsk );
+ directive_failed( status, "cre_tsk of RTEMS_PREEMPT" );
+ status = sta_tsk( PREEMPT_TASK_ID, 0 );
+ directive_failed( status, "sta_tsk of RTEMS_PREEMPT" );
+
+ puts( "INIT - rot_rdq - yielding processor" );
+ status = rot_rdq( 1 );
+ directive_failed( status, "rot_rdq" );
+
+ pk_ctsk.itskpri = 3;
+ pk_ctsk.task = Task_1;
+ status = cre_tsk( TA1_ID, &pk_ctsk );
+ directive_failed( status, "cre_tsk of TA1" );
+
+ pk_ctsk.task = Task_2;
+ status = cre_tsk( TA2_ID, &pk_ctsk );
+ directive_failed( status, "cre_tsk of TA2" );
+
+ pk_ctsk.task = Task_3;
+ status = cre_tsk( TA3_ID, &pk_ctsk );
+ directive_failed( status, "cre_tsk of TA3" );
+
+ status = sta_tsk( TA1_ID, 0 );
+ directive_failed( status, "sta_tsk of TA1" );
+ status = sta_tsk( TA2_ID, 0 );
+ directive_failed( status, "sta_tsk of TA2" );
+ status = sta_tsk( TA3_ID, 0 );
+ directive_failed( status, "sta_tsk of TA3" );
+
+ puts( "INIT - suspending TA2 while middle task on a ready chain" );
+ status = sus_tsk( TA2_ID );
+ directive_failed( status, "sus_tsk of TA2" );
+
+ status = ter_tsk( TA1_ID );
+ directive_failed( status, "ter_tsk of TA1" );
+ status = del_tsk( TA1_ID );
+ directive_failed( status, "del_tsk of TA1" );
+ status = ter_tsk( TA2_ID );
+ directive_failed( status, "ter_tsk of TA2" );
+ status = ter_tsk( TA3_ID );
+ directive_failed( status, "ter_tsk of TA3" );
+
+ pk_ctsk.itskpri = 1;
+ pk_ctsk.task = Task_1;
+ status = cre_tsk( TA1_ID, &pk_ctsk );
+ directive_failed( status, "cre_tsk of TA1 at priority 1" );
+
+ status = sta_tsk( TA1_ID, 0 );
+ directive_failed( status, "sta_tsk of TA1" );
+ status = sta_tsk( TA2_ID, 0 );
+ directive_failed( status, "sta_tsk of TA2" );
+ status = sta_tsk( TA3_ID, 0 );
+ directive_failed( status, "sta_tsk of TA3" );
+
+ exd_tsk();
+ directive_failed( 0, "exd_tsk" );
+}
+
diff --git a/c/src/tests/itrontests/itrontask03/itrontask03.doc b/c/src/tests/itrontests/itrontask03/itrontask03.doc
new file mode 100644
index 0000000000..12d12f0940
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/itrontask03.doc
@@ -0,0 +1,40 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-1998.
+# On-Line Applications Research Corporation (OAR).
+# Copyright assigned to U.S. Government, 1994.
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.OARcorp.com/rtems/license.html.
+#
+
+
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: test2
+
+directives:
+ ext_tsk, cre_tsk, sta_tsk, rot_rdq
+
+ ex_start, t_create, t_start, tm_tick, i_return, t_ident,
+ t_delete, tm_wkafter, t_setpri, t_suspend
+
+concepts:
+
+ a. Verifies that a task can delete another task and also delete itself.
+
+ b. Verifies that memory is freed back to the heap correctly.
+
+ c. Verifies that TCBs are freed back to the inactive chain correctly.
+
+ d. Verifies that a task can get the task identification number of
+ another task.
+
+ e. Verifies the _Set_state routine where the task is not READY.
+
+ f. Verifies the break statement in the _Block_activate routine.
+
+ g. Verifies the while loop in the _Prev_tcb routine.
diff --git a/c/src/tests/itrontests/itrontask03/itrontask03.scn b/c/src/tests/itrontests/itrontask03/itrontask03.scn
new file mode 100644
index 0000000000..1ee0401494
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/itrontask03.scn
@@ -0,0 +1,13 @@
+*** ITRON TEST 5 ***
+INIT - rot_rdq - yielding processor
+PREEMPT - exd_tsk
+INIT - suspending TA2 while middle task on a ready chain
+TA1 - rtems_task_wake_after - sleep 1 second
+TA2 - rtems_task_wake_after - sleep 1 minute
+TA3 - rtems_task_wake_after - sleep 5 seconds
+TA1 - chg_pri - set TA3's priority to 2
+TA1 - rtems_task_suspend - suspend TA2
+TA1 - - delete TA2
+TA1 - rtems_task_wake_after - sleep for 5 seconds
+TA3 - exd_tsk - exit and delete self
+*** END OF TEST 5 ***
diff --git a/c/src/tests/itrontests/itrontask03/preempt.c b/c/src/tests/itrontests/itrontask03/preempt.c
new file mode 100644
index 0000000000..6f8f89f0c2
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/preempt.c
@@ -0,0 +1,31 @@
+/* Preempt_task
+ *
+ * This routine serves as a test task. It verifies the task manager.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <assert.h>
+#include "system.h"
+
+void Preempt_task()
+{
+ ER status;
+
+ puts( "PREEMPT - exd_tsk" );
+ exd_tsk( );
+ assert( 0 );
+}
diff --git a/c/src/tests/itrontests/itrontask03/spinit.c b/c/src/tests/itrontests/itrontask03/spinit.c
new file mode 100644
index 0000000000..dda2f9661c
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/spinit.c
@@ -0,0 +1,152 @@
+/* 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-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#define TEST_INIT
+#include "system.h"
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+
+ puts( "\n\n*** TEST 2 ***" );
+
+ Preempt_task_name = rtems_build_name( 'P', 'R', 'M', 'T' );
+
+ status = rtems_task_create(
+ Preempt_task_name,
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Preempt_task_id
+ );
+ directive_failed( status, "rtems_task_create of RTEMS_PREEMPT" );
+
+ status = rtems_task_start( Preempt_task_id, Preempt_task, 0 );
+ directive_failed( status, "rtems_task_start of RTEMS_PREEMPT" );
+
+ puts( "INIT - rtems_task_wake_after - yielding processor" );
+ status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ 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', ' ' );
+
+ status = rtems_task_create(
+ Task_name[ 1 ],
+ 3,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ 1 ]
+ );
+ directive_failed( status, "rtems_task_create of TA1" );
+
+ status = rtems_task_create(
+ Task_name[ 2 ],
+ 3,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ 2 ]
+ );
+ directive_failed( status, "rtems_task_create of TA2" );
+
+ status = rtems_task_create(
+ Task_name[ 3 ],
+ 3,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ 3 ]
+ );
+ directive_failed( status, "rtems_task_create of TA3" );
+
+ 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_start( Task_id[ 3 ], Task_3, 0 );
+ directive_failed( status, "rtems_task_start of TA3" );
+
+ puts( "INIT - suspending TA2 while middle task on a ready chain" );
+ status = rtems_task_suspend( Task_id[ 2 ] );
+ directive_failed( status, "rtems_task_suspend of TA2" );
+
+ status = rtems_task_delete( Task_id[ 1 ] );
+ directive_failed( status, "rtems_task_delete of TA1" );
+
+ status = rtems_task_delete( Task_id[ 2 ] );
+ directive_failed( status, "rtems_task_delete of TA2" );
+
+ status = rtems_task_delete( Task_id[ 3 ] );
+ directive_failed( status, "rtems_task_delete of TA3" );
+
+ status = rtems_task_create(
+ Task_name[ 1 ],
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ 1 ]
+ );
+ directive_failed( status, "rtems_task_create of TA1" );
+
+ status = rtems_task_create(
+ Task_name[ 2 ],
+ 3,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ 2 ]
+ );
+ directive_failed( status, "rtems_task_create of TA2" );
+
+ status = rtems_task_create(
+ Task_name[ 3 ],
+ 3,
+ RTEMS_MINIMUM_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Task_id[ 3 ]
+ );
+ directive_failed( status, "rtems_task_create of TA3" );
+
+ 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_start( Task_id[ 3 ], Task_3, 0 );
+ directive_failed( status, "rtems_task_start of TA3" );
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
diff --git a/c/src/tests/itrontests/itrontask03/system.h b/c/src/tests/itrontests/itrontask03/system.h
new file mode 100644
index 0000000000..51af0eaca6
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/system.h
@@ -0,0 +1,44 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <tmacros.h>
+
+/* functions */
+
+void ITRON_Init( void );
+void Preempt_task();
+void Task_1();
+void Task_2();
+void Task_3();
+
+/* configuration information */
+
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_ITRON_INIT_TASK_TABLE
+
+#include <confdefs.h>
+
+/* global variables */
+
+#define PREEMPT_TASK_ID 2
+#define TA1_ID 3
+#define TA2_ID 4
+#define TA3_ID 5
+
+TEST_EXTERN rtems_id Global_variable; /* example global variable */
+
+/* end of include file */
diff --git a/c/src/tests/itrontests/itrontask03/task1.c b/c/src/tests/itrontests/itrontask03/task1.c
new file mode 100644
index 0000000000..30a6078956
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/task1.c
@@ -0,0 +1,59 @@
+/* Task_1
+ *
+ * This routine serves as a test task. It verifies the task manager.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+
+void Task_1()
+{
+ ER status;
+ PRI previous_priority;
+
+ /*
+ * XXX - Change to itron routine.
+ */
+
+ puts( "TA1 - rtems_task_wake_after - sleep 1 second" );
+ status = rtems_task_wake_after( 1*TICKS_PER_SECOND );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ status = chg_pri( TA3_ID , 2 );
+ directive_failed( status, "chg_pri" );
+
+ puts( "TA1 - chg_pri - set TA3's priority to 2" );
+
+ puts( "TA1 - rtems_task_suspend - suspend TA2" );
+ status = sus_tsk( TA2_ID );
+ directive_failed( status, "sus_tsk of TA2" );
+
+ puts( "TA1 - - delete TA2" );
+ status = ter_tsk( TA2_ID );
+ directive_failed( status, "ter_tsk of TA2" );
+
+ /*
+ * XXX - Change to itron routine.
+ */
+
+ puts( "TA1 - rtems_task_wake_after - sleep for 5 seconds" );
+ status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
+ directive_failed( status, "rtems_task_wake_after" );
+
+ puts( "*** END OF TEST 5 ***" );
+ exit( 0 );
+}
diff --git a/c/src/tests/itrontests/itrontask03/task2.c b/c/src/tests/itrontests/itrontask03/task2.c
new file mode 100644
index 0000000000..3040b0176f
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/task2.c
@@ -0,0 +1,32 @@
+/* Task_2
+ *
+ * This routine serves as a test task. It sleeps for 1 minute but
+ * does not expect to wake up. Task 1 should suspend then delete it
+ * so that it appears to never wake up.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+
+void Task_2()
+{
+ rtems_status_code status;
+
+ puts( "TA2 - rtems_task_wake_after - sleep 1 minute" );
+ status = rtems_task_wake_after( 60*TICKS_PER_SECOND );
+ directive_failed( status, "rtems_task_wake_after in TA2" );
+}
diff --git a/c/src/tests/itrontests/itrontask03/task3.c b/c/src/tests/itrontests/itrontask03/task3.c
new file mode 100644
index 0000000000..38b9ff97c0
--- /dev/null
+++ b/c/src/tests/itrontests/itrontask03/task3.c
@@ -0,0 +1,40 @@
+/* Task_3
+ *
+ * This routine serves as a test task. It simply sleeps for 5 seconds
+ * and then deletes itself.
+ *
+ * Input parameters:
+ * argument - task argument
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include "system.h"
+
+void Task_3()
+{
+ rtems_status_code status;
+
+ /*
+ * XXX - Convert Later.
+ */
+
+ puts( "TA3 - rtems_task_wake_after - sleep 5 seconds" );
+ status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
+ directive_failed( status, "rtems_task_wake_after in TA3" );
+
+
+ puts( "TA3 - exd_tsk - exit and delete self" );
+ exd_tsk();
+ directive_failed( 0, "exd_tsk" );
+}