From 42f07c5fb7dbd9bdf635e3f98ff273a9ec362924 Mon Sep 17 00:00:00 2001 From: Glenn Humphrey Date: Thu, 25 Oct 2007 19:51:06 +0000 Subject: 2007-10-25 Glenn Humphrey * configure.ac, samples/Makefile.am: Added a test for Clock_Get_Uptime * samples/nsecs/.cvsignore, samples/nsecs/Makefile.am, samples/nsecs/config.h, samples/nsecs/nsecs.adb, samples/nsecs/nsecs.scn, samples/nsecs/sptest.adb, samples/nsecs/sptest.ads: New files. --- c/src/ada-tests/ChangeLog | 8 ++ c/src/ada-tests/configure.ac | 1 + c/src/ada-tests/samples/Makefile.am | 4 +- c/src/ada-tests/samples/nsecs/.cvsignore | 2 + c/src/ada-tests/samples/nsecs/Makefile.am | 21 ++++ c/src/ada-tests/samples/nsecs/config.h | 34 +++++++ c/src/ada-tests/samples/nsecs/nsecs.adb | 55 +++++++++++ c/src/ada-tests/samples/nsecs/nsecs.scn | 27 ++++++ c/src/ada-tests/samples/nsecs/sptest.adb | 155 ++++++++++++++++++++++++++++++ c/src/ada-tests/samples/nsecs/sptest.ads | 39 ++++++++ 10 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 c/src/ada-tests/samples/nsecs/.cvsignore create mode 100644 c/src/ada-tests/samples/nsecs/Makefile.am create mode 100644 c/src/ada-tests/samples/nsecs/config.h create mode 100644 c/src/ada-tests/samples/nsecs/nsecs.adb create mode 100644 c/src/ada-tests/samples/nsecs/nsecs.scn create mode 100644 c/src/ada-tests/samples/nsecs/sptest.adb create mode 100644 c/src/ada-tests/samples/nsecs/sptest.ads (limited to 'c/src/ada-tests') diff --git a/c/src/ada-tests/ChangeLog b/c/src/ada-tests/ChangeLog index a1d22a0f8a..79871fe914 100644 --- a/c/src/ada-tests/ChangeLog +++ b/c/src/ada-tests/ChangeLog @@ -1,3 +1,11 @@ +2007-10-25 Glenn Humphrey + + * configure.ac, samples/Makefile.am: Added a test for Clock_Get_Uptime + * samples/nsecs/.cvsignore, samples/nsecs/Makefile.am, + samples/nsecs/config.h, samples/nsecs/nsecs.adb, + samples/nsecs/nsecs.scn, samples/nsecs/sptest.adb, + samples/nsecs/sptest.ads: New files. + 2007-10-18 Glenn Humphrey * sptests/sp16/sptest.ads, sptests/sp20/sptest.adb, diff --git a/c/src/ada-tests/configure.ac b/c/src/ada-tests/configure.ac index 1a79659b24..d27d0a17d5 100644 --- a/c/src/ada-tests/configure.ac +++ b/c/src/ada-tests/configure.ac @@ -48,6 +48,7 @@ samples/Makefile samples/base_sp/Makefile samples/hello/Makefile samples/ticker/Makefile +samples/nsecs/Makefile samples/base_mp/Makefile samples/base_mp/node1/Makefile samples/base_mp/node2/Makefile diff --git a/c/src/ada-tests/samples/Makefile.am b/c/src/ada-tests/samples/Makefile.am index 0154dc7c19..9079da44fb 100644 --- a/c/src/ada-tests/samples/Makefile.am +++ b/c/src/ada-tests/samples/Makefile.am @@ -1,11 +1,11 @@ ## $Id$ -SUBDIRS = hello ticker base_sp +SUBDIRS = hello ticker base_sp nsecs if HAS_MP SUBDIRS += base_mp endif -DIST_SUBDIRS = hello ticker base_sp base_mp +DIST_SUBDIRS = hello ticker base_sp base_mp nsecs include $(top_srcdir)/../../../testsuites/automake/subdirs.am include $(top_srcdir)/../../../testsuites/automake/local.am diff --git a/c/src/ada-tests/samples/nsecs/.cvsignore b/c/src/ada-tests/samples/nsecs/.cvsignore new file mode 100644 index 0000000000..282522db03 --- /dev/null +++ b/c/src/ada-tests/samples/nsecs/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/c/src/ada-tests/samples/nsecs/Makefile.am b/c/src/ada-tests/samples/nsecs/Makefile.am new file mode 100644 index 0000000000..0fbd6910dc --- /dev/null +++ b/c/src/ada-tests/samples/nsecs/Makefile.am @@ -0,0 +1,21 @@ +## $Id$ + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../../../testsuites/automake/compile.am + +include $(top_srcdir)/ada.am + +nsecs$(EXEEXT): nsecs.adb init.$(OBJEXT) + $(GNATCOMPILE) -margs -a $< -o $@ + +init.$(OBJEXT): ../../support/init.c + $(COMPILE.c) -I$(srcdir) -c $< + +noinst_PROGRAMS = nsecs + +nsecs_SOURCES = nsecs.adb config.h sptest.adb sptest.ads + +scndir = $(rtems_ada_testsdir) +dist_scn_DATA = nsecs.scn + +include $(top_srcdir)/../../../testsuites/automake/local.am diff --git a/c/src/ada-tests/samples/nsecs/config.h b/c/src/ada-tests/samples/nsecs/config.h new file mode 100644 index 0000000000..b14f7fc349 --- /dev/null +++ b/c/src/ada-tests/samples/nsecs/config.h @@ -0,0 +1,34 @@ +/* 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.com/license/LICENSE. + * + * $Id$ + */ + + +/* 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_POSIX_MUTEXES 20 +#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 10 + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#include + +/* end of include file */ diff --git a/c/src/ada-tests/samples/nsecs/nsecs.adb b/c/src/ada-tests/samples/nsecs/nsecs.adb new file mode 100644 index 0000000000..9e427d9ae7 --- /dev/null +++ b/c/src/ada-tests/samples/nsecs/nsecs.adb @@ -0,0 +1,55 @@ +-- +-- MAIN / BODY +-- +-- DESCRIPTION: +-- +-- This is the entry point for Test Nsecs of the Sample Test Suite. +-- +-- DEPENDENCIES: +-- +-- +-- +-- 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.com/license/LICENSE. +-- +-- $Id$ +-- + +with RTEMS; +with SPTEST; +with TEST_SUPPORT; + +procedure Nsecs is + INIT_ID : RTEMS.ID; + STATUS : RTEMS.STATUS_CODES; +begin + + RTEMS.TASK_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.TASK_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/c/src/ada-tests/samples/nsecs/nsecs.scn b/c/src/ada-tests/samples/nsecs/nsecs.scn new file mode 100644 index 0000000000..458f12c874 --- /dev/null +++ b/c/src/ada-tests/samples/nsecs/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/c/src/ada-tests/samples/nsecs/sptest.adb b/c/src/ada-tests/samples/nsecs/sptest.adb new file mode 100644 index 0000000000..12c61c1c21 --- /dev/null +++ b/c/src/ada-tests/samples/nsecs/sptest.adb @@ -0,0 +1,155 @@ +-- +-- SPTEST / BODY +-- +-- DESCRIPTION: +-- +-- This package is the implementation of the Nanosecond test of the +-- Sample Test Suite. +-- +-- DEPENDENCIES: +-- +-- +-- +-- 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.com/license/LICENSE. +-- +-- $Id$ +-- + +with Ada.Integer_Text_IO; +with Interfaces.C; +with RTEMS; +with Test_Support; +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; + + +--PAGE +-- +-- INIT +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASK_ARGUMENT + ) is + 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/c/src/ada-tests/samples/nsecs/sptest.ads b/c/src/ada-tests/samples/nsecs/sptest.ads new file mode 100644 index 0000000000..2911de9c6b --- /dev/null +++ b/c/src/ada-tests/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-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.com/license/LICENSE. +-- +-- $Id$ +-- + +with RTEMS; + +package SPTEST is + +-- +-- INIT +-- +-- DESCRIPTION: +-- +-- This RTEMS task initializes the application. +-- + + procedure INIT ( + ARGUMENT : in RTEMS.TASK_ARGUMENT + ); + +end SPTEST; -- cgit v1.2.3