| 1 |
294 |
jeremybenn |
-- C960002.A
|
| 2 |
|
|
--
|
| 3 |
|
|
-- Grant of Unlimited Rights
|
| 4 |
|
|
--
|
| 5 |
|
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
| 6 |
|
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
| 7 |
|
|
-- unlimited rights in the software and documentation contained herein.
|
| 8 |
|
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
| 9 |
|
|
-- this public release, the Government intends to confer upon all
|
| 10 |
|
|
-- recipients unlimited rights equal to those held by the Government.
|
| 11 |
|
|
-- These rights include rights to use, duplicate, release or disclose the
|
| 12 |
|
|
-- released technical data and computer software in whole or in part, in
|
| 13 |
|
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
| 14 |
|
|
-- to do so.
|
| 15 |
|
|
--
|
| 16 |
|
|
-- DISCLAIMER
|
| 17 |
|
|
--
|
| 18 |
|
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
| 19 |
|
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
| 20 |
|
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
| 21 |
|
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
| 22 |
|
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
| 23 |
|
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
| 24 |
|
|
--*
|
| 25 |
|
|
--
|
| 26 |
|
|
-- OBJECTIVE:
|
| 27 |
|
|
-- Check that the simple "delay until" when the request time is "now" and
|
| 28 |
|
|
-- also some time already in the past is obeyed and returns immediately
|
| 29 |
|
|
--
|
| 30 |
|
|
-- TEST DESCRIPTION:
|
| 31 |
|
|
-- Simulate a task that sends a "pulse" at regular intervals. The Delay
|
| 32 |
|
|
-- Until statement is used to avoid accumulated drift. In this test
|
| 33 |
|
|
-- three simple situations simulating the start of drift are used: the
|
| 34 |
|
|
-- next pulse being called for at the normal time, the next pulse being
|
| 35 |
|
|
-- called for at exactly the current time and then at some time which has
|
| 36 |
|
|
-- already past. We assume the delay is within a While Loop and, to
|
| 37 |
|
|
-- simplify the test, we "unfold" the While Loop and execute the Delays
|
| 38 |
|
|
-- in a serial fashion. This loop is shown in test C960001.
|
| 39 |
|
|
-- It is not possible to test the actual immediacy of the expiration. We
|
| 40 |
|
|
-- can only check that it returns in a "reasonable" time. In this case
|
| 41 |
|
|
-- we check that it expires before the next "pulse" should have been
|
| 42 |
|
|
-- issued.
|
| 43 |
|
|
--
|
| 44 |
|
|
--
|
| 45 |
|
|
-- CHANGE HISTORY:
|
| 46 |
|
|
-- 06 Dec 94 SAIC ACVC 2.0
|
| 47 |
|
|
--
|
| 48 |
|
|
--!
|
| 49 |
|
|
|
| 50 |
|
|
with Report;
|
| 51 |
|
|
with ImpDef;
|
| 52 |
|
|
|
| 53 |
|
|
with Ada.Calendar;
|
| 54 |
|
|
with System;
|
| 55 |
|
|
|
| 56 |
|
|
procedure C960002 is
|
| 57 |
|
|
|
| 58 |
|
|
begin
|
| 59 |
|
|
|
| 60 |
|
|
Report.Test ("C960002", "Simple Delay Until with requested time being" &
|
| 61 |
|
|
" ""now"" and time already in the past");
|
| 62 |
|
|
|
| 63 |
|
|
declare -- To get the Report.Result after all has completed
|
| 64 |
|
|
|
| 65 |
|
|
function "+" (Left : Ada.Calendar.Time; Right: Duration)
|
| 66 |
|
|
return Ada.Calendar.Time renames Ada.Calendar."+";
|
| 67 |
|
|
function "-" (Left : Ada.Calendar.Time; Right: Duration)
|
| 68 |
|
|
return Ada.Calendar.Time renames Ada.Calendar."-";
|
| 69 |
|
|
function "-" (Left, Right : Ada.Calendar.Time)
|
| 70 |
|
|
return duration renames Ada.Calendar."-";
|
| 71 |
|
|
function ">" (Left, Right : Ada.Calendar.Time)
|
| 72 |
|
|
return Boolean renames Ada.Calendar.">";
|
| 73 |
|
|
|
| 74 |
|
|
|
| 75 |
|
|
task Pulse_Task is
|
| 76 |
|
|
entry Trigger;
|
| 77 |
|
|
end Pulse_Task;
|
| 78 |
|
|
|
| 79 |
|
|
|
| 80 |
|
|
-- Task to synchronize all qualified receivers.
|
| 81 |
|
|
-- The entry Trigger starts the synchronization.
|
| 82 |
|
|
--
|
| 83 |
|
|
task body Pulse_Task is
|
| 84 |
|
|
Pulse_Time : Ada.Calendar.Time;
|
| 85 |
|
|
Pulse_Time_Delta : constant duration := ImpDef.Clear_Ready_Queue;
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
TC_Time_Back : Ada.Calendar.Time;
|
| 90 |
|
|
|
| 91 |
|
|
|
| 92 |
|
|
-- This routine transmits a synchronizing "pulse" to
|
| 93 |
|
|
-- all receivers
|
| 94 |
|
|
procedure Pulse is
|
| 95 |
|
|
begin
|
| 96 |
|
|
null; -- Stub
|
| 97 |
|
|
Report.Comment (".......PULSE........");
|
| 98 |
|
|
end Pulse;
|
| 99 |
|
|
|
| 100 |
|
|
begin
|
| 101 |
|
|
accept Trigger;
|
| 102 |
|
|
Pulse;
|
| 103 |
|
|
---------------
|
| 104 |
|
|
-- normal calculation for "next"
|
| 105 |
|
|
Pulse_Time := Ada.Calendar.Clock + Pulse_Time_Delta;
|
| 106 |
|
|
|
| 107 |
|
|
-- TC: unfold the "while" loop in C960001. Four passes through
|
| 108 |
|
|
-- the loop are shown
|
| 109 |
|
|
|
| 110 |
|
|
delay until Pulse_Time;
|
| 111 |
|
|
|
| 112 |
|
|
Pulse;
|
| 113 |
|
|
---------------
|
| 114 |
|
|
-- TC: the normal calculation for "next" would be
|
| 115 |
|
|
-- Pulse_Time := Pulse_Time + Pulse_Time_Delta;
|
| 116 |
|
|
-- Instead of this normal pulse time calculation simulate
|
| 117 |
|
|
-- the new pulse time to be exactly "now" (or, as exactly as
|
| 118 |
|
|
-- we can)
|
| 119 |
|
|
Pulse_Time := Ada.Calendar.Clock;
|
| 120 |
|
|
delay until Ada.Calendar.Clock;
|
| 121 |
|
|
|
| 122 |
|
|
TC_Time_Back := Ada.Calendar.Clock;
|
| 123 |
|
|
|
| 124 |
|
|
-- Now check for reasonableness
|
| 125 |
|
|
if TC_Time_Back > Pulse_Time + Pulse_Time_Delta then
|
| 126 |
|
|
Report.Failed
|
| 127 |
|
|
("""Now"" delayed for more than Pulse_Time_Delta - A");
|
| 128 |
|
|
end if;
|
| 129 |
|
|
Pulse;
|
| 130 |
|
|
---------------
|
| 131 |
|
|
-- normal calculation for "next" would be
|
| 132 |
|
|
Pulse_Time := Pulse_Time + Pulse_Time_Delta;
|
| 133 |
|
|
|
| 134 |
|
|
-- TC: Instead of this, simulate the new calculated pulse time
|
| 135 |
|
|
-- being already past
|
| 136 |
|
|
Pulse_Time := Ada.Calendar.Clock - System.Tick;
|
| 137 |
|
|
delay until Pulse_Time;
|
| 138 |
|
|
|
| 139 |
|
|
TC_Time_Back := Ada.Calendar.Clock;
|
| 140 |
|
|
|
| 141 |
|
|
-- Now check for reasonableness
|
| 142 |
|
|
if TC_Time_Back > Pulse_Time + Pulse_Time_Delta then
|
| 143 |
|
|
Report.Failed
|
| 144 |
|
|
("""Now"" delayed for more than Pulse_Time_Delta - B");
|
| 145 |
|
|
end if;
|
| 146 |
|
|
Pulse;
|
| 147 |
|
|
---------------
|
| 148 |
|
|
-- normal calculation for "next"
|
| 149 |
|
|
Pulse_Time := Pulse_Time + Pulse_Time_Delta;
|
| 150 |
|
|
-- Now simulate getting back into synch
|
| 151 |
|
|
delay until Pulse_Time;
|
| 152 |
|
|
Pulse;
|
| 153 |
|
|
---------------
|
| 154 |
|
|
-- This would be the end of the "while" loop
|
| 155 |
|
|
|
| 156 |
|
|
exception
|
| 157 |
|
|
when others =>
|
| 158 |
|
|
Report.Failed ("Unexpected exception in Pulse_Task");
|
| 159 |
|
|
end Pulse_Task;
|
| 160 |
|
|
|
| 161 |
|
|
|
| 162 |
|
|
|
| 163 |
|
|
begin -- declare
|
| 164 |
|
|
|
| 165 |
|
|
Pulse_Task.Trigger; -- Start test
|
| 166 |
|
|
|
| 167 |
|
|
end; -- declare
|
| 168 |
|
|
|
| 169 |
|
|
Report.Result;
|
| 170 |
|
|
|
| 171 |
|
|
end C960002;
|