annotate gcc/testsuite/ada/acats/tests/c9/c954021.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 -- C954021.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 within a protected entry to an entry in a
kono
parents:
diff changeset
28 -- different protected object is queued correctly.
kono
parents:
diff changeset
29 --
kono
parents:
diff changeset
30 -- TEST DESCRIPTION:
kono
parents:
diff changeset
31 -- One transaction is sent through to check the paths. After processing
kono
parents:
diff changeset
32 -- this the Credit task sets the "overloaded" indicator. Once this
kono
parents:
diff changeset
33 -- indicator is set the Distributor (a protected object) queues low
kono
parents:
diff changeset
34 -- priority transactions on a Wait_for_Underload queue in another
kono
parents:
diff changeset
35 -- protected object using a requeue. The Distributor still delivers high
kono
parents:
diff changeset
36 -- priority transactions. After two high priority transactions have been
kono
parents:
diff changeset
37 -- processed by the Credit task it clears the overload condition. The
kono
parents:
diff changeset
38 -- low priority transactions should now be delivered.
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 -- This series of tests uses a simulation of a transaction driven
kono
parents:
diff changeset
41 -- processing system. Line Drivers accept input from an external source
kono
parents:
diff changeset
42 -- and build them into transaction records. These records are then
kono
parents:
diff changeset
43 -- encapsulated in message tasks which remain extant for the life of the
kono
parents:
diff changeset
44 -- transaction in the system. The message tasks put themselves on the
kono
parents:
diff changeset
45 -- input queue of a Distributor which, from information in the
kono
parents:
diff changeset
46 -- transaction and/or system load conditions forwards them to other
kono
parents:
diff changeset
47 -- operating tasks. These in turn might forward the transactions to yet
kono
parents:
diff changeset
48 -- other tasks for further action. The routing is, in real life, dynamic
kono
parents:
diff changeset
49 -- and unpredictable at the time of message generation. All rerouting in
kono
parents:
diff changeset
50 -- this model is done by means of requeues.
kono
parents:
diff changeset
51 --
kono
parents:
diff changeset
52 --
kono
parents:
diff changeset
53 -- CHANGE HISTORY:
kono
parents:
diff changeset
54 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
55 -- 26 Nov 95 SAIC Fixed shared global variable for ACVC 2.0.1
kono
parents:
diff changeset
56 --
kono
parents:
diff changeset
57 --!
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 with Report;
kono
parents:
diff changeset
60 with ImpDef;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 procedure C954021 is
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- Arbitrary test values
kono
parents:
diff changeset
65 Credit_Return : constant := 1;
kono
parents:
diff changeset
66 Debit_Return : constant := 2;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 -- Mechanism to count the number of Credit Message tasks completed
kono
parents:
diff changeset
70 protected TC_Tasks_Completed is
kono
parents:
diff changeset
71 procedure Increment;
kono
parents:
diff changeset
72 function Count return integer;
kono
parents:
diff changeset
73 private
kono
parents:
diff changeset
74 Number_Complete : integer := 0;
kono
parents:
diff changeset
75 end TC_Tasks_Completed;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 TC_Credit_Messages_Expected : constant integer := 5;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 protected TC_Handshake is
kono
parents:
diff changeset
81 procedure Set;
kono
parents:
diff changeset
82 function First_Message_Arrived return Boolean;
kono
parents:
diff changeset
83 private
kono
parents:
diff changeset
84 Arrived_Flag : Boolean := false;
kono
parents:
diff changeset
85 end TC_Handshake;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 -- Handshaking mechanism between the Line Driver and the Credit task
kono
parents:
diff changeset
88 --
kono
parents:
diff changeset
89 protected body TC_Handshake is
kono
parents:
diff changeset
90 --
kono
parents:
diff changeset
91 procedure Set is
kono
parents:
diff changeset
92 begin
kono
parents:
diff changeset
93 Arrived_Flag := true;
kono
parents:
diff changeset
94 end Set;
kono
parents:
diff changeset
95 --
kono
parents:
diff changeset
96 function First_Message_Arrived return Boolean is
kono
parents:
diff changeset
97 begin
kono
parents:
diff changeset
98 return Arrived_Flag;
kono
parents:
diff changeset
99 end First_Message_Arrived;
kono
parents:
diff changeset
100 --
kono
parents:
diff changeset
101 end TC_Handshake;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 protected type Shared_Boolean (Initial_Value : Boolean := False) is
kono
parents:
diff changeset
105 procedure Set_True;
kono
parents:
diff changeset
106 procedure Set_False;
kono
parents:
diff changeset
107 function Value return Boolean;
kono
parents:
diff changeset
108 private
kono
parents:
diff changeset
109 Current_Value : Boolean := Initial_Value;
kono
parents:
diff changeset
110 end Shared_Boolean;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 protected body Shared_Boolean is
kono
parents:
diff changeset
113 procedure Set_True is
kono
parents:
diff changeset
114 begin
kono
parents:
diff changeset
115 Current_Value := True;
kono
parents:
diff changeset
116 end Set_True;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Set_False is
kono
parents:
diff changeset
119 begin
kono
parents:
diff changeset
120 Current_Value := False;
kono
parents:
diff changeset
121 end Set_False;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 function Value return Boolean is
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125 return Current_Value;
kono
parents:
diff changeset
126 end Value;
kono
parents:
diff changeset
127 end Shared_Boolean;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 TC_Debit_Message_Complete : Shared_Boolean (False);
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 type Transaction_Code is (Credit, Debit);
kono
parents:
diff changeset
132 type Transaction_Priority is (High, Low);
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 type Transaction_Record;
kono
parents:
diff changeset
135 type acc_Transaction_Record is access Transaction_Record;
kono
parents:
diff changeset
136 type Transaction_Record is
kono
parents:
diff changeset
137 record
kono
parents:
diff changeset
138 ID : integer := 0;
kono
parents:
diff changeset
139 Code : Transaction_Code := Debit;
kono
parents:
diff changeset
140 Priority : Transaction_Priority := High;
kono
parents:
diff changeset
141 Account_Number : integer := 0;
kono
parents:
diff changeset
142 Stock_Number : integer := 0;
kono
parents:
diff changeset
143 Quantity : integer := 0;
kono
parents:
diff changeset
144 Return_Value : integer := 0;
kono
parents:
diff changeset
145 TC_Message_Count : integer := 0;
kono
parents:
diff changeset
146 TC_Thru_Dist : Boolean := false;
kono
parents:
diff changeset
147 end record;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 task type Message_Task is
kono
parents:
diff changeset
151 entry Accept_Transaction (In_Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
152 end Message_Task;
kono
parents:
diff changeset
153 type acc_Message_Task is access Message_Task;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 task Line_Driver is
kono
parents:
diff changeset
156 entry Start;
kono
parents:
diff changeset
157 end Line_Driver;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 protected Distributor is
kono
parents:
diff changeset
160 procedure Set_Credit_Overloaded;
kono
parents:
diff changeset
161 procedure Clear_Credit_Overloaded;
kono
parents:
diff changeset
162 function Credit_is_Overloaded return Boolean;
kono
parents:
diff changeset
163 entry Input (Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
164 private
kono
parents:
diff changeset
165 Credit_Overloaded : Boolean := false;
kono
parents:
diff changeset
166 end Distributor;
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 protected Hold is
kono
parents:
diff changeset
169 procedure Underloaded;
kono
parents:
diff changeset
170 entry Wait_for_Underload (Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
171 private
kono
parents:
diff changeset
172 Release_All : Boolean := false;
kono
parents:
diff changeset
173 end Hold;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 task Credit_Computation is
kono
parents:
diff changeset
176 entry Input(Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
177 end Credit_Computation;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 task Debit_Computation is
kono
parents:
diff changeset
180 entry Input(Transaction : acc_Transaction_Record);
kono
parents:
diff changeset
181 end Debit_Computation;
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 --
kono
parents:
diff changeset
184 -- Dispose each input Transaction_Record to the appropriate
kono
parents:
diff changeset
185 -- computation tasks
kono
parents:
diff changeset
186 --
kono
parents:
diff changeset
187 protected body Distributor is
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 procedure Set_Credit_Overloaded is
kono
parents:
diff changeset
190 begin
kono
parents:
diff changeset
191 Credit_Overloaded := true;
kono
parents:
diff changeset
192 end Set_Credit_Overloaded;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 procedure Clear_Credit_Overloaded is
kono
parents:
diff changeset
195 begin
kono
parents:
diff changeset
196 Credit_Overloaded := false;
kono
parents:
diff changeset
197 Hold.Underloaded; -- Release all held messages
kono
parents:
diff changeset
198 end Clear_Credit_Overloaded;
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 function Credit_is_Overloaded return Boolean is
kono
parents:
diff changeset
201 begin
kono
parents:
diff changeset
202 return Credit_Overloaded;
kono
parents:
diff changeset
203 end Credit_is_Overloaded;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 entry Input (Transaction : acc_Transaction_Record) when true is
kono
parents:
diff changeset
207 -- barrier is always open
kono
parents:
diff changeset
208 begin
kono
parents:
diff changeset
209 -- Test Control: Set the indicator in the message to show it has
kono
parents:
diff changeset
210 -- passed through the Distributor object
kono
parents:
diff changeset
211 Transaction.TC_thru_Dist := true;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 -- Pass this transaction on to the appropriate computation
kono
parents:
diff changeset
214 -- task but temporarily hold low-priority transactions under
kono
parents:
diff changeset
215 -- overload conditions
kono
parents:
diff changeset
216 case Transaction.Code is
kono
parents:
diff changeset
217 when Credit =>
kono
parents:
diff changeset
218 if Credit_Overloaded and Transaction.Priority = Low then
kono
parents:
diff changeset
219 requeue Hold.Wait_for_Underload with abort;
kono
parents:
diff changeset
220 else
kono
parents:
diff changeset
221 requeue Credit_Computation.Input with abort;
kono
parents:
diff changeset
222 end if;
kono
parents:
diff changeset
223 when Debit =>
kono
parents:
diff changeset
224 requeue Debit_Computation.Input with abort;
kono
parents:
diff changeset
225 end case;
kono
parents:
diff changeset
226 end Input;
kono
parents:
diff changeset
227 end Distributor;
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 -- Low priority Message tasks are held on the Wait_for_Underload queue
kono
parents:
diff changeset
231 -- while the Credit computation system is overloaded. Once the Credit
kono
parents:
diff changeset
232 -- system reached underload send all queued messages immediately
kono
parents:
diff changeset
233 --
kono
parents:
diff changeset
234 protected body Hold is
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 -- Once this is executed the barrier condition for the entry is
kono
parents:
diff changeset
237 -- evaluated
kono
parents:
diff changeset
238 procedure Underloaded is
kono
parents:
diff changeset
239 begin
kono
parents:
diff changeset
240 Release_All := true;
kono
parents:
diff changeset
241 end Underloaded;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 entry Wait_for_Underload (Transaction : acc_Transaction_Record)
kono
parents:
diff changeset
244 when Release_All is
kono
parents:
diff changeset
245 begin
kono
parents:
diff changeset
246 requeue Credit_Computation.Input with abort;
kono
parents:
diff changeset
247 if Wait_for_Underload'count = 0 then
kono
parents:
diff changeset
248 -- Queue is purged. Set up to hold next batch
kono
parents:
diff changeset
249 Release_All := false;
kono
parents:
diff changeset
250 end if;
kono
parents:
diff changeset
251 end Wait_for_Underload;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 end Hold;
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 -- Mechanism to count the number of Message tasks completed (Credit)
kono
parents:
diff changeset
256 protected body TC_Tasks_Completed is
kono
parents:
diff changeset
257 procedure Increment is
kono
parents:
diff changeset
258 begin
kono
parents:
diff changeset
259 Number_Complete := Number_Complete + 1;
kono
parents:
diff changeset
260 end Increment;
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 function Count return integer is
kono
parents:
diff changeset
263 begin
kono
parents:
diff changeset
264 return Number_Complete;
kono
parents:
diff changeset
265 end Count;
kono
parents:
diff changeset
266 end TC_Tasks_Completed;
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 -- Assemble messages received from an external source
kono
parents:
diff changeset
270 -- Creates a message task for each. The message tasks remain extant
kono
parents:
diff changeset
271 -- for the life of the messages in the system.
kono
parents:
diff changeset
272 -- The Line Driver task would normally be designed to loop continuously
kono
parents:
diff changeset
273 -- creating the messages as input is received. Simulate this
kono
parents:
diff changeset
274 -- but limit it to the required number of dummy messages needed for
kono
parents:
diff changeset
275 -- this test and allow it to terminate at that point. Artificially
kono
parents:
diff changeset
276 -- alternate High and Low priority Credit transactions for this test.
kono
parents:
diff changeset
277 --
kono
parents:
diff changeset
278 task body Line_Driver is
kono
parents:
diff changeset
279 Current_ID : integer := 1;
kono
parents:
diff changeset
280 Current_Priority : Transaction_Priority := High;
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 -- Artificial: number of messages required for this test
kono
parents:
diff changeset
283 type TC_Trans_Range is range 1..6;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 procedure Build_Credit_Record
kono
parents:
diff changeset
286 ( Next_Transaction : acc_Transaction_Record ) is
kono
parents:
diff changeset
287 Dummy_Account : constant integer := 100;
kono
parents:
diff changeset
288 begin
kono
parents:
diff changeset
289 Next_Transaction.ID := Current_ID;
kono
parents:
diff changeset
290 Next_Transaction.Code := Credit;
kono
parents:
diff changeset
291 Next_Transaction.Priority := Current_Priority;
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 Next_Transaction.Account_Number := Dummy_Account;
kono
parents:
diff changeset
294 Current_ID := Current_ID + 1;
kono
parents:
diff changeset
295 end Build_Credit_Record;
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 procedure Build_Debit_Record
kono
parents:
diff changeset
299 ( Next_Transaction : acc_Transaction_Record ) is
kono
parents:
diff changeset
300 Dummy_Account : constant integer := 200;
kono
parents:
diff changeset
301 begin
kono
parents:
diff changeset
302 Next_Transaction.ID := Current_ID;
kono
parents:
diff changeset
303 Next_Transaction.Code := Debit;
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 Next_Transaction.Account_Number := Dummy_Account;
kono
parents:
diff changeset
306 Current_ID := Current_ID + 1;
kono
parents:
diff changeset
307 end Build_Debit_Record;
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 begin
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 accept Start; -- Wait for trigger from Main
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 for Transaction_Numb in TC_Trans_Range loop -- TC: limit the loop
kono
parents:
diff changeset
314 declare
kono
parents:
diff changeset
315 -- Create a task for the next message
kono
parents:
diff changeset
316 Next_Message_Task : acc_Message_Task := new Message_Task;
kono
parents:
diff changeset
317 -- Create a record for it
kono
parents:
diff changeset
318 Next_Transaction : acc_Transaction_Record :=
kono
parents:
diff changeset
319 new Transaction_Record;
kono
parents:
diff changeset
320 begin
kono
parents:
diff changeset
321 if Transaction_Numb = TC_Trans_Range'first then
kono
parents:
diff changeset
322 -- Send the first Credit message
kono
parents:
diff changeset
323 Build_Credit_Record ( Next_Transaction );
kono
parents:
diff changeset
324 Next_Message_Task.Accept_Transaction ( Next_Transaction );
kono
parents:
diff changeset
325 -- TC: Wait until the first message has been received by the
kono
parents:
diff changeset
326 -- Credit task and it has set the Overload indicator for the
kono
parents:
diff changeset
327 -- Distributor
kono
parents:
diff changeset
328 while not TC_Handshake.First_Message_Arrived loop
kono
parents:
diff changeset
329 delay ImpDef.Minimum_Task_Switch;
kono
parents:
diff changeset
330 end loop;
kono
parents:
diff changeset
331 elsif Transaction_Numb = TC_Trans_Range'last then
kono
parents:
diff changeset
332 -- For this test send the last transaction to the Debit task
kono
parents:
diff changeset
333 -- to improve the mix
kono
parents:
diff changeset
334 Build_Debit_Record( Next_Transaction );
kono
parents:
diff changeset
335 Next_Message_Task.Accept_Transaction ( Next_Transaction );
kono
parents:
diff changeset
336 else
kono
parents:
diff changeset
337 -- TC: Alternate high and low priority transactions
kono
parents:
diff changeset
338 if Current_Priority = High then
kono
parents:
diff changeset
339 Current_Priority := Low;
kono
parents:
diff changeset
340 else
kono
parents:
diff changeset
341 Current_Priority := High;
kono
parents:
diff changeset
342 end if;
kono
parents:
diff changeset
343 Build_Credit_Record( Next_Transaction );
kono
parents:
diff changeset
344 Next_Message_Task.Accept_Transaction ( Next_Transaction );
kono
parents:
diff changeset
345 end if;
kono
parents:
diff changeset
346 end; -- declare
kono
parents:
diff changeset
347 end loop;
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 exception
kono
parents:
diff changeset
350 when others =>
kono
parents:
diff changeset
351 Report.Failed ("Unexpected exception in Line_Driver");
kono
parents:
diff changeset
352 end Line_Driver;
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 task body Message_Task is
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 TC_Original_Transaction_Code : Transaction_Code;
kono
parents:
diff changeset
360 This_Transaction : acc_Transaction_Record := new Transaction_Record;
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 begin
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 accept Accept_Transaction (In_Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
365 This_Transaction.all := In_Transaction.all;
kono
parents:
diff changeset
366 end Accept_Transaction;
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 -- Note the original code to ensure correct return
kono
parents:
diff changeset
369 TC_Original_Transaction_Code := This_Transaction.Code;
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 -- Queue up on Distributor's Input queue
kono
parents:
diff changeset
372 Distributor.Input ( This_Transaction );
kono
parents:
diff changeset
373 -- This task will now wait for the requeued rendezvous
kono
parents:
diff changeset
374 -- to complete before proceeding
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 -- After the required computations have been performed
kono
parents:
diff changeset
377 -- return the Transaction_Record appropriately (probably to an output
kono
parents:
diff changeset
378 -- line driver)
kono
parents:
diff changeset
379 null; -- stub
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 -- For the test check that the return values are as expected
kono
parents:
diff changeset
382 if TC_Original_Transaction_Code /= This_Transaction.Code then
kono
parents:
diff changeset
383 -- Incorrect rendezvous
kono
parents:
diff changeset
384 Report.Failed ("Message Task: Incorrect code returned");
kono
parents:
diff changeset
385 end if;
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 if This_Transaction.Code = Credit then
kono
parents:
diff changeset
388 if This_Transaction.Return_Value /= Credit_Return or
kono
parents:
diff changeset
389 not This_Transaction.TC_thru_Dist then
kono
parents:
diff changeset
390 Report.Failed ("Expected path not traversed - Credit");
kono
parents:
diff changeset
391 end if;
kono
parents:
diff changeset
392 TC_Tasks_Completed.Increment;
kono
parents:
diff changeset
393 else
kono
parents:
diff changeset
394 if This_Transaction.Return_Value /= Debit_Return or
kono
parents:
diff changeset
395 This_Transaction.TC_Message_Count /= 1 or
kono
parents:
diff changeset
396 not This_Transaction.TC_thru_Dist then
kono
parents:
diff changeset
397 Report.Failed ("Expected path not traversed - Debit");
kono
parents:
diff changeset
398 end if;
kono
parents:
diff changeset
399 TC_Debit_Message_Complete.Set_True;
kono
parents:
diff changeset
400 end if;
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 exception
kono
parents:
diff changeset
403 when others =>
kono
parents:
diff changeset
404 Report.Failed ("Unexpected exception in Message_Task");
kono
parents:
diff changeset
405 end Message_Task;
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 -- Computation task. After the computation is performed the rendezvous
kono
parents:
diff changeset
412 -- in the original message task is completed.
kono
parents:
diff changeset
413 task body Credit_Computation is
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 Message_Count : integer := 0;
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 begin
kono
parents:
diff changeset
418 loop
kono
parents:
diff changeset
419 select
kono
parents:
diff changeset
420 accept Input ( Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
421 if Distributor.Credit_is_Overloaded
kono
parents:
diff changeset
422 and Transaction.Priority = Low then
kono
parents:
diff changeset
423 -- We should not be getting any Low Priority messages. They
kono
parents:
diff changeset
424 -- should be waiting on the Hold.Wait_for_Underload
kono
parents:
diff changeset
425 -- queue
kono
parents:
diff changeset
426 Report.Failed
kono
parents:
diff changeset
427 ("Credit Task: Low priority transaction during overload");
kono
parents:
diff changeset
428 end if;
kono
parents:
diff changeset
429 -- Perform the computations required for this transaction
kono
parents:
diff changeset
430 null; -- stub
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 -- For the test:
kono
parents:
diff changeset
433 if not Transaction.TC_thru_Dist then
kono
parents:
diff changeset
434 Report.Failed
kono
parents:
diff changeset
435 ("Credit Task: Wrong queue, Distributor bypassed");
kono
parents:
diff changeset
436 end if;
kono
parents:
diff changeset
437 if Transaction.code /= Credit then
kono
parents:
diff changeset
438 Report.Failed
kono
parents:
diff changeset
439 ("Credit Task: Requeue delivered to the wrong queue");
kono
parents:
diff changeset
440 end if;
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 -- The following is all Test Control code:
kono
parents:
diff changeset
443 Transaction.Return_Value := Credit_Return;
kono
parents:
diff changeset
444 Message_Count := Message_Count + 1;
kono
parents:
diff changeset
445 --
kono
parents:
diff changeset
446 -- Now take special action depending on which Message
kono
parents:
diff changeset
447 if Message_Count = 1 then
kono
parents:
diff changeset
448 -- After the first message :
kono
parents:
diff changeset
449 Distributor.Set_Credit_Overloaded;
kono
parents:
diff changeset
450 -- Now flag the Line_Driver that the second and subsequent
kono
parents:
diff changeset
451 -- messages may now be sent
kono
parents:
diff changeset
452 TC_Handshake.Set;
kono
parents:
diff changeset
453 end if;
kono
parents:
diff changeset
454 if Message_Count = 3 then
kono
parents:
diff changeset
455 -- The two high priority transactions created subsequent
kono
parents:
diff changeset
456 -- to the overload have now been processed
kono
parents:
diff changeset
457 Distributor.Clear_Credit_Overloaded;
kono
parents:
diff changeset
458 end if;
kono
parents:
diff changeset
459 end Input;
kono
parents:
diff changeset
460 or
kono
parents:
diff changeset
461 terminate;
kono
parents:
diff changeset
462 end select;
kono
parents:
diff changeset
463 end loop;
kono
parents:
diff changeset
464 exception
kono
parents:
diff changeset
465 when others =>
kono
parents:
diff changeset
466 Report.Failed ("Unexpected exception in Credit_Computation");
kono
parents:
diff changeset
467 end Credit_Computation;
kono
parents:
diff changeset
468
kono
parents:
diff changeset
469
kono
parents:
diff changeset
470
kono
parents:
diff changeset
471 -- Computation task. After the computation is performed the rendezvous
kono
parents:
diff changeset
472 -- in the original message task is completed.
kono
parents:
diff changeset
473 --
kono
parents:
diff changeset
474 task body Debit_Computation is
kono
parents:
diff changeset
475 Message_Count : integer := 0;
kono
parents:
diff changeset
476 begin
kono
parents:
diff changeset
477 loop
kono
parents:
diff changeset
478 select
kono
parents:
diff changeset
479 accept Input (Transaction : acc_Transaction_Record) do
kono
parents:
diff changeset
480 -- Perform the computations required for this message
kono
parents:
diff changeset
481 null; -- stub
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 -- For the test:
kono
parents:
diff changeset
484 if not Transaction.TC_thru_Dist then
kono
parents:
diff changeset
485 Report.Failed
kono
parents:
diff changeset
486 ("Debit Task: Wrong queue, Distributor bypassed");
kono
parents:
diff changeset
487 end if;
kono
parents:
diff changeset
488 if Transaction.code /= Debit then
kono
parents:
diff changeset
489 Report.Failed
kono
parents:
diff changeset
490 ("Debit Task: Requeue delivered to the wrong queue");
kono
parents:
diff changeset
491 end if;
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 -- for the test plug a known value and count
kono
parents:
diff changeset
494 Transaction.Return_Value := Debit_Return;
kono
parents:
diff changeset
495 -- one, and only one, message should pass through
kono
parents:
diff changeset
496 Message_Count := Message_Count + 1;
kono
parents:
diff changeset
497 Transaction.TC_Message_Count := Message_Count;
kono
parents:
diff changeset
498 end Input;
kono
parents:
diff changeset
499 or
kono
parents:
diff changeset
500 terminate;
kono
parents:
diff changeset
501 end select;
kono
parents:
diff changeset
502 end loop;
kono
parents:
diff changeset
503 exception
kono
parents:
diff changeset
504 when others =>
kono
parents:
diff changeset
505 Report.Failed ("Unexpected exception in Debit_Computation");
kono
parents:
diff changeset
506 end Debit_Computation;
kono
parents:
diff changeset
507
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 begin
kono
parents:
diff changeset
510 Report.Test ("C954021", "Requeue from one entry body to an entry in" &
kono
parents:
diff changeset
511 " another protected object");
kono
parents:
diff changeset
512
kono
parents:
diff changeset
513 Line_Driver.Start; -- Start the test
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515
kono
parents:
diff changeset
516 -- Ensure that the message tasks have completed before reporting result
kono
parents:
diff changeset
517 while (TC_Tasks_Completed.Count < TC_Credit_Messages_Expected)
kono
parents:
diff changeset
518 and not TC_Debit_Message_Complete.Value loop
kono
parents:
diff changeset
519 delay ImpDef.Minimum_Task_Switch;
kono
parents:
diff changeset
520 end loop;
kono
parents:
diff changeset
521
kono
parents:
diff changeset
522 Report.Result;
kono
parents:
diff changeset
523
kono
parents:
diff changeset
524 end C954021;