From 1232196a7b2351c6f36a537626f459939df775b9 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 25 Oct 1999 14:14:07 +0000 Subject: Added sp26 which tests the rtems_task_is_suspended directive. --- c/src/tests/sptests/Makefile.am | 2 +- c/src/tests/sptests/configure.in | 1 + c/src/tests/sptests/sp26/Makefile.in | 81 ++++++++++++++++++++++++ c/src/tests/sptests/sp26/init.c | 41 ++++++++++++ c/src/tests/sptests/sp26/sp26.doc | 24 +++++++ c/src/tests/sptests/sp26/sp26.scn | 8 +++ c/src/tests/sptests/sp26/system.h | 57 +++++++++++++++++ c/src/tests/sptests/sp26/task1.c | 119 +++++++++++++++++++++++++++++++++++ testsuites/sptests/Makefile.am | 2 +- testsuites/sptests/sp26/init.c | 41 ++++++++++++ testsuites/sptests/sp26/sp26.doc | 24 +++++++ testsuites/sptests/sp26/sp26.scn | 8 +++ testsuites/sptests/sp26/system.h | 57 +++++++++++++++++ testsuites/sptests/sp26/task1.c | 119 +++++++++++++++++++++++++++++++++++ 14 files changed, 582 insertions(+), 2 deletions(-) create mode 100644 c/src/tests/sptests/sp26/Makefile.in create mode 100644 c/src/tests/sptests/sp26/init.c create mode 100644 c/src/tests/sptests/sp26/sp26.doc create mode 100644 c/src/tests/sptests/sp26/sp26.scn create mode 100644 c/src/tests/sptests/sp26/system.h create mode 100644 c/src/tests/sptests/sp26/task1.c create mode 100644 testsuites/sptests/sp26/init.c create mode 100644 testsuites/sptests/sp26/sp26.doc create mode 100644 testsuites/sptests/sp26/sp26.scn create mode 100644 testsuites/sptests/sp26/system.h create mode 100644 testsuites/sptests/sp26/task1.c diff --git a/c/src/tests/sptests/Makefile.am b/c/src/tests/sptests/Makefile.am index 00553330ba..aaf59aba19 100644 --- a/c/src/tests/sptests/Makefile.am +++ b/c/src/tests/sptests/Makefile.am @@ -15,7 +15,7 @@ all-local: $(PREINSTALLDIRS) ## sp10 and spfatal are not included for now SUBDIRS = . sp01 sp02 sp03 sp04 sp05 sp06 sp07 sp08 sp09 sp11 sp12 sp13 sp14 \ - sp15 sp16 sp17 sp19 sp20 sp21 sp22 sp23 sp24 sp25 spsize + sp15 sp16 sp17 sp19 sp20 sp21 sp22 sp23 sp24 sp25 sp26 spsize include $(top_srcdir)/../../../../automake/subdirs.am include $(top_srcdir)/../../../../automake/local.am diff --git a/c/src/tests/sptests/configure.in b/c/src/tests/sptests/configure.in index 40554df7b9..d3f2d48f7f 100644 --- a/c/src/tests/sptests/configure.in +++ b/c/src/tests/sptests/configure.in @@ -63,6 +63,7 @@ sp22/Makefile sp23/Makefile sp24/Makefile sp25/Makefile +sp26/Makefile spsize/Makefile ) diff --git a/c/src/tests/sptests/sp26/Makefile.in b/c/src/tests/sptests/sp26/Makefile.in new file mode 100644 index 0000000000..25a2712b56 --- /dev/null +++ b/c/src/tests/sptests/sp26/Makefile.in @@ -0,0 +1,81 @@ +# +# $Id$ +# + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = .. +subdir = sp26 + +RTEMS_ROOT = @RTEMS_ROOT@ +PROJECT_ROOT = @PROJECT_ROOT@ + +VPATH = @srcdir@ + +TEST = sp26 + +MANAGERS = io region event + +# C source names, if any, go here -- minus the .c +C_PIECES = init task1 +C_FILES = $(C_PIECES:%=%.c) +C_O_FILES = $(C_PIECES:%=${ARCH}/%.o) + +H_FILES = system.h + +DOCTYPES = scn doc +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@ +mkinstalldirs = $(SHELL) $(top_srcdir)/@RTEMS_TOPdir@/mkinstalldirs + +INSTALLDIRS = $(PROJECT_RELEASE)/tests/screens/sptests + +$(INSTALLDIRS): + @$(mkinstalldirs) $(INSTALLDIRS) + +# +# (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 + $(INSTALL_CHANGE) $(srcdir)/$(TEST).scn \ + $(PROJECT_RELEASE)/tests/screens/sptests/$(TEST).scn + +${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/sptests/sp26/init.c b/c/src/tests/sptests/sp26/init.c new file mode 100644 index 0000000000..79cd91566f --- /dev/null +++ b/c/src/tests/sptests/sp26/init.c @@ -0,0 +1,41 @@ +/* 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 26 ***" ); + + task1(); + /* does not return */ + puts( "Init - task1 should not have returned" ); + exit( 0 ); +} diff --git a/c/src/tests/sptests/sp26/sp26.doc b/c/src/tests/sptests/sp26/sp26.doc new file mode 100644 index 0000000000..d0ed98c029 --- /dev/null +++ b/c/src/tests/sptests/sp26/sp26.doc @@ -0,0 +1,24 @@ +# +# $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: sp26 + +directives: + task_is_suspended + +concepts: + + a. task_is_suspended operates correctly. + diff --git a/c/src/tests/sptests/sp26/sp26.scn b/c/src/tests/sptests/sp26/sp26.scn new file mode 100644 index 0000000000..0e3faf5cd7 --- /dev/null +++ b/c/src/tests/sptests/sp26/sp26.scn @@ -0,0 +1,8 @@ +*** TEST 26 *** +subTask2 - Task 1 suspended? - should be 0: 0 +subTask1 - Event sent +subTask2 - Task 1 suspended? - should be 1: 1 +subTask2 - Task 1 suspended? - should be 0: 0 +subTask1 - Back to task 1 +subTask2 - Task 1 suspended? - should be 1: 1 +*** END OF TEST 26 *** diff --git a/c/src/tests/sptests/sp26/system.h b/c/src/tests/sptests/sp26/system.h new file mode 100644 index 0000000000..3435288228 --- /dev/null +++ b/c/src/tests/sptests/sp26/system.h @@ -0,0 +1,57 @@ +/* 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 + +/* functions */ + +rtems_task Init( + rtems_task_argument argument +); + +rtems_task Task_1( + rtems_task_argument argument +); + +/* configuration information */ + +#define CONFIGURE_SPTEST + +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_REGIONS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#include + +/* global variables */ + +TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */ +TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */ +TEST_EXTERN rtems_id Region_id[ 2 ]; /* array of region ids */ +TEST_EXTERN rtems_name Region_name[ 2 ]; /* array of region names */ + +TEST_EXTERN rtems_unsigned8 Area_1[64000] CPU_STRUCTURE_ALIGNMENT; + +#define BASE_PRIORITY 140 + +#define Put_address_from_area_1( _to_be_printed ) \ + printf( "0x%08lx", \ + (unsigned long) ((rtems_unsigned8 *)(_to_be_printed) - Area_1 ) ) + +/* end of include file */ diff --git a/c/src/tests/sptests/sp26/task1.c b/c/src/tests/sptests/sp26/task1.c new file mode 100644 index 0000000000..8957c293d2 --- /dev/null +++ b/c/src/tests/sptests/sp26/task1.c @@ -0,0 +1,119 @@ +/* + * 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 +#include +#include + +static rtems_id taskId1; +static rtems_id taskId2; +rtems_interval ticksPerSecond; + +static int +isSuspended (rtems_id tid) +{ + rtems_status_code sc; + + sc = rtems_task_is_suspended (tid); + if (sc == RTEMS_ALREADY_SUSPENDED) + return 1; + if (sc != RTEMS_SUCCESSFUL) + printf ("rtems_task_is_suspended: %s\n", rtems_status_text (sc)); + return 0; +} + +static void +subTask1 (rtems_task_argument arg) +{ + rtems_status_code sc; + + rtems_task_wake_after (ticksPerSecond * 3); + sc = rtems_event_send (taskId2, 1); + if (sc != RTEMS_SUCCESSFUL) { + printf ("subTask1 - Can't send event (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } + rtems_task_wake_after (ticksPerSecond * 3); + printf ("subTask1 - Event sent\n"); + rtems_task_suspend (RTEMS_SELF); + printf ("subTask1 - Back to task 1\n"); + rtems_task_wake_after (ticksPerSecond * 3); + rtems_task_suspend (RTEMS_SELF); +} + +static void +subTask2 (rtems_task_argument arg) +{ + rtems_status_code sc; + rtems_event_set ev; + + rtems_task_wake_after (ticksPerSecond * 1); + sc = rtems_event_receive (1, RTEMS_WAIT|RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &ev); + if (sc != RTEMS_SUCCESSFUL) { + printf ("subTask2 - Can't receive event (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } + printf ("subTask2 - Task 1 suspended? - should be 0: %d\n", + isSuspended (taskId1)); + rtems_task_wake_after (ticksPerSecond * 4); + printf ("subTask2 - Task 1 suspended? - should be 1: %d\n", + isSuspended (taskId1)); + rtems_task_resume (taskId1); + printf ("subTask2 - Task 1 suspended? - should be 0: %d\n", + isSuspended (taskId1)); + rtems_task_wake_after (ticksPerSecond * 4); + printf ("subTask2 - Task 1 suspended? - should be 1: %d\n", + isSuspended (taskId1)); + + puts( "*** END OF TEST 26 ***" ); + exit( 0 ); +} + +static void +createTask (char c, rtems_id *tid) +{ + rtems_status_code sc; + + sc = rtems_task_create (rtems_build_name('S','u','b',c), + 100, + RTEMS_MINIMUM_STACK_SIZE * 4, + RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0), + RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL, + tid); + if (sc != RTEMS_SUCCESSFUL) { + printf ("Can't create task (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } +} + +static void +startTask (rtems_id tid, rtems_task_entry entry_point) +{ + rtems_status_code sc; + + sc = rtems_task_start (tid, entry_point, 0); + if (sc != RTEMS_SUCCESSFUL) { + printf ("Can't start task (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } +} + +void +task1 (void) +{ + rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond); + createTask ('1', &taskId1); + createTask ('2', &taskId2); + startTask (taskId1, subTask1); + startTask (taskId2, subTask2); + rtems_task_suspend (RTEMS_SELF); +} diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 00553330ba..aaf59aba19 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -15,7 +15,7 @@ all-local: $(PREINSTALLDIRS) ## sp10 and spfatal are not included for now SUBDIRS = . sp01 sp02 sp03 sp04 sp05 sp06 sp07 sp08 sp09 sp11 sp12 sp13 sp14 \ - sp15 sp16 sp17 sp19 sp20 sp21 sp22 sp23 sp24 sp25 spsize + sp15 sp16 sp17 sp19 sp20 sp21 sp22 sp23 sp24 sp25 sp26 spsize include $(top_srcdir)/../../../../automake/subdirs.am include $(top_srcdir)/../../../../automake/local.am diff --git a/testsuites/sptests/sp26/init.c b/testsuites/sptests/sp26/init.c new file mode 100644 index 0000000000..79cd91566f --- /dev/null +++ b/testsuites/sptests/sp26/init.c @@ -0,0 +1,41 @@ +/* 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 26 ***" ); + + task1(); + /* does not return */ + puts( "Init - task1 should not have returned" ); + exit( 0 ); +} diff --git a/testsuites/sptests/sp26/sp26.doc b/testsuites/sptests/sp26/sp26.doc new file mode 100644 index 0000000000..d0ed98c029 --- /dev/null +++ b/testsuites/sptests/sp26/sp26.doc @@ -0,0 +1,24 @@ +# +# $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: sp26 + +directives: + task_is_suspended + +concepts: + + a. task_is_suspended operates correctly. + diff --git a/testsuites/sptests/sp26/sp26.scn b/testsuites/sptests/sp26/sp26.scn new file mode 100644 index 0000000000..0e3faf5cd7 --- /dev/null +++ b/testsuites/sptests/sp26/sp26.scn @@ -0,0 +1,8 @@ +*** TEST 26 *** +subTask2 - Task 1 suspended? - should be 0: 0 +subTask1 - Event sent +subTask2 - Task 1 suspended? - should be 1: 1 +subTask2 - Task 1 suspended? - should be 0: 0 +subTask1 - Back to task 1 +subTask2 - Task 1 suspended? - should be 1: 1 +*** END OF TEST 26 *** diff --git a/testsuites/sptests/sp26/system.h b/testsuites/sptests/sp26/system.h new file mode 100644 index 0000000000..3435288228 --- /dev/null +++ b/testsuites/sptests/sp26/system.h @@ -0,0 +1,57 @@ +/* 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 + +/* functions */ + +rtems_task Init( + rtems_task_argument argument +); + +rtems_task Task_1( + rtems_task_argument argument +); + +/* configuration information */ + +#define CONFIGURE_SPTEST + +#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_REGIONS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#include + +/* global variables */ + +TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */ +TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */ +TEST_EXTERN rtems_id Region_id[ 2 ]; /* array of region ids */ +TEST_EXTERN rtems_name Region_name[ 2 ]; /* array of region names */ + +TEST_EXTERN rtems_unsigned8 Area_1[64000] CPU_STRUCTURE_ALIGNMENT; + +#define BASE_PRIORITY 140 + +#define Put_address_from_area_1( _to_be_printed ) \ + printf( "0x%08lx", \ + (unsigned long) ((rtems_unsigned8 *)(_to_be_printed) - Area_1 ) ) + +/* end of include file */ diff --git a/testsuites/sptests/sp26/task1.c b/testsuites/sptests/sp26/task1.c new file mode 100644 index 0000000000..8957c293d2 --- /dev/null +++ b/testsuites/sptests/sp26/task1.c @@ -0,0 +1,119 @@ +/* + * 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 +#include +#include + +static rtems_id taskId1; +static rtems_id taskId2; +rtems_interval ticksPerSecond; + +static int +isSuspended (rtems_id tid) +{ + rtems_status_code sc; + + sc = rtems_task_is_suspended (tid); + if (sc == RTEMS_ALREADY_SUSPENDED) + return 1; + if (sc != RTEMS_SUCCESSFUL) + printf ("rtems_task_is_suspended: %s\n", rtems_status_text (sc)); + return 0; +} + +static void +subTask1 (rtems_task_argument arg) +{ + rtems_status_code sc; + + rtems_task_wake_after (ticksPerSecond * 3); + sc = rtems_event_send (taskId2, 1); + if (sc != RTEMS_SUCCESSFUL) { + printf ("subTask1 - Can't send event (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } + rtems_task_wake_after (ticksPerSecond * 3); + printf ("subTask1 - Event sent\n"); + rtems_task_suspend (RTEMS_SELF); + printf ("subTask1 - Back to task 1\n"); + rtems_task_wake_after (ticksPerSecond * 3); + rtems_task_suspend (RTEMS_SELF); +} + +static void +subTask2 (rtems_task_argument arg) +{ + rtems_status_code sc; + rtems_event_set ev; + + rtems_task_wake_after (ticksPerSecond * 1); + sc = rtems_event_receive (1, RTEMS_WAIT|RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &ev); + if (sc != RTEMS_SUCCESSFUL) { + printf ("subTask2 - Can't receive event (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } + printf ("subTask2 - Task 1 suspended? - should be 0: %d\n", + isSuspended (taskId1)); + rtems_task_wake_after (ticksPerSecond * 4); + printf ("subTask2 - Task 1 suspended? - should be 1: %d\n", + isSuspended (taskId1)); + rtems_task_resume (taskId1); + printf ("subTask2 - Task 1 suspended? - should be 0: %d\n", + isSuspended (taskId1)); + rtems_task_wake_after (ticksPerSecond * 4); + printf ("subTask2 - Task 1 suspended? - should be 1: %d\n", + isSuspended (taskId1)); + + puts( "*** END OF TEST 26 ***" ); + exit( 0 ); +} + +static void +createTask (char c, rtems_id *tid) +{ + rtems_status_code sc; + + sc = rtems_task_create (rtems_build_name('S','u','b',c), + 100, + RTEMS_MINIMUM_STACK_SIZE * 4, + RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0), + RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL, + tid); + if (sc != RTEMS_SUCCESSFUL) { + printf ("Can't create task (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } +} + +static void +startTask (rtems_id tid, rtems_task_entry entry_point) +{ + rtems_status_code sc; + + sc = rtems_task_start (tid, entry_point, 0); + if (sc != RTEMS_SUCCESSFUL) { + printf ("Can't start task (%d)\n", sc); + rtems_task_suspend (RTEMS_SELF); + } +} + +void +task1 (void) +{ + rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond); + createTask ('1', &taskId1); + createTask ('2', &taskId2); + startTask (taskId1, subTask1); + startTask (taskId2, subTask2); + rtems_task_suspend (RTEMS_SELF); +} -- cgit v1.2.3