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/sp20 | |
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/sp20')
-rw-r--r-- | testsuites/ada/sptests/sp20/Makefile.am | 16 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp20/ada_sp20.scn | 40 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp20/config.h | 31 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp20/sp20.adb | 54 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp20/sptest.adb | 310 | ||||
-rw-r--r-- | testsuites/ada/sptests/sp20/sptest.ads | 105 |
6 files changed, 556 insertions, 0 deletions
diff --git a/testsuites/ada/sptests/sp20/Makefile.am b/testsuites/ada/sptests/sp20/Makefile.am new file mode 100644 index 0000000000..de7b240d5c --- /dev/null +++ b/testsuites/ada/sptests/sp20/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_sp20 +ada_sp20_SOURCES = sp20.adb config.h sptest.adb sptest.ads +ada_sp20_SOURCES += ../../support/init.c + +ada_sp20$(EXEEXT): sp20.adb init.$(OBJEXT) + $(GNATCOMPILE) -margs -a $< -o $@ + +scndir = $(rtems_ada_testsdir) +dist_scn_DATA = ada_sp20.scn + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/ada/sptests/sp20/ada_sp20.scn b/testsuites/ada/sptests/sp20/ada_sp20.scn new file mode 100644 index 0000000000..5411361d76 --- /dev/null +++ b/testsuites/ada/sptests/sp20/ada_sp20.scn @@ -0,0 +1,40 @@ +*** TEST 20 *** +TA1 - rate_monotonic_create id = 16#42010001# +TA1 - rate_monotonic_ident id = 16#42010001# +TA1 - (16#42010001#) period 2 +TA2 - rate_monotonic_create id = 16#42010002# +TA2 - rate_monotonic_ident id = 16#42010002# +TA2 - (16#42010002#) period 2 +TA3 - rate_monotonic_create id = 16#42010003# +TA3 - rate_monotonic_ident id = 16#42010003# +TA3 - (16#42010003#) period 2 +TA4 - rate_monotonic_create id = 16#42010004# +TA4 - rate_monotonic_ident id = 16#42010004# +TA4 - (16#42010004#) period 2 +TA5 - rate_monotonic_create id = 16#42010005# +TA5 - rate_monotonic_ident id = 16#42010005# +TA5 - (16#42010005#) period 100 +TA6 - rate_monotonic_create id = 16#42010006# +TA6 - rate_monotonic_ident id = 16#42010006# +TA6 - (16#42010006#) period 0 +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 20 *** diff --git a/testsuites/ada/sptests/sp20/config.h b/testsuites/ada/sptests/sp20/config.h new file mode 100644 index 0000000000..daf598bf4c --- /dev/null +++ b/testsuites/ada/sptests/sp20/config.h @@ -0,0 +1,31 @@ +/* config.h + * + * This include file defines the Configuration Table for this test. + * + * COPYRIGHT (c) 1989-2007. + * 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_TASKS 7 +#define CONFIGURE_MAXIMUM_PERIODS 10 + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 10 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 10 + +#include <rtems/confdefs.h> + +/* end of include file */ diff --git a/testsuites/ada/sptests/sp20/sp20.adb b/testsuites/ada/sptests/sp20/sp20.adb new file mode 100644 index 0000000000..898b96c119 --- /dev/null +++ b/testsuites/ada/sptests/sp20/sp20.adb @@ -0,0 +1,54 @@ +-- +-- MAIN / BODY +-- +-- DESCRIPTION: +-- +-- This is the entry point for Test SP20 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 SP20 is + INIT_ID : RTEMS.ID; + STATUS : RTEMS.STATUS_CODES; +begin + + RTEMS.TASKS.CREATE( + RTEMS.BUILD_NAME( 'I', 'N', 'I', 'T' ), + 10, + RTEMS.MINIMUM_STACK_SIZE, + RTEMS.DEFAULT_MODES, + 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 SP20; + diff --git a/testsuites/ada/sptests/sp20/sptest.adb b/testsuites/ada/sptests/sp20/sptest.adb new file mode 100644 index 0000000000..1929fd958f --- /dev/null +++ b/testsuites/ada/sptests/sp20/sptest.adb @@ -0,0 +1,310 @@ +-- +-- SPTEST / BODY +-- +-- DESCRIPTION: +-- +-- This package is the implementation of Test 20 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 UNSIGNED32_IO; +with RTEMS.CLOCK; +with RTEMS.RATE_MONOTONIC; + +package body SPTEST is + +-- +-- INIT +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + pragma Unreferenced(ARGUMENT); + STATUS : RTEMS.STATUS_CODES; + begin + + TEXT_IO.NEW_LINE( 2 ); + TEXT_IO.PUT_LINE( "*** TEST 20 ***" ); + + 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.TASK_NAME( 4 ) := RTEMS.BUILD_NAME( 'T', 'A', '4', ' ' ); + SPTEST.TASK_NAME( 5 ) := RTEMS.BUILD_NAME( 'T', 'A', '5', ' ' ); + SPTEST.TASK_NAME( 6 ) := RTEMS.BUILD_NAME( 'T', 'A', '6', ' ' ); + + for INDEX in 1 .. 6 + loop + + SPTEST.COUNT( INDEX ) := 0; + + RTEMS.TASKS.CREATE( + SPTEST.TASK_NAME( INDEX ), + SPTEST.PRIORITIES( INDEX ), + 4096, + RTEMS.DEFAULT_MODES, + RTEMS.DEFAULT_ATTRIBUTES, + SPTEST.TASK_ID( INDEX ), + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE LOOP" ); + + end loop; + + for INDEX in 1 .. 6 + loop + + RTEMS.TASKS.START( + SPTEST.TASK_ID( INDEX ), + SPTEST.TASK_1_THROUGH_6'ACCESS, + RTEMS.TASKS.ARGUMENT( INDEX ), + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START LOOP" ); + + end loop; + + RTEMS.TASKS.DELETE( RTEMS.SELF, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" ); + + end INIT; + +-- +-- TASK_1_THROUGH_6 +-- + + procedure TASK_1_THROUGH_6 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + RMID : RTEMS.ID; + TEST_RMID : RTEMS.ID; + PASS : RTEMS.UNSIGNED32; + FAILED : RTEMS.UNSIGNED32; + STATUS : RTEMS.STATUS_CODES; + TIME : array( 0 .. 10 ) of RTEMS.INTERVAL; + PERIOD : RTEMS.INTERVAL; + MEASURE : RTEMS.INTERVAL; + begin + + RTEMS.RATE_MONOTONIC.CREATE( ARGUMENT, RMID, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "RATE_MONOTONIC_CREATE" ); + TEST_SUPPORT.PUT_NAME( SPTEST.TASK_NAME( INTEGER( ARGUMENT ) ), FALSE ); + TEXT_IO.PUT( "- rate_monotonic_create id = " ); + UNSIGNED32_IO.PUT( RMID, WIDTH => 8, BASE => 16 ); + TEXT_IO.NEW_LINE; + + RTEMS.RATE_MONOTONIC.IDENT( ARGUMENT, TEST_RMID, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "RATE_MONOTONIC_IDENT" ); + TEST_SUPPORT.PUT_NAME( SPTEST.TASK_NAME( INTEGER( ARGUMENT ) ), FALSE ); + TEXT_IO.PUT( "- rate_monotonic_ident id = " ); + UNSIGNED32_IO.PUT( RMID, WIDTH => 8, BASE => 16 ); + TEXT_IO.NEW_LINE; + if TEST_RMID /= RMID then + TEXT_IO.PUT_LINE( "RMID's DO NOT MATCH!!!" ); + RTEMS.SHUTDOWN_EXECUTIVE( 0 ); + end if; + + TEST_SUPPORT.PUT_NAME( SPTEST.TASK_NAME( INTEGER( ARGUMENT ) ), FALSE ); + TEXT_IO.PUT( " - (" ); + UNSIGNED32_IO.PUT( RMID, WIDTH => 1, BASE => 16 ); + TEXT_IO.PUT( ") period " ); + UNSIGNED32_IO.PUT( + SPTEST.PERIODS( INTEGER( ARGUMENT ) ), + WIDTH => 1, + BASE => 10 + ); + TEXT_IO.NEW_LINE; + + RTEMS.TASKS.WAKE_AFTER( 2, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" ); + + case ARGUMENT is + when 1 .. 4 => + loop + RTEMS.RATE_MONOTONIC.PERIOD( + RMID, + SPTEST.PERIODS( INTEGER( ARGUMENT ) ), + STATUS + ); + + TEST_SUPPORT.DIRECTIVE_FAILED( + STATUS, + "RATE_MONOTONIC_PERIOD" + ); + + SPTEST.COUNT( INTEGER( ARGUMENT ) ) := + SPTEST.COUNT( INTEGER( ARGUMENT ) ) + 1; + + end loop; + + when 5 => + + PASS := 0; + FAILED := 0; + + RTEMS.RATE_MONOTONIC.PERIOD( + RMID, + SPTEST.PERIODS( INTEGER( ARGUMENT ) ), + STATUS + ); + + TEST_SUPPORT.DIRECTIVE_FAILED( + STATUS, + "RATE_MONOTONIC_PERIOD 1 OF TA5" + ); + + SPTEST.GET_ALL_COUNTERS; + + loop + + RTEMS.RATE_MONOTONIC.PERIOD( + RMID, + SPTEST.PERIODS( INTEGER( ARGUMENT ) ), + STATUS + ); + + TEST_SUPPORT.DIRECTIVE_FAILED( + STATUS, + "RATE_MONOTONIC_PERIOD 2 OF TA5" + ); + + SPTEST.GET_ALL_COUNTERS; + + for INDEX in 1 .. 4 loop + + if SPTEST.TEMPORARY_COUNT( INDEX ) /= + SPTEST.ITERATIONS( INDEX ) then + + TEXT_IO.PUT( "FAIL -- " ); + TEST_SUPPORT.PUT_NAME( + SPTEST.TASK_NAME( INDEX ), + FALSE + ); + TEXT_IO.PUT( "ACTUAL=" ); + UNSIGNED32_IO.PUT( + SPTEST.TEMPORARY_COUNT( INDEX ), + WIDTH => 3, + BASE => 10 + ); + TEXT_IO.PUT( " EXPECTED=" ); + UNSIGNED32_IO.PUT( + SPTEST.ITERATIONS( INDEX ), + WIDTH => 3, + BASE => 10 + ); + TEXT_IO.NEW_LINE; + + FAILED := FAILED + 1; + + end if; + + end loop; + + if FAILED = 5 then + RTEMS.SHUTDOWN_EXECUTIVE( 0 ); + end if; + + PASS := PASS + 1; + TEXT_IO.PUT( "TA5 - PERIODS CHECK OK (" ); + UNSIGNED32_IO.PUT( PASS, WIDTH => 1, BASE => 10 ); + TEXT_IO.PUT_LINE( ")" ); + + if PASS = 10 then + TEXT_IO.PUT_LINE( "*** END OF TEST 20 ***" ); + RTEMS.SHUTDOWN_EXECUTIVE( 0 ); + end if; + + end loop; + + when 6 => + -- test changing periods + for INDEX in 0 .. 10 loop + PERIOD := RTEMS.INTERVAL( ( INDEX + 1 ) * 10 ); + RTEMS.RATE_MONOTONIC.PERIOD( RMID, PERIOD, STATUS); + TEST_SUPPORT.DIRECTIVE_FAILED( + STATUS, "rate_monotonic_period of TA6" + ); + + -- timestamp + Time( INDEX ) := RTEMS.CLOCK.GET_TICKS_SINCE_BOOT; + end loop; + + for INDEX in 1 .. 10 loop + MEASURE := TIME( INDEX ) - TIME( INDEX - 1 ); + PERIOD := RTEMS.INTERVAL( INDEX * 10 ); + TEXT_IO.PUT( "TA6 - Actual: " ); + UNSIGNED32_IO.PUT( MEASURE, WIDTH => 3, BASE => 10 ); + TEXT_IO.PUT( " Expected: " ); + UNSIGNED32_IO.PUT( PERIOD, WIDTH => 3, BASE => 10 ); + if PERIOD = MEASURE then + TEXT_IO.PUT_LINE( " - OK" ); + else + TEXT_IO.PUT_LINE( " - FAILED" ); + end if; + end loop; + + RTEMS.TASKS.SUSPEND( RTEMS.SELF, STATUS ); + TEST_SUPPORT.DIRECTIVE_FAILED( + STATUS, "task_suspend of TA6" + ); + + when others => + NULL; + + end case; + + end TASK_1_THROUGH_6; + +-- +-- GET_ALL_COUNTERS +-- + + procedure GET_ALL_COUNTERS + is + PREVIOUS_MODE : RTEMS.MODE; + STATUS : RTEMS.STATUS_CODES; + begin + + RTEMS.TASKS.MODE( + RTEMS.NO_PREEMPT, + RTEMS.PREEMPT_MASK, + PREVIOUS_MODE, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE TO NO_PREEMPT" ); + + SPTEST.TEMPORARY_COUNT := SPTEST.COUNT; + + for INDEX in 1 .. 5 + loop + + SPTEST.COUNT( INDEX ) := 0; + + end loop; + + RTEMS.TASKS.MODE( + RTEMS.PREEMPT, + RTEMS.PREEMPT_MASK, + PREVIOUS_MODE, + STATUS + ); + TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE TO PREEMPT" ); + + end GET_ALL_COUNTERS; + +end SPTEST; diff --git a/testsuites/ada/sptests/sp20/sptest.ads b/testsuites/ada/sptests/sp20/sptest.ads new file mode 100644 index 0000000000..384cc1dac5 --- /dev/null +++ b/testsuites/ada/sptests/sp20/sptest.ads @@ -0,0 +1,105 @@ +-- +-- SPTEST / SPECIFICATION +-- +-- DESCRIPTION: +-- +-- This package is the specification for Test 20 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 ( 1 .. 6 ) of RTEMS.ID; + TASK_NAME : array ( 1 .. 6 ) of RTEMS.NAME; + +-- +-- These arrays contain the parameters which define the execution +-- characteristics and periods of each instantiation of the +-- copies of the RTEMS task TASKS_1_THROUGH_6. +-- + + PERIODS : constant array ( 1 .. 6 ) + of RTEMS.UNSIGNED32 := ( 2, 2, 2, 2, 100, 0 ); + + ITERATIONS : constant array ( 1 .. 6 ) + of RTEMS.UNSIGNED32 := ( 50, 50, 50, 50, 1, 10 ); + + PRIORITIES : constant array ( 1 .. 6 ) + of RTEMS.UNSIGNED32 := ( 1, 1, 3, 4, 5, 1 ); + +-- +-- The following type defines the array used to manage the +-- execution counts of each task's period. +-- + + type COUNT_ARRAY is array ( 1 .. 6 ) of RTEMS.UNSIGNED32; + +-- +-- These arrays contains the number of periods successfully completed +-- by each of the tasks. At each of its periods, the fifth task +-- will copy the contents of the COUNT array to TEMPORARY_COUNT, +-- and clear the COUNT array. The copy is performed to insure +-- that no periods fire while it is verifying the correctness +-- of the test's execution. +-- + + COUNT : SPTEST.COUNT_ARRAY; + TEMPORARY_COUNT : SPTEST.COUNT_ARRAY; + +-- +-- INIT +-- +-- DESCRIPTION: +-- +-- This RTEMS task initializes the application. +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, INIT); + +-- +-- TASK_1_THROUGH_6 +-- +-- DESCRIPTION: +-- +-- These RTEMS tasks test the Rate Monotonic Manager. +-- + + procedure TASK_1_THROUGH_6 ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, TASK_1_THROUGH_6); + +-- +-- GET_ALL_COUNTERS +-- +-- DESCRIPTION: +-- +-- This subprogram atomically copies the contents of COUNTER to +-- TEMPORARY_COUNTER. +-- + + procedure GET_ALL_COUNTERS; + +end SPTEST; |