forked from Imagelibrary/rtems
2007-10-25 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* 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.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2007-10-25 Glenn Humphrey <glenn.humphrey@OARcorp.com>
|
||||
|
||||
* 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 <glenn.humphrey@OARcorp.com>
|
||||
|
||||
* sptests/sp16/sptest.ads, sptests/sp20/sptest.adb,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
2
c/src/ada-tests/samples/nsecs/.cvsignore
Normal file
2
c/src/ada-tests/samples/nsecs/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
21
c/src/ada-tests/samples/nsecs/Makefile.am
Normal file
21
c/src/ada-tests/samples/nsecs/Makefile.am
Normal file
@@ -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
|
||||
34
c/src/ada-tests/samples/nsecs/config.h
Normal file
34
c/src/ada-tests/samples/nsecs/config.h
Normal file
@@ -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 <rtems/confdefs.h>
|
||||
|
||||
/* end of include file */
|
||||
55
c/src/ada-tests/samples/nsecs/nsecs.adb
Normal file
55
c/src/ada-tests/samples/nsecs/nsecs.adb
Normal file
@@ -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;
|
||||
|
||||
27
c/src/ada-tests/samples/nsecs/nsecs.scn
Normal file
27
c/src/ada-tests/samples/nsecs/nsecs.scn
Normal file
@@ -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 ***
|
||||
155
c/src/ada-tests/samples/nsecs/sptest.adb
Normal file
155
c/src/ada-tests/samples/nsecs/sptest.adb
Normal file
@@ -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;
|
||||
39
c/src/ada-tests/samples/nsecs/sptest.ads
Normal file
39
c/src/ada-tests/samples/nsecs/sptest.ads
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user