Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/ada/acats/tests/c9/c974002.a @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 -- C974002.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 the sequence of statements of the triggering alternative | |
28 -- of an asynchronous select statement is executed if the triggering | |
29 -- statement is a delay_until statement, and the specified time has | |
30 -- already passed. Check that the abortable part is not executed after | |
31 -- the sequence of statements of the triggering alternative is left. | |
32 -- | |
33 -- Check that the sequence of statements of the triggering alternative | |
34 -- of an asynchronous select statement is not executed if the abortable | |
35 -- part completes before the triggering statement, and the triggering | |
36 -- statement is a delay_until statement. | |
37 -- | |
38 -- TEST DESCRIPTION: | |
39 -- Declare a task with an accept statement containing an asynchronous | |
40 -- select with a delay_until triggering statement. Parameterize | |
41 -- the accept statement with the time to be used in the delay. Simulate | |
42 -- a quick calculation by declaring a procedure which sets a Boolean | |
43 -- flag. Call this procedure in the abortable part. | |
44 -- | |
45 -- Make two calls to the task entry: (1) with a time that has already | |
46 -- expired, and (2) with a time that will not expire before the quick | |
47 -- calculation completes. | |
48 -- | |
49 -- For (1), the sequence of statements following the triggering statement | |
50 -- is executed, and the abortable part never starts. | |
51 -- | |
52 -- For (2), the abortable part completes before the triggering statement, | |
53 -- the delay is canceled, and the sequence of statements following the | |
54 -- triggering statement never starts. | |
55 -- | |
56 -- | |
57 -- CHANGE HISTORY: | |
58 -- 06 Dec 94 SAIC ACVC 2.0 | |
59 -- 26 Nov 95 SAIC Bug fix for ACVC 2.0.1. | |
60 -- | |
61 --! | |
62 | |
63 with Report; | |
64 with Ada.Calendar; | |
65 with ImpDef; | |
66 procedure C974002 is | |
67 | |
68 function "-" (Left: Ada.Calendar.Time; Right: Duration ) | |
69 return Ada.Calendar.Time renames Ada.Calendar."-"; | |
70 function "+" (Left: Ada.Calendar.Time; Right: Duration ) | |
71 return Ada.Calendar.Time renames Ada.Calendar."+"; | |
72 | |
73 Abortable_Part_Executed : Boolean; | |
74 Triggering_Alternative_Executed : Boolean; | |
75 | |
76 | |
77 --========================================================-- | |
78 | |
79 | |
80 procedure Quick_Calculation is | |
81 begin | |
82 if Report.Equal (1, 1) then | |
83 Abortable_Part_Executed := True; | |
84 end if; | |
85 end Quick_Calculation; | |
86 | |
87 | |
88 --========================================================-- | |
89 | |
90 | |
91 task type Timed_Calculation_Task is | |
92 entry Calculation (Time_Out : in Ada.Calendar.Time); | |
93 end Timed_Calculation_Task; | |
94 | |
95 | |
96 task body Timed_Calculation_Task is | |
97 begin | |
98 loop | |
99 select | |
100 accept Calculation (Time_Out : in Ada.Calendar.Time) do | |
101 | |
102 -- -- | |
103 -- Asynchronous select is tested here -- | |
104 -- -- | |
105 | |
106 select | |
107 delay until Time_Out; -- Triggering | |
108 -- statement. | |
109 | |
110 Triggering_Alternative_Executed := True; -- Triggering | |
111 -- alternative. | |
112 then abort | |
113 Quick_Calculation; -- Abortable part. | |
114 end select; | |
115 end Calculation; | |
116 or | |
117 terminate; | |
118 end select; | |
119 end loop; | |
120 exception | |
121 when others => | |
122 Report.Failed ("Unexpected exception in Timed_Calculation_Task"); | |
123 end Timed_Calculation_Task; | |
124 | |
125 | |
126 --========================================================-- | |
127 | |
128 | |
129 Start_Time : constant Ada.Calendar.Time := | |
130 Ada.Calendar.Time_of (1901,1,1); | |
131 Minute : constant Duration := 60.0; | |
132 | |
133 | |
134 --========================================================-- | |
135 | |
136 | |
137 begin -- Main program. | |
138 | |
139 Report.Test ("C974002", "Asynchronous Select with Delay_Until"); | |
140 | |
141 -- take care of implementations that start the clock at 1/1/01 | |
142 delay ImpDef.Delay_For_Time_Past; | |
143 | |
144 | |
145 Abortable_Part_Executed := False; | |
146 Triggering_Alternative_Executed := False; | |
147 | |
148 NO_DELAY_SUBTEST: | |
149 | |
150 declare | |
151 -- Set Expiry to a time which has already passed | |
152 Expiry : constant Ada.Calendar.Time := Start_Time; | |
153 Timed : Timed_Calculation_Task; | |
154 begin | |
155 | |
156 -- Expiry is the time to be specified in the delay_until statement | |
157 -- of the asynchronous select. Since it has already passed, the | |
158 -- abortable part should not execute, and the sequence of statements | |
159 -- of the triggering alternative should be executed. | |
160 | |
161 Timed.Calculation (Time_Out => Expiry); -- Asynchronous select | |
162 -- inside accept block. | |
163 if Abortable_Part_Executed then | |
164 Report.Failed ("No delay: Abortable part was executed"); | |
165 end if; | |
166 | |
167 if not Triggering_Alternative_Executed then | |
168 Report.Failed ("No delay: triggering alternative sequence " & | |
169 "of statements was not executed"); | |
170 end if; | |
171 end No_Delay_Subtest; | |
172 | |
173 | |
174 Abortable_Part_Executed := False; | |
175 Triggering_Alternative_Executed := False; | |
176 | |
177 LONG_DELAY_SUBTEST: | |
178 | |
179 declare | |
180 | |
181 -- Quick_Calculation should finish before expiry. | |
182 Expiry : constant Ada.Calendar.Time := | |
183 Ada.Calendar.Clock + Minute; | |
184 Timed : Timed_Calculation_Task; | |
185 | |
186 begin | |
187 | |
188 -- Expiry is the time to be specified in the delay_until statement | |
189 -- of the asynchronous select. It should not pass before the abortable | |
190 -- part completes, at which time control should return to the caller; | |
191 -- the sequence of statements of the triggering alternative should | |
192 -- not be executed. | |
193 | |
194 Timed.Calculation (Time_Out => Expiry); -- Asynchronous select. | |
195 | |
196 if not Abortable_Part_Executed then | |
197 Report.Failed ("Long delay: Abortable part was not executed"); | |
198 end if; | |
199 | |
200 if Triggering_Alternative_Executed then | |
201 Report.Failed ("Long delay: triggering alternative sequence " & | |
202 "of statements was executed"); | |
203 end if; | |
204 end Long_Delay_Subtest; | |
205 | |
206 | |
207 Report.Result; | |
208 | |
209 end C974002; |