summaryrefslogtreecommitdiffstats
path: root/testsuites/ada/sptests/sp22
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-12 10:00:10 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-12 10:53:16 +0200
commitee537ea3dd964d4de3565a36b4857af31fb5a3f4 (patch)
treead8b328a58469ca0632e3e61cd94f37c9d97cc25 /testsuites/ada/sptests/sp22
parentada-tests: Use _SUBDIRS instead of SUBDIRS (diff)
downloadrtems-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/sp22')
-rw-r--r--testsuites/ada/sptests/sp22/Makefile.am16
-rw-r--r--testsuites/ada/sptests/sp22/ada_sp22.scn29
-rw-r--r--testsuites/ada/sptests/sp22/config.h31
-rw-r--r--testsuites/ada/sptests/sp22/sp22.adb55
-rw-r--r--testsuites/ada/sptests/sp22/sptest.adb297
-rw-r--r--testsuites/ada/sptests/sp22/sptest.ads93
6 files changed, 521 insertions, 0 deletions
diff --git a/testsuites/ada/sptests/sp22/Makefile.am b/testsuites/ada/sptests/sp22/Makefile.am
new file mode 100644
index 0000000000..8b24be6768
--- /dev/null
+++ b/testsuites/ada/sptests/sp22/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_sp22
+ada_sp22_SOURCES = sp22.adb config.h sptest.adb sptest.ads
+ada_sp22_SOURCES += ../../support/init.c
+
+ada_sp22$(EXEEXT): sp22.adb init.$(OBJEXT)
+ $(GNATCOMPILE) -margs -a $< -o $@
+
+scndir = $(rtems_ada_testsdir)
+dist_scn_DATA = ada_sp22.scn
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/ada/sptests/sp22/ada_sp22.scn b/testsuites/ada/sptests/sp22/ada_sp22.scn
new file mode 100644
index 0000000000..3e96936e24
--- /dev/null
+++ b/testsuites/ada/sptests/sp22/ada_sp22.scn
@@ -0,0 +1,29 @@
+*** TEST 22 ***
+INIT - timer_create - creating timer 1
+INIT - timer 1 has id (16#12010001#)
+TA1 - timer_ident - identing timer 1
+TA1 - timer 1 has id (16#12010001#)
+TA1 - clock_get - 9: 0: 0 12/31/1988
+TA1 - timer_after - timer 1 in 3 seconds
+TA1 - task_suspend( SELF )
+TA1 - clock_get - 9: 0: 3 12/31/1988
+TA1 - timer_after - timer 1 in 3 seconds
+TA1 - task_wake_after - 1 second
+TA1 - clock_get - 9: 0: 4 12/31/1988
+TA1 - timer_reset - timer 1
+TA1 - task_suspend( SELF )
+TA1 - clock_get - 9: 0: 7 12/31/1988
+<pause>
+TA1 - timer_after - timer 1 in 3 seconds
+TA1 - timer_cancel - timer 1
+TA1 - clock_get - 9: 0: 7 12/31/1988
+TA1 - timer_when - timer 1 in 3 seconds
+TA1 - task_suspend( SELF )
+TA1 - clock_get - 9: 0:10 12/31/1988
+TA1 - timer_when - timer 1 in 3 seconds
+TA1 - task_wake_after - 1 second
+TA1 - clock_get - 9: 0:11 12/31/1988
+TA1 - timer_cancel - timer 1
+TA1 - task_wake_after - YIELD (only task at priority)
+TA1 - timer_delete - timer 1
+*** END OF TEST 22 ***
diff --git a/testsuites/ada/sptests/sp22/config.h b/testsuites/ada/sptests/sp22/config.h
new file mode 100644
index 0000000000..b8ed5c97d0
--- /dev/null
+++ b/testsuites/ada/sptests/sp22/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 2
+#define CONFIGURE_MAXIMUM_TIMERS 2
+
+#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/sp22/sp22.adb b/testsuites/ada/sptests/sp22/sp22.adb
new file mode 100644
index 0000000000..842bc7338e
--- /dev/null
+++ b/testsuites/ada/sptests/sp22/sp22.adb
@@ -0,0 +1,55 @@
+--
+-- MAIN / BODY
+--
+-- DESCRIPTION:
+--
+-- This is the entry point for Test SP22 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 SP22 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 SP22;
+
diff --git a/testsuites/ada/sptests/sp22/sptest.adb b/testsuites/ada/sptests/sp22/sptest.adb
new file mode 100644
index 0000000000..a947628db5
--- /dev/null
+++ b/testsuites/ada/sptests/sp22/sptest.adb
@@ -0,0 +1,297 @@
+--
+-- SPTEST / BODY
+--
+-- DESCRIPTION:
+--
+-- This package is the implementation of Test 22 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.TIMER;
+
+package body SPTEST is
+
+--
+-- 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 22 ***" );
+
+ TIME := ( 1988, 12, 31, 9, 0, 0, 0 );
+
+ RTEMS.CLOCK.SET( TIME, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" );
+
+ SPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME( 'T', 'A', '1', ' ' );
+ SPTEST.TIMER_NAME( 1 ) := RTEMS.BUILD_NAME( 'T', 'M', '1', ' ' );
+
+ RTEMS.TASKS.CREATE(
+ SPTEST.TASK_NAME( 1 ),
+ 1,
+ 2048,
+ RTEMS.DEFAULT_MODES,
+ RTEMS.DEFAULT_ATTRIBUTES,
+ SPTEST.TASK_ID( 1 ),
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
+
+ RTEMS.TASKS.START(
+ SPTEST.TASK_ID( 1 ),
+ SPTEST.TASK_1'ACCESS,
+ 0,
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
+
+ TEXT_IO.PUT_LINE( "INIT - timer_create - creating timer 1" );
+ RTEMS.TIMER.CREATE(
+ SPTEST.TIMER_NAME( 1 ),
+ SPTEST.TIMER_ID( 1 ),
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CREATE OF TM1" );
+ TEXT_IO.PUT( "INIT - timer 1 has id (" );
+ UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ), WIDTH => 8, BASE => 16 );
+ TEXT_IO.PUT_LINE( ")" );
+
+ RTEMS.TASKS.DELETE( RTEMS.SELF, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
+
+ end INIT;
+
+--
+-- DELAYED_RESUME
+--
+
+ procedure DELAYED_RESUME (
+ IGNORED_ID : in RTEMS.ID;
+ IGNORED_ADDRESS : in RTEMS.ADDRESS
+ ) is
+ pragma Unreferenced(IGNORED_ID);
+ pragma Unreferenced(IGNORED_ADDRESS);
+ STATUS : RTEMS.STATUS_CODES;
+ begin
+
+ RTEMS.TASKS.RESUME( SPTEST.TASK_ID( 1 ), STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESUME OF SELF" );
+
+ end DELAYED_RESUME;
+
+--
+-- PRINT_TIME
+--
+
+ procedure PRINT_TIME
+ is
+ TIME : RTEMS.TIME_OF_DAY;
+ STATUS : RTEMS.STATUS_CODES;
+ begin
+
+ RTEMS.CLOCK.GET_TOD( TIME, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_TOD" );
+
+ TEST_SUPPORT.PUT_NAME(
+ SPTEST.TASK_NAME( 1 ),
+ FALSE
+ );
+
+ TEST_SUPPORT.PRINT_TIME( "- clock_get - ", TIME, "" );
+ TEXT_IO.NEW_LINE;
+
+ end PRINT_TIME;
+
+--
+-- TASK_1
+--
+
+ procedure TASK_1 (
+ ARGUMENT : in RTEMS.TASKS.ARGUMENT
+ ) is
+ pragma Unreferenced(ARGUMENT);
+ TMID : RTEMS.ID;
+ TIME : RTEMS.TIME_OF_DAY;
+ STATUS : RTEMS.STATUS_CODES;
+ begin
+
+-- GET ID
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_ident - identing timer 1" );
+ RTEMS.TIMER.IDENT( SPTEST.TIMER_NAME( 1 ), TMID, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_IDENT OF TM1" );
+ TEXT_IO.PUT( "TA1 - timer 1 has id (" );
+ UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ), WIDTH => 8, BASE => 16 );
+ TEXT_IO.PUT_LINE( ")" );
+
+-- AFTER WHICH IS ALLOWED TO FIRE
+
+ SPTEST.PRINT_TIME;
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
+ RTEMS.TIMER.FIRE_AFTER(
+ TMID,
+ 3 * TEST_SUPPORT.TICKS_PER_SECOND,
+ SPTEST.DELAYED_RESUME'ACCESS,
+ RTEMS.NULL_ADDRESS,
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
+
+ TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
+ RTEMS.TASKS.SUSPEND( RTEMS.SELF, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
+
+ SPTEST.PRINT_TIME;
+
+-- AFTER WHICH IS RESET AND ALLOWED TO FIRE
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
+ RTEMS.TIMER.FIRE_AFTER(
+ TMID,
+ 3 * TEST_SUPPORT.TICKS_PER_SECOND,
+ SPTEST.DELAYED_RESUME'ACCESS,
+ RTEMS.NULL_ADDRESS,
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
+
+ TEXT_IO.PUT_LINE( "TA1 - task_wake_after - 1 second" );
+ RTEMS.TASKS.WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
+
+ SPTEST.PRINT_TIME;
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_reset - timer 1" );
+ RTEMS.TIMER.RESET( TMID, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_RESET" );
+
+ TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
+ RTEMS.TASKS.SUSPEND( RTEMS.SELF, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
+
+ SPTEST.PRINT_TIME;
+
+TEST_SUPPORT.PAUSE;
+
+--
+-- Reset the time since we do not know how long the user waited
+-- before pressing <cr> at the pause. This insures that the
+-- actual output matches the screen.
+--
+
+ TIME := ( 1988, 12, 31, 9, 0, 7, 0 );
+
+ RTEMS.CLOCK.SET( TIME, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" );
+
+-- after which is canceled
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
+ RTEMS.TIMER.FIRE_AFTER(
+ TMID,
+ 3 * TEST_SUPPORT.TICKS_PER_SECOND,
+ SPTEST.DELAYED_RESUME'ACCESS,
+ RTEMS.NULL_ADDRESS,
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_cancel - timer 1" );
+ RTEMS.TIMER.CANCEL( TMID, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CANCEL" );
+
+-- when which is allowed to fire
+
+ SPTEST.PRINT_TIME;
+
+ RTEMS.CLOCK.GET_TOD( TIME, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_TOD" );
+
+ TIME.SECOND := TIME.SECOND + 3;
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_when - timer 1 in 3 seconds" );
+ RTEMS.TIMER.FIRE_WHEN(
+ TMID,
+ TIME,
+ SPTEST.DELAYED_RESUME'ACCESS,
+ RTEMS.NULL_ADDRESS,
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_WHEN" );
+
+ TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
+ RTEMS.TASKS.SUSPEND( RTEMS.SELF, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
+
+ SPTEST.PRINT_TIME;
+
+-- when which is canceled
+
+ RTEMS.CLOCK.GET_TOD( TIME, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET_TOD" );
+
+ TIME.SECOND := TIME.SECOND + 3;
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_when - timer 1 in 3 seconds" );
+ RTEMS.TIMER.FIRE_WHEN(
+ TMID,
+ TIME,
+ SPTEST.DELAYED_RESUME'ACCESS,
+ RTEMS.NULL_ADDRESS,
+ STATUS
+ );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_WHEN" );
+
+ TEXT_IO.PUT_LINE( "TA1 - task_wake_after - 1 second" );
+ RTEMS.TASKS.WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
+
+ SPTEST.PRINT_TIME;
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_cancel - timer 1" );
+ RTEMS.TIMER.CANCEL( TMID, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CANCEL" );
+
+-- delete
+
+ TEXT_IO.PUT_LINE(
+ "TA1 - task_wake_after - YIELD (only task at priority)"
+ );
+ RTEMS.TASKS.WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER YIELD" );
+
+ TEXT_IO.PUT_LINE( "TA1 - timer_delete - timer 1" );
+ RTEMS.TIMER.DELETE( TMID, STATUS );
+ TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_DELETE" );
+
+ TEXT_IO.PUT_LINE( "*** END OF TEST 22 ***" );
+ RTEMS.SHUTDOWN_EXECUTIVE( 0 );
+
+ end TASK_1;
+
+end SPTEST;
diff --git a/testsuites/ada/sptests/sp22/sptest.ads b/testsuites/ada/sptests/sp22/sptest.ads
new file mode 100644
index 0000000000..af312fafb8
--- /dev/null
+++ b/testsuites/ada/sptests/sp22/sptest.ads
@@ -0,0 +1,93 @@
+--
+-- SPTEST / SPECIFICATION
+--
+-- DESCRIPTION:
+--
+-- This package is the specification for Test 22 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 .. 1 ) of RTEMS.ID;
+ TASK_NAME : array ( RTEMS.UNSIGNED32 range 1 .. 1 ) of RTEMS.NAME;
+
+--
+-- These arrays contain the IDs and NAMEs of all RTEMS timers created
+-- by this test.
+--
+
+ TIMER_ID : array ( RTEMS.UNSIGNED32 range 1 .. 1 ) of RTEMS.ID;
+ TIMER_NAME : array ( RTEMS.UNSIGNED32 range 1 .. 1 ) of RTEMS.NAME;
+
+--
+-- INIT
+--
+-- DESCRIPTION:
+--
+-- This RTEMS task initializes the application.
+--
+
+ procedure INIT (
+ ARGUMENT : in RTEMS.TASKS.ARGUMENT
+ );
+ pragma Convention (C, INIT);
+
+--
+-- DELAYED_RESUME
+--
+-- DESCRIPTION:
+--
+-- This subprogram is scheduled to be fired as a timer service
+-- routine. When fired this subprogram resumes TASK_1.
+--
+
+ procedure DELAYED_RESUME (
+ IGNORED_ID : in RTEMS.ID;
+ IGNORED_ADDRESS : in RTEMS.ADDRESS
+ );
+ pragma Convention (C, DELAYED_RESUME);
+
+--
+-- PRINT_TIME
+--
+-- DESCRIPTION:
+--
+-- This subprogram prints the name of TASK_1 and the current TIME of day.
+--
+
+ procedure PRINT_TIME;
+
+--
+-- TASK_1
+--
+-- DESCRIPTION:
+--
+-- This RTEMS task tests the Timer Manager.
+--
+
+ procedure TASK_1 (
+ ARGUMENT : in RTEMS.TASKS.ARGUMENT
+ );
+ pragma Convention (C, TASK_1);
+
+end SPTEST;