OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c9/] [c960004.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- C960004.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
--      With the triggering statement being a delay and with the Asynchronous
28
--      Select statement being in a tasking situation complete the abortable
29
--      part before the delay expires.  Check that the delay is cancelled
30
--      and that the optional statements in the triggering part are not
31
--      executed.
32
--
33
-- TEST DESCRIPTION:
34
--      Simulate the creation of a carrier task to control the output of
35
--      a message via a line driver.  If the message sending process is
36
--      not complete (the completion of the rendezvous) within a
37
--      specified time the carrier task is designed to take corrective action.
38
--      Use an asynchronous select to control the timing; arrange that
39
--      the abortable part (the rendezvous) completes almost immediately.
40
--      Check that the optional statements are not executed and that the
41
--      test completes well before the time of the trigger delay request thus
42
--      showing that it has been cancelled.
43
--
44
--
45
-- CHANGE HISTORY:
46
--      06 Dec 94   SAIC    ACVC 2.0
47
--
48
--!
49
 
50
 
51
with Report;
52
with Ada.Calendar;
53
 
54
procedure C960004 is
55
 
56
   function "-" (Left, Right : Ada.Calendar.Time)
57
                                    return Duration  renames Ada.Calendar."-";
58
   TC_Start_Time      : Ada.Calendar.Time := Ada.Calendar.Clock;
59
   TC_Elapsed_Time    : duration;
60
 
61
   -- Note: a properly executing test will complete immediately.
62
   Allowable_ACK_Time : duration := 600.0;
63
 
64
begin
65
 
66
   Report.Test ("C960004", "ATC: When abortable part completes before " &
67
                             "a triggering delay, check that the delay " &
68
                             "is cancelled & optional statements " &
69
                             "are not performed. Tasking situation");
70
 
71
   declare  -- To get the Report.Result after all has completed
72
 
73
      type Sequence_Number is range 1..1_999_999;   -- Message Number
74
      subtype S_length_subtype  is integer range 1..80;
75
 
76
      type Message_Type (Max_String : S_length_subtype := 1) is
77
         record
78
            Message_Number    : Sequence_Number;
79
            Alpha             : string(1..Max_String);
80
         end record;
81
 
82
      -- TC:  Dummy message for the test
83
      Dummy_Alpha     : constant string := "This could be printed";
84
      Message_to_Send : Message_Type (Max_string => Dummy_Alpha'length);
85
 
86
 
87
      -- This is the carrier task.  One of these is created for each
88
      -- message that requires ACK
89
      --
90
      task type Require_ACK_task is
91
         entry Message_In (Message_to_Send: Message_Type);
92
      end Require_ACK_task;
93
      type acc_Require_ACK_task is access Require_ACK_task;
94
 
95
 
96
      --:::::::::::::::::::::::::::::::::
97
      -- There would also be another task type "No_ACK_Task" which would
98
      -- be the carrier task for those messages not requiring an ACK.
99
      -- This task would call Send_Message.ACK_Not_Required.  It is not
100
      -- shown in this test as it is not used.
101
      --:::::::::::::::::::::::::::::::::
102
 
103
 
104
 
105
      task Send_Message is
106
         entry ACK_Required     (Message_to_Send: Message_Type);
107
         entry ACK_Not_Required (Message_to_Send: Message_Type);
108
      end Send_Message;
109
 
110
 
111
      -- This is the carrier task.  One of these is created for each
112
      -- message that requires ACK
113
      --
114
      task body Require_ACK_task is
115
         Hold_Message : Message_Type;
116
 
117
         procedure Time_Out (Failed_Message_Number : Sequence_Number) is
118
         begin
119
            -- Take remedial action on the timed-out message
120
            null;    -- stub
121
 
122
            Report.Failed ("Optional statements in triggering part" &
123
                                    " were performed");
124
         end Time_out;
125
 
126
      begin
127
         accept Message_In (Message_to_Send: Message_Type) do
128
            Hold_Message := Message_to_Send;    -- to release caller
129
         end Message_In;
130
 
131
         -- Now put the message out to the Send_Message task and
132
         -- wait (no more than Allowable_Ack_Time) for its completion
133
         --
134
         select
135
            delay Allowable_ACK_Time;
136
            -- ACK not received in specified time
137
            Time_out (Hold_Message.Message_Number);
138
         then abort
139
            -- If the rendezvous is not completed in the above time, this
140
            -- call is cancelled
141
            --    Note: for this test this call will complete immediately
142
            --          and thus the trigger should be cancelled
143
            Send_Message.ACK_Required (Hold_Message);
144
         end select;
145
 
146
      exception
147
         when others =>
148
               Report.Failed ("Unexpected exception in Require_ACK_task");
149
      end Require_ACK_task;
150
 
151
 
152
      -- This is the Line Driver task
153
      --
154
      task body Send_Message is
155
         Hold_Non_ACK_Message : Message_Type;
156
      begin
157
         loop
158
            select
159
               accept ACK_Required (Message_to_Send: Message_Type) do
160
                  -- Here send the message from within the rendezvous
161
                  -- waiting for full transmission to complete
162
                  null;  -- stub
163
                  -- Note: In this test this accept will complete immediately
164
               end ACK_Required;
165
            or
166
               accept ACK_Not_Required (Message_to_Send: Message_Type) do
167
                  Hold_Non_ACK_Message := Message_to_Send;
168
               end ACK_Not_Required;
169
               -- Here send the message from outside the rendezvous
170
               null;  -- stub
171
            or
172
               terminate;
173
            end select;
174
         end loop;
175
      exception
176
         when others => Report.Failed ("Unexpected exception in Send_Message");
177
      end Send_Message;
178
 
179
   begin -- declare
180
      -- Build a dummy message
181
      Message_to_Send.Alpha          := Dummy_Alpha;
182
      Message_to_Send.Message_Number := 110_693;
183
 
184
      declare
185
         New_Require_ACK_task : acc_Require_ACK_task :=
186
                                             new Require_ACK_task;
187
      begin
188
         -- Create a carrier task for this message and pass the latter in
189
         New_Require_ACK_task.Message_In (Message_to_Send);
190
      end; -- declare
191
 
192
   end; -- declare
193
 
194
   --Once we are out of the above declarative region, all tasks have completed
195
 
196
   TC_Elapsed_Time := Ada.Calendar.Clock - TC_Start_Time;
197
 
198
   -- Check that the test has completed well before the time of the requested
199
   -- delay to ensure the delay was cancelled
200
   --
201
   if (TC_Elapsed_Time > Allowable_ACK_Time/2) then
202
      Report.Failed ("Triggering delay statement was not cancelled");
203
   end if;
204
 
205
   Report.Result;
206
end C960004;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.