diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-12 10:00:10 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-10-12 10:53:16 +0200 |
commit | ee537ea3dd964d4de3565a36b4857af31fb5a3f4 (patch) | |
tree | ad8b328a58469ca0632e3e61cd94f37c9d97cc25 /testsuites/ada/sptests/sp04 | |
parent | ada-tests: Use _SUBDIRS instead of SUBDIRS (diff) | |
download | rtems-ee537ea3dd964d4de3565a36b4857af31fb5a3f4.tar.bz2 |
ada-tests: Move to testsuites/ada
This solves a build dependency issue, e.g. building tests before
librtemsbsp.a exists.
Close #3079.
Diffstat (limited to 'testsuites/ada/sptests/sp04')
-rw-r--r-- | testsuites/ada/sptests/sp04/Makefile.am | 16 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp04/README | 9 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp04/ada_sp04.scn | 25 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp04/config.h | 33 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp04/sp04.adb | 55 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp04/sptest.adb | 348 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp04/sptest.ads | 136 |
7 files changed, 622 insertions, 0 deletions
diff --git a/testsuites/ada/sptests/sp04/Makefile.am b/testsuites/ada/sptests/sp04/Makefile.am new file mode 100644 index 0000000000..fc5d2be018 --- /dev/null +++ b/testsuites/ada/sptests/sp04/Makefile.am @@ -0,0 +1,16 @@ +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am + +include $(top_srcdir)/ada.am + +noinst_PROGRAMS = ada_sp04 +ada_sp04_SOURCES = sp04.adb config.h sptest.adb sptest.ads +ada_sp04_SOURCES += ../../support/init.c + +ada_sp04$(EXEEXT): sp04.adb init.$(OBJEXT) + $(GNATCOMPILE) -margs -a $< -o $@ + +scndir = $(rtems_ada_testsdir) +dist_scn_DATA = ada_sp04.scn + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/ada/sptests/sp04/README b/testsuites/ada/sptests/sp04/README new file mode 100644 index 0000000000..43ff165261 --- /dev/null +++ b/testsuites/ada/sptests/sp04/README @@ -0,0 +1,9 @@ +This test is broken as it is currently implemented. It is illegal for +a task to do Ada IO during a extension since the Ada run-time uses +locks to safeguard data structures. Dispatching is disabled and the +call to Text_IO in the Switch extension will lock the system up. + +The proper solution is to have the Switch extension lock task and +time when it a switch occurs and have a single task print this +information as necessary. + diff --git a/testsuites/ada/sptests/sp04/ada_sp04.scn b/testsuites/ada/sptests/sp04/ada_sp04.scn new file mode 100644 index 0000000000..76d9f0c665 --- /dev/null +++ b/testsuites/ada/sptests/sp04/ada_sp04.scn @@ -0,0 +1,25 @@ +*** TEST 4 *** +TA1 - task_suspend - on Task 2 +TA1 - task_suspend - on Task 3 +TA1 - killing time +TA1 - task_resume - on Task 2 +TA1 - task_resume - on Task 3 +TA1 - task_mode - change mode to NO PREEMPT +TA1 - 9:15:10 12/31/1988 +TA1 - 9:15:11 12/31/1988 +TA1 - 9:15:12 12/31/1988 +TA1 - 9:15:13 12/31/1988 +TA1 - 9:15:14 12/31/1988 +TA1 - 9:15:15 12/31/1988 +TA1 - task_mode - change mode to PREEMPT +TA1 - 9:15: 0 12/31/1988 +TA2 - 9:15: 4 12/31/1988 +TA3 - 9:15: 5 12/31/1988 +TA1 - 9:15: 6 12/31/1988 +TA2 - 9:15: 7 12/31/1988 +TA3 - 9:15: 8 12/31/1988 +TA1 - 9:15: 9 12/31/1988 +TA2 - 9:15:16 12/31/1988 +TA3 - 9:15:17 12/31/1988 +TA1 - 9:15:18 12/31/1988 +*** END OF TEST 4 *** diff --git a/testsuites/ada/sptests/sp04/config.h b/testsuites/ada/sptests/sp04/config.h new file mode 100644 index 0000000000..45fc324df8 --- /dev/null +++ b/testsuites/ada/sptests/sp04/config.h @@ -0,0 +1,33 @@ +/* config.h + * + * This include file defines the Configuration Table for this test. + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +/* configuration information */ + +#define CONFIGURE_SPTEST + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 +#define CONFIGURE_TICKS_PER_TIMESLICE 100 + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 10 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 10 + +#define CONFIGURE_MAXIMUM_TASKS 4 + +#include <rtems/confdefs.h> + +/* end of include file */ diff --git a/testsuites/ada/sptests/sp04/sp04.adb b/testsuites/ada/sptests/sp04/sp04.adb new file mode 100644 index 0000000000..9d91593b36 --- /dev/null +++ b/testsuites/ada/sptests/sp04/sp04.adb @@ -0,0 +1,55 @@ +-- +-- MAIN / BODY +-- +-- DESCRIPTION: +-- +-- This is the entry point for Test SP04 of the Single Processor Test Suite. +-- +-- DEPENDENCIES: +-- +-- +-- +-- COPYRIGHT (c) 1989-2011. +-- On-Line Applications Research Corporation (OAR). +-- +-- The license and distribution terms for this file may in +-- the file LICENSE in this distribution or at +-- http://www.rtems.org/license/LICENSE. +-- + +with RTEMS; +with RTEMS.TASKS; +with SPTEST; +with TEST_SUPPORT; + +procedure SP04 is + INIT_ID : RTEMS.ID; + STATUS : RTEMS.STATUS_CODES; +begin + + RTEMS.TASKS.CREATE( + RTEMS.BUILD_NAME( 'I', 'N', 'I', 'T' ), + 1, + RTEMS.MINIMUM_STACK_SIZE, + RTEMS.NO_PREEMPT, + RTEMS.DEFAULT_ATTRIBUTES, + INIT_ID, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF INIT" ); + + + RTEMS.TASKS.START( + INIT_ID, + SPTEST.INIT'ACCESS, + 0, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF INIT" ); + + loop + delay 120.0; + end loop; + +end SP04; + diff --git a/testsuites/ada/sptests/sp04/sptest.adb b/testsuites/ada/sptests/sp04/sptest.adb new file mode 100644 index 0000000000..01283d3fec --- /dev/null +++ b/testsuites/ada/sptests/sp04/sptest.adb @@ -0,0 +1,348 @@ +-- +-- SPTEST / BODY +-- +-- DESCRIPTION: +-- +-- This package is the implementation of Test 4 of the RTEMS +-- Single Processor Test Suite. +-- +-- DEPENDENCIES: +-- +-- +-- +-- COPYRIGHT (c) 1989-2011. +-- On-Line Applications Research Corporation (OAR). +-- +-- The license and distribution terms for this file may in +-- the file LICENSE in this distribution or at +-- http://www.rtems.org/license/LICENSE. +-- + +with INTERFACES; use INTERFACES; +with TEST_SUPPORT; +with TEXT_IO; +with RTEMS.CLOCK; +with RTEMS.EXTENSION; +with RTEMS.FATAL; + +package body SPTEST is + + TestsFinished : Boolean := False; + pragma Volatile (TestsFinished); + + type Task_Event is record + Task_Index : RTEMS.Unsigned32; + When_Switched : RTEMS.Time_Of_Day; + end record; + + Task_Events : array (1 .. 15) of Task_Event; + Task_Events_Index : Natural := Task_Events'First; + + procedure Log_Task_Event ( + Task_Index : RTEMS.Unsigned32; + When_Switched : RTEMS.Time_Of_Day + ) is + begin + if Task_Events_Index = Task_Events'Last then + RTEMS.Fatal.Error_Occurred ( 1 ); -- no other choice + else + Task_Events (Task_Events_Index).Task_Index := Task_Index; + Task_Events (Task_Events_Index).When_Switched := When_Switched; + Task_Events_Index := Task_Events_Index + 1; + end if; + end Log_Task_Event; + + procedure Flush_Task_Event_Log is + begin + for I in Task_Events'First .. Task_Events_Index - 1 loop + + TEST_SUPPORT.PUT_NAME( + SPTEST.TASK_NAME( Task_Events (I).Task_Index ), FALSE + ); + TEST_SUPPORT.PRINT_TIME( "- ", Task_Events (I).When_Switched, "" ); + TEXT_IO.NEW_LINE; + + end loop; + + end Flush_Task_Event_Log; + +-- +-- INIT +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + pragma Unreferenced(ARGUMENT); + TIME : RTEMS.TIME_OF_DAY; + STATUS : RTEMS.STATUS_CODES; + begin + + TEXT_IO.NEW_LINE( 2 ); + TEXT_IO.PUT_LINE( "*** TEST 4 ***" ); + + TIME := ( 1988, 12, 31, 9, 15, 0, 0 ); + + RTEMS.CLOCK.SET( TIME, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" ); + + SPTEST.EXTENSION_NAME( 1 ) := RTEMS.BUILD_NAME( 'E', 'X', 'T', ' ' ); + + RTEMS.EXTENSION.CREATE( + SPTEST.EXTENSION_NAME( 1 ), + SPTEST.EXTENSIONS'ACCESS, + EXTENSION_ID( 1 ), + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "EXTENSION_CREATE" ); + + SPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME( 'T', 'A', '1', ' ' ); + SPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME( 'T', 'A', '2', ' ' ); + SPTEST.TASK_NAME( 3 ) := RTEMS.BUILD_NAME( 'T', 'A', '3', ' ' ); + + SPTEST.RUN_COUNT( 1 ) := 0; + SPTEST.RUN_COUNT( 2 ) := 0; + SPTEST.RUN_COUNT( 3 ) := 0; + + RTEMS.TASKS.CREATE( + SPTEST.TASK_NAME( 1 ), + 1, + 2048, + RTEMS.TIMESLICE, + RTEMS.DEFAULT_ATTRIBUTES, + SPTEST.TASK_ID( 1 ), + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" ); + + RTEMS.TASKS.CREATE( + SPTEST.TASK_NAME( 2 ), + 1, + 2048, + RTEMS.TIMESLICE, + RTEMS.DEFAULT_ATTRIBUTES, + SPTEST.TASK_ID( 2 ), + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA2" ); + + RTEMS.TASKS.CREATE( + SPTEST.TASK_NAME( 3 ), + 1, + 2048, + RTEMS.TIMESLICE, + RTEMS.DEFAULT_ATTRIBUTES, + SPTEST.TASK_ID( 3 ), + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA3" ); + + RTEMS.TASKS.START( + SPTEST.TASK_ID( 1 ), + SPTEST.TASK_1'ACCESS, + 0, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" ); + + RTEMS.TASKS.START( + SPTEST.TASK_ID( 2 ), + SPTEST.TASK_2'ACCESS, + 0, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA2" ); + + RTEMS.TASKS.START( + SPTEST.TASK_ID( 3 ), + SPTEST.TASK_3'ACCESS, + 0, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA3" ); + + RTEMS.TASKS.DELETE( RTEMS.SELF, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" ); + + end INIT; + +-- +-- TASK_1 +-- + + procedure TASK_1 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + pragma Unreferenced(ARGUMENT); + SECONDS : RTEMS.UNSIGNED32; + OLD_SECONDS : RTEMS.UNSIGNED32; + PREVIOUS_MODE : RTEMS.MODE; + TIME : RTEMS.TIME_OF_DAY; + START_TIME : RTEMS.INTERVAL; + END_TIME : RTEMS.INTERVAL; + STATUS : RTEMS.STATUS_CODES; + begin + + TEXT_IO.PUT_LINE( "TA1 - task_suspend - on Task 2" ); + RTEMS.TASKS.SUSPEND( TASK_ID( 2 ), STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND OF TA2" ); + + TEXT_IO.PUT_LINE( "TA1 - task_suspend - on Task 3" ); + RTEMS.TASKS.SUSPEND( TASK_ID( 3 ), STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND OF TA3" ); + + TEXT_IO.PUT_LINE( "TA1 - killing time" ); + + RTEMS.CLOCK.GET_SECONDS_SINCE_EPOCH( START_TIME, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_SECONDS_SINCE_EPOCH" ); + + loop + RTEMS.CLOCK.GET_SECONDS_SINCE_EPOCH( START_TIME, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED(STATUS, "CLOCK_GET_SECONDS_SINCE_EPOCH"); + + exit when END_TIME > (START_TIME + 2); + end loop; + + TEXT_IO.PUT_LINE( "TA1 - task_resume - on Task 2" ); + RTEMS.TASKS.RESUME( TASK_ID( 2 ), STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESUME OF TA2" ); + + TEXT_IO.PUT_LINE( "TA1 - task_resume - on Task 3" ); + RTEMS.TASKS.RESUME( TASK_ID( 3 ), STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESUME OF TA3" ); + + loop + + if SPTEST.RUN_COUNT( 1 ) = 3 then + + TEXT_IO.PUT_LINE( + "TA1 - task_mode - change mode to NO PREEMPT" + ); + RTEMS.TASKS.MODE( + RTEMS.NO_PREEMPT, + RTEMS.PREEMPT_MASK, + PREVIOUS_MODE, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE" ); + + RTEMS.CLOCK.GET_TOD( TIME, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_TOD" ); + + OLD_SECONDS := TIME.SECOND; + + SECONDS := 0; + loop + + exit when SECONDS >= 6; + + RTEMS.CLOCK.GET_TOD( TIME, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_TOD" ); + + if TIME.SECOND /= OLD_SECONDS then + OLD_SECONDS := TIME.SECOND; + SECONDS := SECONDS + 1; + TEST_SUPPORT.PRINT_TIME( "TA1 - ", TIME, "" ); + TEXT_IO.NEW_LINE; + end if; + + end loop; + + TEXT_IO.PUT_LINE( + "TA1 - task_mode - change mode to PREEMPT" + ); + + RTEMS.TASKS.MODE( + RTEMS.PREEMPT, + RTEMS.PREEMPT_MASK, + PREVIOUS_MODE, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE" ); + + while not TestsFinished loop + NULL; + END LOOP; + Flush_Task_Event_Log; + TEXT_IO.PUT_LINE( "*** END OF TEST 4 ***" ); + RTEMS.SHUTDOWN_EXECUTIVE( 0 ); + + end if; + + end loop; + + end TASK_1; + +-- +-- TASK_2 +-- + + procedure TASK_2 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + pragma Unreferenced(ARGUMENT); + begin + + LOOP + NULL; + END LOOP; + + end TASK_2; + +-- +-- TASK_3 +-- + + procedure TASK_3 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + pragma Unreferenced(ARGUMENT); + begin + + LOOP + NULL; + END LOOP; + + end TASK_3; + +-- +-- TASK_SWITCH +-- + + procedure TASK_SWITCH ( + UNUSED : in RTEMS.TCB_POINTER; + HEIR : in RTEMS.TCB_POINTER + ) is + pragma Unreferenced(UNUSED); + INDEX : RTEMS.UNSIGNED32; + TIME : RTEMS.TIME_OF_DAY; + STATUS : RTEMS.STATUS_CODES; + function TCB_To_ID ( + TCB : RTEMS.TCB_POINTER + ) return RTEMS.ID; + pragma Import (C, TCB_To_ID, "tcb_to_id" ); + + begin + + INDEX := TEST_SUPPORT.TASK_NUMBER( TCB_To_ID( HEIR ) ); + + case INDEX is + when 1 | 2 | 3 => + SPTEST.RUN_COUNT( INDEX ) := SPTEST.RUN_COUNT( INDEX ) + 1; + + RTEMS.CLOCK.GET_TOD( TIME, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_TOD" ); + + Log_Task_Event ( INDEX, TIME ); + + if TIME.SECOND >= 16 then + TestsFinished := True; + end if; + + when others => + NULL; + end case; + + end TASK_SWITCH; + +end SPTEST; diff --git a/testsuites/ada/sptests/sp04/sptest.ads b/testsuites/ada/sptests/sp04/sptest.ads new file mode 100644 index 0000000000..36f1202118 --- /dev/null +++ b/testsuites/ada/sptests/sp04/sptest.ads @@ -0,0 +1,136 @@ +-- +-- SPTEST / SPECIFICATION +-- +-- DESCRIPTION: +-- +-- This package is the specification for Test 4 of the RTEMS +-- Single Processor Test Suite. +-- +-- DEPENDENCIES: +-- +-- +-- +-- COPYRIGHT (c) 1989-2011. +-- On-Line Applications Research Corporation (OAR). +-- +-- The license and distribution terms for this file may in +-- the file LICENSE in this distribution or at +-- http://www.rtems.org/license/LICENSE. +-- + +with RTEMS; +with RTEMS.TASKS; + +package SPTEST is + +-- +-- These arrays contain the IDs and NAMEs of all RTEMS tasks created +-- by this test. +-- + + TASK_ID : array ( RTEMS.UNSIGNED32 range 1 .. 3 ) of RTEMS.ID; + TASK_NAME : array ( RTEMS.UNSIGNED32 range 1 .. 3 ) of RTEMS.NAME; + +-- +-- These arrays contain the IDs and NAMEs of all RTEMS extensions created +-- by this test. +-- + + EXTENSION_ID : array ( RTEMS.UNSIGNED32 range 1 .. 3 ) of RTEMS.ID; + EXTENSION_NAME : array ( RTEMS.UNSIGNED32 range 1 .. 3 ) of RTEMS.NAME; + +-- +-- This array contains the number of times each of the test tasks has +-- been context switched TO. +-- + + RUN_COUNT : array ( RTEMS.UNSIGNED32 range 1 .. 3 ) of RTEMS.UNSIGNED32; + +-- +-- INIT +-- +-- DESCRIPTION: +-- +-- This RTEMS task initializes the application. +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, INIT); + +-- +-- TASK_1 +-- +-- DESCRIPTION: +-- +-- This RTEMS task tests some of the capabilities of the Task Manager. +-- + + procedure TASK_1 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, TASK_1); + +-- +-- TASK_2 +-- +-- DESCRIPTION: +-- +-- This RTEMS task is used as a background task to suspend, resume, +-- and context switch to. +-- + + procedure TASK_2 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, TASK_2); + +-- +-- TASK_3 +-- +-- DESCRIPTION: +-- +-- This RTEMS task is used as a background task to suspend, resume, +-- and context switch to. +-- + + procedure TASK_3 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, TASK_3); + +-- +-- TASK_SWITCH +-- +-- DESCRIPTION: +-- +-- This subprogram is the TASK_SWITCH extension for this test. +-- It is invoked at each context switch and counts the number +-- of times each application task has been context switched to. +-- + + procedure TASK_SWITCH ( + UNUSED : in RTEMS.TCB_POINTER; + HEIR : in RTEMS.TCB_POINTER + ); + pragma Convention (C, TASK_SWITCH); + +-- +-- This is the User Extension Table for this test. +-- + + EXTENSIONS : aliased RTEMS.EXTENSIONS_TABLE := + ( + NULL, -- Task create + NULL, -- Task start + NULL, -- Task restart + NULL, -- Task delete + SPTEST.TASK_SWITCH'ACCESS, -- Task switch + NULL, -- Task post switch + NULL, -- Task begin + NULL, -- Task exitted + NULL -- Fatal error + ); + +end SPTEST; |