annotate gcc/testsuite/ada/acats/tests/c9/c954011.a @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 -- C954011.A
kono
parents:
diff changeset
2 --
kono
parents:
diff changeset
3 -- Grant of Unlimited Rights
kono
parents:
diff changeset
4 --
kono
parents:
diff changeset
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
7 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
9 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
10 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
11 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
12 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
13 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
14 -- to do so.
kono
parents:
diff changeset
15 --
kono
parents:
diff changeset
16 -- DISCLAIMER
kono
parents:
diff changeset
17 --
kono
parents:
diff changeset
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
24 --*
kono
parents:
diff changeset
25 --
kono
parents:
diff changeset
26 -- OBJECTIVE:
kono
parents:
diff changeset
27 -- Check that a requeue is placed on the correct entry; that the
kono
parents:
diff changeset
28 -- original caller waits for the completion of the requeued rendezvous;
kono
parents:
diff changeset
29 -- that the original caller continues after the rendezvous.
kono
parents:
diff changeset
30 -- Specifically, this test checks requeue to an entry in a different
kono
parents:
diff changeset
31 -- task, requeue where the entry has parameters, and requeue with
kono
parents:
diff changeset
32 -- abort.
kono
parents:
diff changeset
33 --
kono
parents:
diff changeset
34 -- TEST DESCRIPTION:
kono
parents:
diff changeset
35 -- In the Distributor task, requeue two successive calls on the entries
kono
parents:
diff changeset
36 -- of two separate target tasks. Each task in each of the paths adds
kono
parents:
diff changeset
37 -- identifying information in the transaction being passed. This
kono
parents:
diff changeset
38 -- information is checked by the Message tasks on completion ensuring that
kono
parents:
diff changeset
39 -- the requeues have been placed on the correct queues.
kono
parents:
diff changeset
40 --
kono
parents:
diff changeset
41 -- This series of tests uses a simulation of a transaction driven
kono
parents:
diff changeset
42 -- processing system. Line Drivers accept input from an external source
kono
parents:
diff changeset
43 -- and build them into transaction records. These records are then
kono
parents:
diff changeset
44 -- encapsulated in message tasks which remain extant for the life of the
kono
parents:
diff changeset
45 -- transaction in the system. The message tasks put themselves on the
kono
parents:
diff changeset
46 -- input queue of a Distributor which, from information in the
kono
parents:
diff changeset
47 -- transaction and/or system load conditions forwards them to other
kono
parents:
diff changeset
48 -- operating tasks. These in turn might forward the transactions to yet
kono
parents:
diff changeset
49 -- other tasks for further action. The routing is, in real life,
kono
parents:
diff changeset
50 -- dynamic and unpredictable at the time of message generation. All
kono
parents:
diff changeset
51 -- rerouting in this model is done by means of requeues.
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 --
kono
parents:
diff changeset
54 -- CHANGE HISTORY:
kono
parents:
diff changeset
55 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
56 -- 26 Nov 95 SAIC Fixed problems with shared global variables
kono
parents:
diff changeset
57 -- for ACVC 2.0.1
kono
parents:
diff changeset
58 --
kono
parents:
diff changeset
59 --!
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 with Report;
kono
parents:
diff changeset
62 with ImpDef;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 procedure C954011 is
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- Arbitrary test values
kono
parents:
diff changeset
68 Credit_Return : constant := 1;
kono
parents:
diff changeset
69 Debit_Return : constant := 2;
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 type Transaction_Code is (Credit, Debit);
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 type Transaction_Record;
kono
parents:
diff changeset
74 type acc_Transaction_Record is access Transaction_Record;
kono
parents:
diff changeset
75 type Transaction_Record is
kono
parents:
diff changeset
76 record
kono
parents:
diff changeset
77 ID : integer := 0;
kono
parents:
diff changeset
78 Code : Transaction_Code := Debit;
kono
parents:
diff changeset
79 Account_Number : integer := 0;
kono
parents:
diff changeset
80 Stock_Number : integer := 0;
kono
parents:
diff changeset
81 Quantity : integer := 0;
kono
parents:
diff changeset
82 Return_Value : integer := 0;
kono
parents:
diff changeset
83 TC_Message_Count : integer := 0;
kono
parents:
diff changeset
84 TC_Thru_Distrib : Boolean := false;
kono
parents:
diff changeset
85 end record;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 protected type Message_Mgr is
kono
parents:
diff changeset
88 procedure Mark_Complete;
kono
parents:
diff changeset
89 function Is_Complete return Boolean;
kono
parents:
diff changeset
90 private
kono
parents:
diff changeset
91 Complete : Boolean := False;
kono
parents:
diff changeset
92 end Message_Mgr;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 protected body Message_Mgr is
kono
parents:
diff changeset
95 procedure Mark_Complete is
kono
parents:
diff changeset
96 begin
kono
parents:
diff changeset
97 Complete := True;
kono
parents:
diff changeset
98 end Mark_Complete;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 Function Is_Complete return Boolean is
kono
parents:
diff changeset
101 begin
kono
parents:
diff changeset
102 return Complete;
kono
parents:
diff changeset
103 end Is_Complete;
kono
parents:
diff changeset
104 end Message_Mgr;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 TC_Debit_Message : Message_Mgr;
kono
parents:
diff changeset
107 TC_Credit_Message : Message_Mgr;
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 task type Message_Task is
kono
parents:
diff changeset
111 entry Accept_Transaction (In_Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
112 end Message_Task;
kono
parents:
diff changeset
113 type acc_Message_Task is access Message_Task;
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 task Line_Driver is
kono
parents:
diff changeset
116 entry Start;
kono
parents:
diff changeset
117 end Line_Driver;
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 task Distributor is
kono
parents:
diff changeset
120 entry Input(Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
121 end Distributor;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 task Credit_Computation is
kono
parents:
diff changeset
124 entry Input(Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
125 end Credit_Computation;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 task Debit_Computation is
kono
parents:
diff changeset
128 entry Input(Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
129 end Debit_Computation;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 -- Assemble messages received from an external source
kono
parents:
diff changeset
134 -- Creates a message task for each. The message tasks remain extant
kono
parents:
diff changeset
135 -- for the life of the messages in the system.
kono
parents:
diff changeset
136 -- The Line Driver task would normally be designed to loop continuously
kono
parents:
diff changeset
137 -- creating the messages as input is received. Simulate this
kono
parents:
diff changeset
138 -- but limit it to two dummy messages for this test and allow it
kono
parents:
diff changeset
139 -- to terminate at that point
kono
parents:
diff changeset
140 --
kono
parents:
diff changeset
141 task body Line_Driver is
kono
parents:
diff changeset
142 Current_ID : integer := 1;
kono
parents:
diff changeset
143 TC_Last_was_for_credit : Boolean := false;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Build_Credit_Record
kono
parents:
diff changeset
146 ( Next_Transaction : acc_Transaction_Record ) is
kono
parents:
diff changeset
147 Dummy_Account : constant integer := 100;
kono
parents:
diff changeset
148 begin
kono
parents:
diff changeset
149 Next_Transaction.ID := Current_ID;
kono
parents:
diff changeset
150 Next_Transaction.Code := Credit;
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 Next_Transaction.Account_Number := Dummy_Account;
kono
parents:
diff changeset
153 Current_ID := Current_ID + 1;
kono
parents:
diff changeset
154 end Build_Credit_Record;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 procedure Build_Debit_Record
kono
parents:
diff changeset
158 ( Next_Transaction : acc_Transaction_Record ) is
kono
parents:
diff changeset
159 Dummy_Account : constant integer := 200;
kono
parents:
diff changeset
160 begin
kono
parents:
diff changeset
161 Next_Transaction.ID := Current_ID;
kono
parents:
diff changeset
162 Next_Transaction.Code := Debit;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 Next_Transaction.Account_Number := Dummy_Account;
kono
parents:
diff changeset
165 Current_ID := Current_ID + 1;
kono
parents:
diff changeset
166 end Build_Debit_Record;
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 begin
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 accept Start; -- Wait for trigger from Main
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 for i in 1..2 loop -- arbitrarily limit to two messages for the test
kono
parents:
diff changeset
173 declare
kono
parents:
diff changeset
174 -- Create a task for the next message
kono
parents:
diff changeset
175 Next_Message_Task : acc_Message_Task := new Message_Task;
kono
parents:
diff changeset
176 -- Create a record for it
kono
parents:
diff changeset
177 Next_Transaction : acc_Transaction_Record
kono
parents:
diff changeset
178 := new Transaction_Record;
kono
parents:
diff changeset
179 begin
kono
parents:
diff changeset
180 if TC_Last_was_for_credit then
kono
parents:
diff changeset
181 Build_Debit_Record ( Next_Transaction );
kono
parents:
diff changeset
182 else
kono
parents:
diff changeset
183 Build_Credit_Record( Next_Transaction );
kono
parents:
diff changeset
184 TC_Last_was_for_credit := true;
kono
parents:
diff changeset
185 end if;
kono
parents:
diff changeset
186 Next_Message_Task.Accept_Transaction ( Next_Transaction );
kono
parents:
diff changeset
187 end; -- declare
kono
parents:
diff changeset
188 end loop;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 exception
kono
parents:
diff changeset
191 when others =>
kono
parents:
diff changeset
192 Report.Failed ("Unexpected exception in Line_Driver");
kono
parents:
diff changeset
193 end Line_Driver;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 task body Message_Task is
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 TC_Original_Transaction_Code : Transaction_Code;
kono
parents:
diff changeset
201 This_Transaction : acc_Transaction_Record := new Transaction_Record;
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 begin
kono
parents:
diff changeset
204 accept Accept_Transaction (In_Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
205 This_Transaction.all := In_Transaction.all;
kono
parents:
diff changeset
206 end Accept_Transaction;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 -- Note the original code to ensure correct return
kono
parents:
diff changeset
209 TC_Original_Transaction_Code := This_Transaction.Code;
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 -- Queue up on Distributor's Input queue
kono
parents:
diff changeset
212 Distributor.Input ( This_Transaction );
kono
parents:
diff changeset
213 -- This task will now wait for the requeued rendezvous
kono
parents:
diff changeset
214 -- to complete before proceeding
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 -- After the required computations have been performed
kono
parents:
diff changeset
217 -- return the Transaction_Record appropriately (probably to an output
kono
parents:
diff changeset
218 -- line driver)
kono
parents:
diff changeset
219 null; -- stub
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 -- The following is all Test Control Code
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 -- Check that the return values are as expected
kono
parents:
diff changeset
225 if TC_Original_Transaction_Code /= This_Transaction.Code then
kono
parents:
diff changeset
226 -- Incorrect rendezvous
kono
parents:
diff changeset
227 Report.Failed ("Message Task: Incorrect code returned");
kono
parents:
diff changeset
228 end if;
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 if This_Transaction.Code = Credit then
kono
parents:
diff changeset
231 if This_Transaction.Return_Value /= Credit_Return or
kono
parents:
diff changeset
232 This_Transaction.TC_Message_Count /= 1 or not
kono
parents:
diff changeset
233 This_Transaction.TC_Thru_Distrib then
kono
parents:
diff changeset
234 Report.Failed ("Expected path not traversed");
kono
parents:
diff changeset
235 end if;
kono
parents:
diff changeset
236 TC_Credit_Message.Mark_Complete;
kono
parents:
diff changeset
237 else
kono
parents:
diff changeset
238 if This_Transaction.Return_Value /= Debit_Return or
kono
parents:
diff changeset
239 This_Transaction.TC_Message_Count /= 1 or not
kono
parents:
diff changeset
240 This_Transaction.TC_Thru_Distrib then
kono
parents:
diff changeset
241 Report.Failed ("Expected path not traversed");
kono
parents:
diff changeset
242 end if;
kono
parents:
diff changeset
243 TC_Debit_Message.Mark_Complete;
kono
parents:
diff changeset
244 end if;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 exception
kono
parents:
diff changeset
247 when others =>
kono
parents:
diff changeset
248 Report.Failed ("Unexpected exception in Message_Task");
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 end Message_Task;
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 -- Dispose each input Transaction_Record to the appropriate
kono
parents:
diff changeset
255 -- computation tasks
kono
parents:
diff changeset
256 --
kono
parents:
diff changeset
257 task body Distributor is
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 begin
kono
parents:
diff changeset
260 loop
kono
parents:
diff changeset
261 select
kono
parents:
diff changeset
262 accept Input (Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
263 -- Mark the message as having passed through the distributor
kono
parents:
diff changeset
264 Transaction.TC_Thru_Distrib := true;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 -- Pass this transaction on the appropriate computation
kono
parents:
diff changeset
267 -- task
kono
parents:
diff changeset
268 case Transaction.Code is
kono
parents:
diff changeset
269 when Credit =>
kono
parents:
diff changeset
270 requeue Credit_Computation.Input with abort;
kono
parents:
diff changeset
271 when Debit =>
kono
parents:
diff changeset
272 requeue Debit_Computation.Input with abort;
kono
parents:
diff changeset
273 end case;
kono
parents:
diff changeset
274 end Input;
kono
parents:
diff changeset
275 or
kono
parents:
diff changeset
276 terminate;
kono
parents:
diff changeset
277 end select;
kono
parents:
diff changeset
278 end loop;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 exception
kono
parents:
diff changeset
281 when others =>
kono
parents:
diff changeset
282 Report.Failed ("Unexpected exception in Distributor");
kono
parents:
diff changeset
283 end Distributor;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 -- Computation task.
kono
parents:
diff changeset
288 -- Note: After the computation is performed in this task and the
kono
parents:
diff changeset
289 -- accept body is completed the rendezvous in the original
kono
parents:
diff changeset
290 -- message task is completed.
kono
parents:
diff changeset
291 --
kono
parents:
diff changeset
292 task body Credit_Computation is
kono
parents:
diff changeset
293 Message_Count : integer := 0;
kono
parents:
diff changeset
294 begin
kono
parents:
diff changeset
295 loop
kono
parents:
diff changeset
296 select
kono
parents:
diff changeset
297 accept Input ( Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
298 -- Perform the computations required for this transaction
kono
parents:
diff changeset
299 null; -- stub
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 -- For the test:
kono
parents:
diff changeset
302 if not Transaction.TC_Thru_Distrib then
kono
parents:
diff changeset
303 Report.Failed
kono
parents:
diff changeset
304 ("Credit Task: Wrong queue, Distributor bypassed");
kono
parents:
diff changeset
305 end if;
kono
parents:
diff changeset
306 if Transaction.code /= Credit then
kono
parents:
diff changeset
307 Report.Failed
kono
parents:
diff changeset
308 ("Credit Task: Requeue delivered to the wrong queue");
kono
parents:
diff changeset
309 end if;
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 -- for the test plug a known value and count
kono
parents:
diff changeset
312 Transaction.Return_Value := Credit_Return;
kono
parents:
diff changeset
313 -- one, and only one message should pass through
kono
parents:
diff changeset
314 Message_Count := Message_Count + 1;
kono
parents:
diff changeset
315 Transaction.TC_Message_Count := Message_Count;
kono
parents:
diff changeset
316 end Input;
kono
parents:
diff changeset
317 or
kono
parents:
diff changeset
318 terminate;
kono
parents:
diff changeset
319 end select;
kono
parents:
diff changeset
320 end loop;
kono
parents:
diff changeset
321 exception
kono
parents:
diff changeset
322 when others =>
kono
parents:
diff changeset
323 Report.Failed ("Unexpected exception in Credit_Computation");
kono
parents:
diff changeset
324 end Credit_Computation;
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 -- Computation task.
kono
parents:
diff changeset
329 -- Note: After the computation is performed in this task and the
kono
parents:
diff changeset
330 -- accept body is completed the rendezvous in the original
kono
parents:
diff changeset
331 -- message task is completed.
kono
parents:
diff changeset
332 --
kono
parents:
diff changeset
333 task body Debit_Computation is
kono
parents:
diff changeset
334 Message_Count : integer := 0;
kono
parents:
diff changeset
335 begin
kono
parents:
diff changeset
336 loop
kono
parents:
diff changeset
337 select
kono
parents:
diff changeset
338 accept Input (Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
339 -- Perform the computations required for this message
kono
parents:
diff changeset
340 null; -- stub
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 -- For the test:
kono
parents:
diff changeset
343 if not Transaction.TC_Thru_Distrib then
kono
parents:
diff changeset
344 Report.Failed
kono
parents:
diff changeset
345 ("Debit Task: Wrong queue, Distributor bypassed");
kono
parents:
diff changeset
346 end if;
kono
parents:
diff changeset
347 if Transaction.code /= Debit then
kono
parents:
diff changeset
348 Report.Failed
kono
parents:
diff changeset
349 ("Debit Task: Requeue delivered to the wrong queue");
kono
parents:
diff changeset
350 end if;
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 -- for the test plug a known value and count
kono
parents:
diff changeset
353 Transaction.Return_Value := Debit_Return;
kono
parents:
diff changeset
354 -- one, and only one, message should pass through
kono
parents:
diff changeset
355 Message_Count := Message_Count + 1;
kono
parents:
diff changeset
356 Transaction.TC_Message_Count := Message_Count;
kono
parents:
diff changeset
357 end Input;
kono
parents:
diff changeset
358 or
kono
parents:
diff changeset
359 terminate;
kono
parents:
diff changeset
360 end select;
kono
parents:
diff changeset
361 end loop;
kono
parents:
diff changeset
362 exception
kono
parents:
diff changeset
363 when others =>
kono
parents:
diff changeset
364 Report.Failed ("Unexpected exception in Debit_Computation");
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 end Debit_Computation;
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 begin -- c954011
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 Report.Test ("C954011", "Requeue from task body to task entry");
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 Line_Driver.Start; -- Start the test
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 -- Ensure that the message tasks complete before reporting the result
kono
parents:
diff changeset
377 while not (TC_Credit_Message.Is_Complete and
kono
parents:
diff changeset
378 TC_Debit_Message.Is_Complete) loop
kono
parents:
diff changeset
379 delay ImpDef.Minimum_Task_Switch;
kono
parents:
diff changeset
380 end loop;
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 Report.Result;
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 end C954011;