Merge from mainline
[official-gcc.git] / gcc / testsuite / ada / acats / tests / c9 / c954025.a
blobc4993f7ed05a39303c1e510f51e9b9016ab95b28
1 -- C954025.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.
16 -- DISCLAIMER
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 --*
26 -- OBJECTIVE:
27 -- Check that if the original entry call was a conditional entry call,
28 -- the call is cancelled if a requeue-with-abort of the call is not
29 -- selected immediately.
30 -- Check that if the original entry call was a timed entry call, the
31 -- expiration time for a requeue-with-abort is the original expiration
32 -- time.
34 -- TEST DESCRIPTION:
35 -- This test declares two tasks: Launch_Control and Mission_Control.
36 -- Mission_Control instructs Launch_Control to start its countdown
37 -- and then requeues (with abort) to the Launch_Control.Launch
38 -- entry. This call to Launch will be accepted at the end of the
39 -- countdown (if the task is still waiting).
40 -- The main task does an unconditional, conditional, and timed
41 -- entry call to Mission_Control and checks to see if the launch
42 -- was accepted.
45 -- CHANGE HISTORY:
46 -- 18 OCT 95 SAIC ACVC 2.1
47 -- 10 JUL 96 SAIC Incorporated reviewer's comments.
49 --!
51 with Calendar; use type Calendar.Time;
52 with Report;
53 with ImpDef;
54 procedure C954025 is
55 Verbose : constant Boolean := False;
56 Countdown_Amount : constant Duration := 2.0 * Impdef.One_Long_Second;
57 Plenty_Of_Time : constant Duration :=
58 Countdown_Amount + ImpDef.Clear_Ready_Queue + 1.0 * Impdef.One_Long_Second;
59 Not_Enough_Time : constant Duration :=
60 Countdown_Amount - 0.5 * Impdef.One_Long_Second;
61 begin
62 Report.Test ("C954025",
63 "Check that if the original entry" &
64 " call was a conditional or timed entry call, the" &
65 " expiration time for a requeue with abort is the" &
66 " original expiration time");
67 declare
68 -- note that the following object is a shared object and its use
69 -- governed by the rules of 9.10(3,4,8);6.0
70 Launch_Accepted : Boolean := False;
72 task Launch_Control is
73 entry Enable_Launch_Control;
74 entry Start_Countdown (How_Long : Duration);
75 -- Launch will be accepted if a call is waiting when the countdown
76 -- reaches 0
77 entry Launch;
78 end Launch_Control;
80 task body Launch_Control is
81 Wait_Amount : Duration := 0.0;
82 begin
83 loop
84 select
85 accept Enable_Launch_Control do
86 Launch_Accepted := False;
87 end Enable_Launch_Control;
89 terminate;
90 end select;
92 accept Start_Countdown (How_Long : Duration) do
93 Wait_Amount := How_Long;
94 end Start_Countdown;
96 delay Wait_Amount;
98 select
99 accept Launch do
100 Launch_Accepted := True;
101 end Launch;
102 else
103 null;
104 -- note that Launch_Accepted is False here
105 end select;
106 end loop;
107 end Launch_Control;
109 task Mission_Control is
110 -- launch will occur if we are given enough time to complete
111 -- a standard countdown. We will not be rushed!
112 entry Do_Launch;
113 end Mission_Control;
115 task body Mission_Control is
116 begin
117 loop
118 select
119 accept Do_Launch do
120 Launch_Control.Start_Countdown (Countdown_Amount);
121 requeue Launch_Control.Launch with abort;
122 end Do_Launch;
124 terminate;
125 end select;
126 end loop;
127 end Mission_Control;
129 begin -- test encapsulation
130 -- unconditional entry call to check the simple case
131 Launch_Control.Enable_Launch_Control;
132 Mission_Control.Do_Launch;
133 if Launch_Accepted then
134 if Verbose then
135 Report.Comment ("simple case passed");
136 end if;
137 else
138 Report.Failed ("simple case");
139 end if;
142 -- timed but with plenty of time - delay relative
143 Launch_Control.Enable_Launch_Control;
144 select
145 Mission_Control.Do_Launch;
147 delay Plenty_Of_Time;
148 if Launch_Accepted then
149 Report.Failed ("plenty of time timed out after accept (1)");
150 end if;
151 end select;
152 if Launch_Accepted then
153 if Verbose then
154 Report.Comment ("plenty of time case passed (1)");
155 end if;
156 else
157 Report.Failed ("plenty of time (1)");
158 end if;
161 -- timed but with plenty of time -- delay until
162 Launch_Control.Enable_Launch_Control;
163 select
164 Mission_Control.Do_Launch;
166 delay until Calendar.Clock + Plenty_Of_Time;
167 if Launch_Accepted then
168 Report.Failed ("plenty of time timed out after accept(2)");
169 end if;
170 end select;
171 if Launch_Accepted then
172 if Verbose then
173 Report.Comment ("plenty of time case passed (2)");
174 end if;
175 else
176 Report.Failed ("plenty of time (2)");
177 end if;
180 -- timed without enough time - delay relative
181 Launch_Control.Enable_Launch_Control;
182 select
183 Mission_Control.Do_Launch;
184 Report.Failed ("not enough time completed accept (1)");
186 delay Not_Enough_Time;
187 end select;
188 if Launch_Accepted then
189 Report.Failed ("not enough time (1)");
190 else
191 if Verbose then
192 Report.Comment ("not enough time case passed (1)");
193 end if;
194 end if;
197 -- timed without enough time - delay until
198 Launch_Control.Enable_Launch_Control;
199 select
200 Mission_Control.Do_Launch;
201 Report.Failed ("not enough time completed accept (2)");
203 delay until Calendar.Clock + Not_Enough_Time;
204 end select;
205 if Launch_Accepted then
206 Report.Failed ("not enough time (2)");
207 else
208 if Verbose then
209 Report.Comment ("not enough time case passed (2)");
210 end if;
211 end if;
214 -- conditional case
215 Launch_Control.Enable_Launch_Control;
216 -- make sure Mission_Control is ready to accept immediately
217 delay ImpDef.Clear_Ready_Queue;
218 select
219 Mission_Control.Do_Launch;
220 Report.Failed ("no time completed accept");
221 else
222 if Verbose then
223 Report.Comment ("conditional case - else taken");
224 end if;
225 end select;
226 if Launch_Accepted then
227 Report.Failed ("no time");
228 else
229 if Verbose then
230 Report.Comment ("no time case passed");
231 end if;
232 end if;
234 end;
236 Report.Result;
237 end C954025;