3 -- Grant of Unlimited Rights
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
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.
27 -- Check that when a construct is aborted the execution of an Initialize
28 -- procedure as the last step of the default initialization of a
29 -- controlled object is abort-deferred.
31 -- Check that when a construct is aborted the execution of a Finalize
32 -- procedure as part of the finalization of a controlled object is
35 -- Check that an assignment operation to an object with a controlled
36 -- part is an abort-deferred operation.
39 -- The controlled operations which are being tested call a subprogram
40 -- which guarantees that the enclosing operation becomes aborted.
42 -- Each object is created with a unique value to prevent optimizations
43 -- due to the values being the same.
45 -- Two protected objects are utilized to warrant that the operations
46 -- are delayed in their execution until such time that the abort is
47 -- processed. The object Hold_Up is used to hold the targeted
48 -- operation in execution, the object Progress is used to communicate
49 -- to the driver software that progress is indeed being made.
53 -- 01 MAY 95 SAIC Initial version
54 -- 01 MAY 96 SAIC Revised for 2.1
55 -- 11 DEC 96 SAIC Final revision for 2.1
56 -- 02 DEC 97 EDS Remove 2 calls to C980001_0.Hold_Up.Lock
59 ---------------------------------------------------------------- C980001_0
62 with Ada
.Finalization
;
65 A_Little_While
: constant Duration := Impdef
.Switch_To_New_Task
* 2.0;
66 Enough_Time_For_The_Controlled_Operation_To_Happen
: constant Duration
67 := Impdef
.Switch_To_New_Task
* 4.0;
69 function TC_Unique
return Integer;
71 type Sticks_In_Initialize
is new Ada
.Finalization
.Controlled
with record
72 Item
: Integer := TC_Unique
;
74 procedure Initialize
( AV
: in out Sticks_In_Initialize
);
76 type Sticks_In_Adjust
is new Ada
.Finalization
.Controlled
with record
77 Item
: Integer := TC_Unique
;
79 procedure Adjust
( AV
: in out Sticks_In_Adjust
);
81 type Sticks_In_Finalize
is new Ada
.Finalization
.Controlled
with record
82 Item
: Integer := TC_Unique
;
84 procedure Finalize
( AV
: in out Sticks_In_Finalize
);
86 Initialize_Called
: Boolean := False;
87 Adjust_Called
: Boolean := False;
88 Finalize_Called
: Boolean := False;
90 protected type Sticker
is
93 function Is_Locked
return Boolean;
95 Locked
: Boolean := False;
101 procedure Fail_And_Clear
( Message
: String );
106 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
110 package body C980001_0
is
112 TC_Master_Value
: Integer := 0;
115 function TC_Unique
return Integer is -- make all values unique.
117 TC_Master_Value
:= TC_Master_Value
+1;
118 return TC_Master_Value
;
121 protected body Sticker
is
123 entry Lock
when not Locked
is
133 function Is_Locked
return Boolean is
140 procedure Initialize
( AV
: in out Sticks_In_Initialize
) is
142 TCTouch
.Touch
('I'); -------------------------------------------------- I
143 Hold_Up
.Unlock
; -- cause the select to abort
144 Initialize_Called
:= True;
145 AV
.Item
:= TC_Unique
;
146 TCTouch
.Touch
('i'); -------------------------------------------------- i
147 Progress
.Unlock
; -- allows Wait_Your_Turn to continue
150 procedure Adjust
( AV
: in out Sticks_In_Adjust
) is
152 TCTouch
.Touch
('A'); -------------------------------------------------- A
153 Hold_Up
.Unlock
; -- cause the select to abort
154 Adjust_Called
:= True;
155 AV
.Item
:= TC_Unique
;
156 TCTouch
.Touch
('a'); -------------------------------------------------- a
160 procedure Finalize
( AV
: in out Sticks_In_Finalize
) is
162 TCTouch
.Touch
('F'); -------------------------------------------------- F
163 Hold_Up
.Unlock
; -- cause the select to abort
164 Finalize_Called
:= True;
165 AV
.Item
:= TC_Unique
;
166 TCTouch
.Touch
('f'); -------------------------------------------------- f
170 procedure Fail_And_Clear
( Message
: String ) is
172 Report
.Failed
(Message
);
179 ---------------------------------------------------------------------------
187 procedure Check_Initialize_Conditions
is
189 if not C980001_0
.Initialize_Called
then
190 C980001_0
.Fail_And_Clear
("Initialize did not correctly complete");
192 TCTouch
.Validate
("Ii", "Initialization Sequence");
193 end Check_Initialize_Conditions
;
195 procedure Check_Adjust_Conditions
is
197 if not C980001_0
.Adjust_Called
then
198 C980001_0
.Fail_And_Clear
("Adjust did not correctly complete");
200 TCTouch
.Validate
("Aa", "Adjust Sequence");
201 end Check_Adjust_Conditions
;
203 procedure Check_Finalize_Conditions
is
205 if not C980001_0
.Finalize_Called
then
206 C980001_0
.Fail_And_Clear
("Finalize did not correctly complete");
208 TCTouch
.Validate
("FfFfFf", "Finalization Sequence",
209 Order_Meaningful
=> False);
210 end Check_Finalize_Conditions
;
212 procedure Wait_Your_Turn
is
213 Overrun
: Natural := 0;
215 while C980001_0
.Progress
.Is_Locked
loop -- and waits
216 delay C980001_0
.A_Little_While
;
217 Overrun
:= Overrun
+1;
219 C980001_0
.Fail_And_Clear
("Overrun expired lock");
224 begin -- Main test procedure.
226 Report
.Test
("C980001", "Check the interaction between asynchronous " &
227 "transfer of control and controlled types" );
229 C980001_0
.Progress
.Lock
;
230 C980001_0
.Hold_Up
.Lock
;
233 C980001_0
.Hold_Up
.Lock
; -- Init will unlock
235 Wait_Your_Turn
; -- abortable part is stuck in Initialize
236 Check_Initialize_Conditions
;
240 Object
: C980001_0
.Sticks_In_Initialize
;
242 delay Impdef
.Minimum_Task_Switch
;
243 if Report
.Ident_Int
( Object
.Item
) /= Object
.Item
then
244 Report
.Failed
("Optimization foil caused failure");
246 C980001_0
.Fail_And_Clear
(
247 "Initialize test executed beyond expected region");
251 C980001_0
.Progress
.Lock
;
254 C980001_0
.Hold_Up
.Lock
; -- Adjust will unlock
256 Wait_Your_Turn
; -- abortable part is stuck in Adjust
257 Check_Adjust_Conditions
;
261 Object1
: C980001_0
.Sticks_In_Adjust
;
262 Object2
: C980001_0
.Sticks_In_Adjust
;
265 delay Impdef
.Minimum_Task_Switch
;
266 if Report
.Ident_Int
( Object2
.Item
)
267 /= Report
.Ident_Int
( Object1
.Item
) then
268 Report
.Failed
("Optimization foil 1 caused failure");
270 C980001_0
.Fail_And_Clear
("Adjust test executed beyond expected region");
274 C980001_0
.Progress
.Lock
;
277 C980001_0
.Hold_Up
.Lock
; -- Finalize will unlock
279 Wait_Your_Turn
; -- abortable part is stuck in Finalize
280 Check_Finalize_Conditions
;
284 Object1
: C980001_0
.Sticks_In_Finalize
;
285 Object2
: C980001_0
.Sticks_In_Finalize
;
287 Object1
:= Object2
; -- cause a finalize call
288 delay Impdef
.Minimum_Task_Switch
;
289 if Report
.Ident_Int
( Object2
.Item
)
290 /= Report
.Ident_Int
( Object1
.Item
) then
291 Report
.Failed
("Optimization foil 2 caused failure");
293 C980001_0
.Fail_And_Clear
(
294 "Finalize test executed beyond expected region");
301 when others => C980001_0
.Fail_And_Clear
("Exception in main");