1 |
149 |
jeremybenn |
-- C954024.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 a call to a protected entry can be requeued to a task
|
28 |
|
|
-- entry. Check that the requeue is placed on the correct entry; that the
|
29 |
|
|
-- original caller waits for the completion of the requeue and continues
|
30 |
|
|
-- after the requeued rendezvous. Check that the requeue does not block.
|
31 |
|
|
-- Specifically, check a requeue without abort from a protected entry to
|
32 |
|
|
-- an entry in a task.
|
33 |
|
|
--
|
34 |
|
|
-- TEST DESCRIPTION:
|
35 |
|
|
-- In the Distributor protected object, requeue two successive calls on
|
36 |
|
|
-- the entries of two separate target tasks. Each task in each of the
|
37 |
|
|
-- paths adds identifying information in the transaction being passed.
|
38 |
|
|
-- This information is checked by the Message tasks on completion
|
39 |
|
|
-- ensuring that the requeues have been placed on the correct queues.
|
40 |
|
|
-- There is an artificial guard on the Credit Task to ensure that the
|
41 |
|
|
-- input is queued; this guard is released by the Debit task which
|
42 |
|
|
-- handles its input immediately. This ensures that we have one of the
|
43 |
|
|
-- requeued items actually queued for later handling and also verifies
|
44 |
|
|
-- that the requeuing process (in the protected object) is not blocked.
|
45 |
|
|
--
|
46 |
|
|
-- This series of tests uses a simulation of a transaction driven
|
47 |
|
|
-- processing system. Line Drivers accept input from an external source
|
48 |
|
|
-- and build them into transaction records. These records are then
|
49 |
|
|
-- encapsulated in message tasks which remain extant for the life of the
|
50 |
|
|
-- transaction in the system. The message tasks put themselves on the
|
51 |
|
|
-- input queue of a Distributor object which, from information in the
|
52 |
|
|
-- transaction and/or system load conditions forwards them to other
|
53 |
|
|
-- operating tasks. These in turn might forward the transactions to yet
|
54 |
|
|
-- other tasks for further action. The routing is, in real life,
|
55 |
|
|
-- dynamic and unpredictable at the time of message generation. All
|
56 |
|
|
-- rerouting in this model is done by means of requeues.
|
57 |
|
|
--
|
58 |
|
|
--
|
59 |
|
|
-- CHANGE HISTORY:
|
60 |
|
|
-- 06 Dec 94 SAIC ACVC 2.0
|
61 |
|
|
-- 08 Nov 95 SAIC Fixed reported problems for ACVC 2.0.1
|
62 |
|
|
--
|
63 |
|
|
--!
|
64 |
|
|
|
65 |
|
|
with Report;
|
66 |
|
|
with ImpDef;
|
67 |
|
|
procedure C954024 is
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
begin -- C954024
|
71 |
|
|
|
72 |
|
|
Report.Test ("C954024", "Requeue from protected entry to task entry");
|
73 |
|
|
|
74 |
|
|
declare -- encapsulate the test
|
75 |
|
|
|
76 |
|
|
-- Arbitrary test values
|
77 |
|
|
Credit_Return : constant := 1;
|
78 |
|
|
Debit_Return : constant := 2;
|
79 |
|
|
|
80 |
|
|
type Transaction_Code is (Credit, Debit);
|
81 |
|
|
|
82 |
|
|
type Transaction_Record;
|
83 |
|
|
type acc_Transaction_Record is access Transaction_Record;
|
84 |
|
|
type Transaction_Record is
|
85 |
|
|
record
|
86 |
|
|
ID : integer := 0;
|
87 |
|
|
Code : Transaction_Code := Debit;
|
88 |
|
|
Account_Number : integer := 0;
|
89 |
|
|
Stock_Number : integer := 0;
|
90 |
|
|
Quantity : integer := 0;
|
91 |
|
|
Return_Value : integer := 0;
|
92 |
|
|
TC_Message_Count : integer := 0;
|
93 |
|
|
TC_Thru_Dist : Boolean := false;
|
94 |
|
|
end record;
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
task type Message_Task is
|
98 |
|
|
entry Accept_Transaction (In_Transaction : acc_Transaction_Record);
|
99 |
|
|
end Message_Task;
|
100 |
|
|
type acc_Message_Task is access Message_Task;
|
101 |
|
|
|
102 |
|
|
task Line_Driver is
|
103 |
|
|
entry Start;
|
104 |
|
|
end Line_Driver;
|
105 |
|
|
|
106 |
|
|
task Credit_Computation is
|
107 |
|
|
entry Input(Transaction : acc_Transaction_Record);
|
108 |
|
|
end Credit_Computation;
|
109 |
|
|
|
110 |
|
|
task Debit_Computation is
|
111 |
|
|
entry Input(Transaction : acc_Transaction_Record);
|
112 |
|
|
end Debit_Computation;
|
113 |
|
|
|
114 |
|
|
protected Time_Lock is
|
115 |
|
|
procedure Credit_Start;
|
116 |
|
|
function Credit_Enabled return Boolean;
|
117 |
|
|
private
|
118 |
|
|
Credit_OK : Boolean := false;
|
119 |
|
|
end Time_Lock;
|
120 |
|
|
|
121 |
|
|
protected body Time_Lock is
|
122 |
|
|
procedure Credit_Start is
|
123 |
|
|
begin
|
124 |
|
|
Credit_OK := true;
|
125 |
|
|
end Credit_Start;
|
126 |
|
|
|
127 |
|
|
function Credit_Enabled return Boolean is
|
128 |
|
|
begin
|
129 |
|
|
return Credit_OK;
|
130 |
|
|
end Credit_Enabled;
|
131 |
|
|
end Time_Lock;
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
protected Distributor is
|
136 |
|
|
entry Input (Transaction : acc_Transaction_Record);
|
137 |
|
|
end Distributor;
|
138 |
|
|
--
|
139 |
|
|
--
|
140 |
|
|
-- Dispose each input Transaction_Record to the appropriate
|
141 |
|
|
-- computation tasks
|
142 |
|
|
--
|
143 |
|
|
protected body Distributor is
|
144 |
|
|
entry Input (Transaction : acc_Transaction_Record) when true is
|
145 |
|
|
-- barrier is always open
|
146 |
|
|
begin
|
147 |
|
|
-- Test Control: Set the indicator in the message to show it has
|
148 |
|
|
-- passed through the Distributor object
|
149 |
|
|
Transaction.TC_thru_Dist := true;
|
150 |
|
|
|
151 |
|
|
-- Pass this transaction on to the appropriate computation
|
152 |
|
|
-- task
|
153 |
|
|
case Transaction.Code is
|
154 |
|
|
when Credit =>
|
155 |
|
|
requeue Credit_Computation.Input;
|
156 |
|
|
when Debit =>
|
157 |
|
|
requeue Debit_Computation.Input;
|
158 |
|
|
end case;
|
159 |
|
|
end Input;
|
160 |
|
|
end Distributor;
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
-- Assemble messages received from an external source
|
166 |
|
|
-- Creates a message task for each. The message tasks remain extant
|
167 |
|
|
-- for the life of the messages in the system.
|
168 |
|
|
-- NOTE:
|
169 |
|
|
-- The Line Driver task would normally be designed to loop continuously
|
170 |
|
|
-- creating the messages as input is received. Simulate this
|
171 |
|
|
-- but limit it to two dummy messages for this test and allow it
|
172 |
|
|
-- to terminate at that point
|
173 |
|
|
--
|
174 |
|
|
task body Line_Driver is
|
175 |
|
|
Current_ID : integer := 1;
|
176 |
|
|
TC_Last_was_for_credit : Boolean := false;
|
177 |
|
|
|
178 |
|
|
procedure Build_Credit_Record
|
179 |
|
|
( Next_Transaction : acc_Transaction_Record ) is
|
180 |
|
|
Dummy_Account : constant integer := 100;
|
181 |
|
|
begin
|
182 |
|
|
Next_Transaction.ID := Current_ID;
|
183 |
|
|
Next_Transaction.Code := Credit;
|
184 |
|
|
|
185 |
|
|
Next_Transaction.Account_Number := Dummy_Account;
|
186 |
|
|
Current_ID := Current_ID + 1;
|
187 |
|
|
end Build_Credit_Record;
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
procedure Build_Debit_Record
|
191 |
|
|
( Next_Transaction : acc_Transaction_Record ) is
|
192 |
|
|
Dummy_Account : constant integer := 200;
|
193 |
|
|
begin
|
194 |
|
|
Next_Transaction.ID := Current_ID;
|
195 |
|
|
Next_Transaction.Code := Debit;
|
196 |
|
|
|
197 |
|
|
Next_Transaction.Account_Number := Dummy_Account;
|
198 |
|
|
Current_ID := Current_ID + 1;
|
199 |
|
|
end Build_Debit_Record;
|
200 |
|
|
|
201 |
|
|
begin
|
202 |
|
|
|
203 |
|
|
accept Start; -- Wait for trigger from Main
|
204 |
|
|
|
205 |
|
|
for i in 1..2 loop -- arbitrarily limit to two messages for the test
|
206 |
|
|
declare
|
207 |
|
|
-- Create a task for the next message
|
208 |
|
|
Next_Message_Task : acc_Message_Task := new Message_Task;
|
209 |
|
|
-- Create a record for it
|
210 |
|
|
Next_Transaction : acc_Transaction_Record
|
211 |
|
|
:= new Transaction_Record;
|
212 |
|
|
begin
|
213 |
|
|
if TC_Last_was_for_credit then
|
214 |
|
|
Build_Debit_Record ( Next_Transaction );
|
215 |
|
|
else
|
216 |
|
|
Build_Credit_Record( Next_Transaction );
|
217 |
|
|
TC_Last_was_for_credit := true;
|
218 |
|
|
end if;
|
219 |
|
|
Next_Message_Task.Accept_Transaction ( Next_Transaction );
|
220 |
|
|
end; -- declare
|
221 |
|
|
end loop;
|
222 |
|
|
|
223 |
|
|
exception
|
224 |
|
|
when others =>
|
225 |
|
|
Report.Failed ("Unexpected exception in Line_Driver");
|
226 |
|
|
end Line_Driver;
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
task body Message_Task is
|
232 |
|
|
|
233 |
|
|
TC_Original_Transaction_Code : Transaction_Code;
|
234 |
|
|
This_Transaction : acc_Transaction_Record := new Transaction_Record;
|
235 |
|
|
|
236 |
|
|
begin
|
237 |
|
|
accept Accept_Transaction
|
238 |
|
|
(In_Transaction : acc_Transaction_Record) do
|
239 |
|
|
This_Transaction.all := In_Transaction.all;
|
240 |
|
|
end Accept_Transaction;
|
241 |
|
|
|
242 |
|
|
-- Note the original code to ensure correct return
|
243 |
|
|
TC_Original_Transaction_Code := This_Transaction.Code;
|
244 |
|
|
|
245 |
|
|
-- Queue up on Distributor's Input queue
|
246 |
|
|
Distributor.Input ( This_Transaction );
|
247 |
|
|
-- This task will now wait for the requeued rendezvous
|
248 |
|
|
-- to complete before proceeding
|
249 |
|
|
|
250 |
|
|
-- After the required computations have been performed
|
251 |
|
|
-- return the Transaction_Record appropriately (probably to an output
|
252 |
|
|
-- line driver)
|
253 |
|
|
null; -- stub
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
-- The following is all Test Control Code
|
257 |
|
|
|
258 |
|
|
-- Check that the return values are as expected
|
259 |
|
|
if TC_Original_Transaction_Code /= This_Transaction.Code then
|
260 |
|
|
-- Incorrect rendezvous
|
261 |
|
|
Report.Failed ("Message Task: Incorrect code returned");
|
262 |
|
|
end if;
|
263 |
|
|
|
264 |
|
|
if This_Transaction.Code = Credit then
|
265 |
|
|
if This_Transaction.Return_Value /= Credit_Return or
|
266 |
|
|
This_Transaction.TC_Message_Count /= 1 or
|
267 |
|
|
not This_Transaction.TC_thru_Dist then
|
268 |
|
|
Report.Failed ("Expected path not traversed");
|
269 |
|
|
end if;
|
270 |
|
|
else
|
271 |
|
|
if This_Transaction.Return_Value /= Debit_Return or
|
272 |
|
|
This_Transaction.TC_Message_Count /= 1 or
|
273 |
|
|
not This_Transaction.TC_thru_Dist then
|
274 |
|
|
Report.Failed ("Expected path not traversed");
|
275 |
|
|
end if;
|
276 |
|
|
end if;
|
277 |
|
|
|
278 |
|
|
exception
|
279 |
|
|
when others =>
|
280 |
|
|
Report.Failed ("Unexpected exception in Message_Task");
|
281 |
|
|
|
282 |
|
|
end Message_Task;
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
-- Computation task.
|
287 |
|
|
-- Note: After the computation is performed in this task and the
|
288 |
|
|
-- accept body is completed the rendezvous in the original
|
289 |
|
|
-- message task is completed.
|
290 |
|
|
--
|
291 |
|
|
task body Credit_Computation is
|
292 |
|
|
Message_Count : integer := 0;
|
293 |
|
|
begin
|
294 |
|
|
loop
|
295 |
|
|
select
|
296 |
|
|
when Time_Lock.Credit_enabled =>
|
297 |
|
|
accept Input ( Transaction : acc_Transaction_Record) do
|
298 |
|
|
-- Perform the computations required for this transaction
|
299 |
|
|
null; -- stub
|
300 |
|
|
|
301 |
|
|
-- For the test:
|
302 |
|
|
if not Transaction.TC_thru_Dist then
|
303 |
|
|
Report.Failed
|
304 |
|
|
("Credit Task: Wrong queue, Distributor bypassed");
|
305 |
|
|
end if;
|
306 |
|
|
if Transaction.code /= Credit then
|
307 |
|
|
Report.Failed
|
308 |
|
|
("Credit Task: Requeue delivered to the wrong queue");
|
309 |
|
|
end if;
|
310 |
|
|
|
311 |
|
|
-- for the test plug a known value and count
|
312 |
|
|
Transaction.Return_Value := Credit_Return;
|
313 |
|
|
-- one, and only one message should pass through
|
314 |
|
|
Message_Count := Message_Count + 1;
|
315 |
|
|
Transaction.TC_Message_Count := Message_Count;
|
316 |
|
|
end Input;
|
317 |
|
|
exit; -- one message is enough
|
318 |
|
|
else
|
319 |
|
|
delay ImpDef.Clear_Ready_Queue; -- poll
|
320 |
|
|
end select;
|
321 |
|
|
end loop;
|
322 |
|
|
exception
|
323 |
|
|
when others =>
|
324 |
|
|
Report.Failed ("Unexpected exception in Credit_Computation");
|
325 |
|
|
end Credit_Computation;
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
-- Computation task.
|
330 |
|
|
-- Note: After the computation is performed in this task and the
|
331 |
|
|
-- accept body is completed the rendezvous in the original
|
332 |
|
|
-- message task is completed.
|
333 |
|
|
--
|
334 |
|
|
task body Debit_Computation is
|
335 |
|
|
Message_Count : integer := 0;
|
336 |
|
|
begin
|
337 |
|
|
loop
|
338 |
|
|
select
|
339 |
|
|
accept Input (Transaction : acc_Transaction_Record) do
|
340 |
|
|
-- Perform the computations required for this message
|
341 |
|
|
null; -- stub
|
342 |
|
|
|
343 |
|
|
-- For the test:
|
344 |
|
|
if not Transaction.TC_thru_Dist then
|
345 |
|
|
Report.Failed
|
346 |
|
|
("Debit Task: Wrong queue, Distributor bypassed");
|
347 |
|
|
end if;
|
348 |
|
|
if Transaction.code /= Debit then
|
349 |
|
|
Report.Failed
|
350 |
|
|
("Debit Task: Requeue delivered to the wrong queue");
|
351 |
|
|
end if;
|
352 |
|
|
|
353 |
|
|
-- for the test plug a known value and count
|
354 |
|
|
Transaction.Return_Value := Debit_Return;
|
355 |
|
|
-- one, and only one, message should pass through
|
356 |
|
|
Message_Count := Message_Count + 1;
|
357 |
|
|
Transaction.TC_Message_Count := Message_Count;
|
358 |
|
|
-- for the test: once we have completed the only Debit
|
359 |
|
|
-- message release the Credit Messages which are queued
|
360 |
|
|
-- on the Credit Input queue
|
361 |
|
|
Time_Lock.Credit_Start;
|
362 |
|
|
|
363 |
|
|
end Input;
|
364 |
|
|
or
|
365 |
|
|
terminate;
|
366 |
|
|
end select;
|
367 |
|
|
end loop;
|
368 |
|
|
exception
|
369 |
|
|
when others =>
|
370 |
|
|
Report.Failed ("Unexpected exception in Debit_Computation");
|
371 |
|
|
|
372 |
|
|
end Debit_Computation;
|
373 |
|
|
|
374 |
|
|
begin -- declare block
|
375 |
|
|
Line_Driver.Start;
|
376 |
|
|
end; -- test encapsulation
|
377 |
|
|
|
378 |
|
|
Report.Result;
|
379 |
|
|
|
380 |
|
|
end C954024;
|