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/samples/nsecs | |
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/samples/nsecs')
-rw-r--r-- | testsuites/ada/samples/nsecs/Makefile.am | 19 | ||||
-rw-r--r-- | testsuites/ada/samples/nsecs/ada_nsecs.scn | 27 | ||||
-rw-r--r-- | testsuites/ada/samples/nsecs/config.h | 30 | ||||
-rw-r--r-- | testsuites/ada/samples/nsecs/nsecs.adb | 54 | ||||
-rw-r--r-- | testsuites/ada/samples/nsecs/sptest.adb | 153 | ||||
-rw-r--r-- | testsuites/ada/samples/nsecs/sptest.ads | 39 |
6 files changed, 322 insertions, 0 deletions
diff --git a/testsuites/ada/samples/nsecs/Makefile.am b/testsuites/ada/samples/nsecs/Makefile.am new file mode 100644 index 0000000000..64a8145818 --- /dev/null +++ b/testsuites/ada/samples/nsecs/Makefile.am @@ -0,0 +1,19 @@ +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am + +include $(top_srcdir)/ada.am + +ada_nsecs$(EXEEXT): nsecs.adb init.$(OBJEXT) + $(GNATCOMPILE) -margs -a $< -o $@ + +init.$(OBJEXT): ../../support/init.c + $(COMPILE.c) -I$(srcdir) -c $< + +noinst_PROGRAMS = ada_nsecs + +ada_nsecs_SOURCES = nsecs.adb config.h sptest.adb sptest.ads + +scndir = $(rtems_ada_testsdir) +dist_scn_DATA = ada_nsecs.scn + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/ada/samples/nsecs/ada_nsecs.scn b/testsuites/ada/samples/nsecs/ada_nsecs.scn new file mode 100644 index 0000000000..458f12c874 --- /dev/null +++ b/testsuites/ada/samples/nsecs/ada_nsecs.scn @@ -0,0 +1,27 @@ +*** NANOSECOND CLOCK TEST *** +10 iterations of getting TOD NOT tested in Ada + +10 iterations of getting Uptime +0: 9025000 0: 9034000 --> 0: 9000 +0: 10724000 0: 10733000 --> 0: 9000 +0: 12400000 0: 12409000 --> 0: 9000 +0: 14076000 0: 14085000 --> 0: 9000 +0: 15752000 0: 15761000 --> 0: 9000 +0: 17428000 0: 17438000 --> 0: 10000 +0: 19108000 0: 19117000 --> 0: 9000 +0: 20814000 0: 20823000 --> 0: 9000 +0: 22490000 0: 22499000 --> 0: 9000 +0: 24166000 0: 24175000 --> 0: 9000 + +10 iterations of getting Uptime with different loop values +loop of 10000 0: 26747000 0: 29758000 --> 0: 3011000 +loop of 20000 0: 31927000 0: 37938000 --> 0: 6011000 +loop of 30000 0: 40108000 0: 49118000 --> 0: 9010000 +loop of 40000 0: 51287000 0: 63327000 --> 0: 12040000 +loop of 50000 0: 65471000 0: 80541000 --> 0: 15070000 +loop of 60000 0: 82684000 0:100754000 --> 0: 18070000 +loop of 70000 0:102892000 0:123963000 --> 0: 21071000 +loop of 80000 0:126096000 0:150196000 --> 0: 24100000 +loop of 90000 0:152329000 0:179399000 --> 0: 27070000 +loop of 100000 0:181562000 0:211662000 --> 0: 30100000 +*** END OF NANOSECOND CLOCK TEST *** diff --git a/testsuites/ada/samples/nsecs/config.h b/testsuites/ada/samples/nsecs/config.h new file mode 100644 index 0000000000..7703e721f0 --- /dev/null +++ b/testsuites/ada/samples/nsecs/config.h @@ -0,0 +1,30 @@ +/* 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_APPLICATION + +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE + +#define CONFIGURE_MAXIMUM_POSIX_THREADS 10 +#define CONFIGURE_MAXIMUM_POSIX_KEYS 10 + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#include <rtems/confdefs.h> + +/* end of include file */ diff --git a/testsuites/ada/samples/nsecs/nsecs.adb b/testsuites/ada/samples/nsecs/nsecs.adb new file mode 100644 index 0000000000..0a8f84a606 --- /dev/null +++ b/testsuites/ada/samples/nsecs/nsecs.adb @@ -0,0 +1,54 @@ +-- +-- MAIN / BODY +-- +-- DESCRIPTION: +-- +-- This is the entry point for Test Nsecs of the Sample 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 Nsecs 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 Nsecs; + diff --git a/testsuites/ada/samples/nsecs/sptest.adb b/testsuites/ada/samples/nsecs/sptest.adb new file mode 100644 index 0000000000..193fa09a45 --- /dev/null +++ b/testsuites/ada/samples/nsecs/sptest.adb @@ -0,0 +1,153 @@ +-- +-- SPTEST / BODY +-- +-- DESCRIPTION: +-- +-- This package is the implementation of the Nanosecond test of the +-- Sample 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 Ada.Integer_Text_IO; +with Interfaces.C; +with RTEMS; +with RTEMS.Clock; +with Text_IO; +use type Interfaces.C.Long; +use type RTEMS.Time_T; + +package body SPTEST is + + Dummy_Variable : Natural := 0; + + procedure Simple_Procedure is + begin + Dummy_Variable := Dummy_Variable + 1; + end Simple_Procedure; + + procedure Subtract_Em ( + Start : in RTEMS.Timespec; + Stop : in RTEMS.Timespec; + Result : out RTEMS.Timespec + ) is + Nanoseconds_Per_Second : constant := 1000000000; + begin + if (Stop.TV_Nsec < Start.TV_Nsec) then + Result.TV_Sec := Stop.TV_Sec - Start.TV_Sec - 1; + Result.TV_Nsec := + (Nanoseconds_Per_Second - Start.TV_Nsec) + Stop.TV_Nsec; + else + Result.TV_Sec := Stop.TV_Sec - Start.TV_Sec; + Result.TV_Nsec := Stop.TV_Nsec - Start.TV_Nsec; + end if; + end Subtract_Em; + + +-- +-- INIT +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ) is + pragma Unreferenced(ARGUMENT); + Status : RTEMS.Status_Codes; + Start : RTEMS.Timespec; + Stop : RTEMS.Timespec; + Diff : RTEMS.Timespec; + Max : Integer; + begin + + TEXT_IO.NEW_LINE( 2 ); + TEXT_IO.PUT_LINE( "*** NANOSECOND CLOCK TEST ***" ); + + -- + -- Iterate 10 times showing difference in TOD + -- + + TEXT_IO.PUT_LINE( "10 iterations of getting TOD NOT tested in Ada" ); + + -- + -- Iterate 10 times showing difference in Uptime + -- + + TEXT_IO.NEW_LINE; + TEXT_IO.PUT_LINE( "10 iterations of getting Uptime" ); + + for Index in 1 .. 10 loop + + RTEMS.Clock.Get_Uptime( Start, Status ); + RTEMS.Clock.Get_Uptime( Stop, Status ); + + Subtract_Em( Start, Stop, Diff ); + + Ada.Integer_Text_IO.Put( Integer( Start.TV_Sec ), 1 ); + Text_IO.Put( ":" ); + Ada.Integer_Text_IO.Put( Integer( Start.TV_Nsec ), 9 ); + Text_IO.Put( " " ); + Ada.Integer_Text_IO.Put( Integer( Stop.TV_Sec ), 1 ); + Text_IO.Put( ":" ); + Ada.Integer_Text_IO.Put( Integer( Stop.TV_Nsec ), 9 ); + Text_IO.Put( " --> " ); + Ada.Integer_Text_IO.Put( Integer( Diff.TV_Sec ), 1 ); + Text_IO.Put( ":" ); + Ada.Integer_Text_IO.Put( Integer( Diff.TV_Nsec ), 9 ); + Text_IO.New_Line; + end loop; + + -- + -- Iterate 10 times showing difference in Uptime with different counts + -- + + TEXT_IO.NEW_LINE; + TEXT_IO.PUT_LINE( + "10 iterations of getting Uptime with different loop values" + ); + + for Index in 1 .. 10 loop + Max := (Index * 10000); + RTEMS.Clock.Get_Uptime( Start, Status ); + for j in 1 .. Max loop + Simple_Procedure; + end loop; + RTEMS.Clock.Get_Uptime( Stop, Status ); + + Subtract_Em( Start, Stop, Diff ); + + Text_IO.Put( "loop of " ); + Ada.Integer_Text_IO.Put( Max, 6 ); + Text_IO.Put( " " ); + Ada.Integer_Text_IO.Put( Integer( Start.TV_Sec ), 1 ); + Text_IO.Put( ":" ); + Ada.Integer_Text_IO.Put( Integer( Start.TV_Nsec ), 9 ); + Text_IO.Put( " " ); + Ada.Integer_Text_IO.Put( Integer( Stop.TV_Sec ), 1 ); + Text_IO.Put( ":" ); + Ada.Integer_Text_IO.Put( Integer( Stop.TV_Nsec ), 9 ); + Text_IO.Put( " --> " ); + Ada.Integer_Text_IO.Put( Integer( Diff.TV_Sec ), 1 ); + Text_IO.Put( ":" ); + Ada.Integer_Text_IO.Put( Integer( Diff.TV_Nsec ), 9 ); + Text_IO.New_Line; + + end loop; + + delay( 1.0 ); + + TEXT_IO.PUT_LINE( "*** END OF NANOSECOND CLOCK TEST ***" ); + + RTEMS.SHUTDOWN_EXECUTIVE( 0 ); + + end INIT; + +end SPTEST; diff --git a/testsuites/ada/samples/nsecs/sptest.ads b/testsuites/ada/samples/nsecs/sptest.ads new file mode 100644 index 0000000000..97fa00ac2c --- /dev/null +++ b/testsuites/ada/samples/nsecs/sptest.ads @@ -0,0 +1,39 @@ +-- +-- SPTEST / SPECIFICATION +-- +-- DESCRIPTION: +-- +-- This package is the specification for the Nsecs Test of the RTEMS +-- Sample 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 + +-- +-- INIT +-- +-- DESCRIPTION: +-- +-- This RTEMS task initializes the application. +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASKS.ARGUMENT + ); + pragma Convention (C, INIT); + +end SPTEST; |