annotate gcc/testsuite/ada/acats/tests/c9/c974010.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 -- C974010.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 the abortable part of an asynchronous select statement
kono
parents:
diff changeset
28 -- is not started if the triggering statement is a task entry call to
kono
parents:
diff changeset
29 -- a task that has already terminated.
kono
parents:
diff changeset
30 --
kono
parents:
diff changeset
31 -- Check that Tasking_Error is properly propagated to the asynchronous
kono
parents:
diff changeset
32 -- select statement and thus the sequence of statements of the triggering
kono
parents:
diff changeset
33 -- alternative is not executed after the abortable part is left.
kono
parents:
diff changeset
34 --
kono
parents:
diff changeset
35 -- Check that Tasking_Error is re-raised immediately following the
kono
parents:
diff changeset
36 -- asynchronous select.
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- TEST DESCRIPTION:
kono
parents:
diff changeset
39 --
kono
parents:
diff changeset
40 -- Use a small subset of the base Automated Teller Machine simulation
kono
parents:
diff changeset
41 -- which is shown in greater detail in other tests of this series.
kono
parents:
diff changeset
42 -- Declare a main procedure containing an asynchronous select with a task
kono
parents:
diff changeset
43 -- entry call as triggering statement. Ensure that the task is
kono
parents:
diff changeset
44 -- terminated before the entry call. Use stripped down versions of
kono
parents:
diff changeset
45 -- the called procedures to check the correct path in the test.
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 -- CHANGE HISTORY:
kono
parents:
diff changeset
49 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
50 --
kono
parents:
diff changeset
51 --!
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 package C974010_0 is -- Automated teller machine abstraction.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 Transaction_Canceled : exception;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type Key_Enum is (None, Cancel, Deposit, Withdraw);
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 type Card_Number_Type is private;
kono
parents:
diff changeset
61 type Card_PIN_Type is private;
kono
parents:
diff changeset
62 type ATM_Card_Type is private;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 task type ATM_Keyboard_Task is
kono
parents:
diff changeset
65 entry Cancel_Pressed;
kono
parents:
diff changeset
66 end ATM_Keyboard_Task;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 procedure Validate_Card (Card : in ATM_Card_Type);
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 procedure Perform_Transaction (Card : in ATM_Card_Type);
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 private
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type Card_Number_Type is range 1 .. 9999;
kono
parents:
diff changeset
77 type Card_PIN_Type is range 100 .. 999;
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 type ATM_Card_Type is record
kono
parents:
diff changeset
80 Number : Card_Number_Type;
kono
parents:
diff changeset
81 PIN : Card_PIN_Type;
kono
parents:
diff changeset
82 end record;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 end C974010_0;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 --==================================================================--
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 with Report;
kono
parents:
diff changeset
91 package body C974010_0 is
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 -- One of these gets created as "Keyboard" for each transaction
kono
parents:
diff changeset
96 --
kono
parents:
diff changeset
97 task body ATM_Keyboard_Task is
kono
parents:
diff changeset
98 TC_Suicide : exception;
kono
parents:
diff changeset
99 Key_Pressed : Key_Enum := None;
kono
parents:
diff changeset
100 begin
kono
parents:
diff changeset
101 raise TC_Suicide; -- Simulate early, unexpected termination
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 accept Cancel_Pressed do -- queued entry call.
kono
parents:
diff changeset
104 null; --:::: user code for cancel
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 end Cancel_Pressed;
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 exception
kono
parents:
diff changeset
109 when TC_Suicide =>
kono
parents:
diff changeset
110 null; -- This is the expected test behavior
kono
parents:
diff changeset
111 when others =>
kono
parents:
diff changeset
112 Report.Failed ("Unexpected Exception in ATM_Keyboard_Task");
kono
parents:
diff changeset
113 end ATM_Keyboard_Task;
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 procedure Validate_Card (Card : in ATM_Card_Type) is
kono
parents:
diff changeset
116 begin
kono
parents:
diff changeset
117 Report.Failed ("Abortable part was executed");
kono
parents:
diff changeset
118 end Validate_Card;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 procedure Perform_Transaction (Card : in ATM_Card_Type) is
kono
parents:
diff changeset
122 begin
kono
parents:
diff changeset
123 Report.Failed ("Exception not re-raised immediately following " &
kono
parents:
diff changeset
124 "asynchronous select");
kono
parents:
diff changeset
125 end Perform_Transaction;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 end C974010_0;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 --==================================================================--
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 with Report;
kono
parents:
diff changeset
135 with ImpDef;
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 with C974010_0; -- Automated teller machine abstraction.
kono
parents:
diff changeset
138 use C974010_0;
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 procedure C974010 is
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 Card_Data : ATM_Card_Type;
kono
parents:
diff changeset
143 TC_Tasking_Error_Handled : Boolean := false;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 begin -- Main program.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 Report.Test ("C974010", "Asynchronous Select: Trigger is a call to a " &
kono
parents:
diff changeset
148 "task entry of a task that is already completed");
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 declare
kono
parents:
diff changeset
152 -- Create the task for this transaction
kono
parents:
diff changeset
153 Keyboard : C974010_0.ATM_Keyboard_Task;
kono
parents:
diff changeset
154 begin
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 -- Ensure the task is already completed before calling
kono
parents:
diff changeset
157 --
kono
parents:
diff changeset
158 while not Keyboard'terminated loop
kono
parents:
diff changeset
159 delay ImpDef.Minimum_Task_Switch;
kono
parents:
diff changeset
160 end loop;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 -- --
kono
parents:
diff changeset
163 -- Asynchronous select is tested here --
kono
parents:
diff changeset
164 -- --
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 select
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 Keyboard.Cancel_Pressed;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 raise Transaction_Canceled; -- Should not be executed.
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 then abort
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 -- Since the triggering call is not queued the abortable part
kono
parents:
diff changeset
175 -- should not be executed.
kono
parents:
diff changeset
176 --
kono
parents:
diff changeset
177 Validate_Card (Card_Data);
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 end select;
kono
parents:
diff changeset
180 --
kono
parents:
diff changeset
181 -- The propagated exception is re-raised here.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 Perform_Transaction(Card_Data); -- Should not be reached.
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 exception
kono
parents:
diff changeset
186 when Transaction_Canceled =>
kono
parents:
diff changeset
187 Report.Failed ("Triggering alternative sequence of statements " &
kono
parents:
diff changeset
188 "executed");
kono
parents:
diff changeset
189 when Tasking_Error =>
kono
parents:
diff changeset
190 -- This is the expected test path
kono
parents:
diff changeset
191 TC_Tasking_Error_Handled := true;
kono
parents:
diff changeset
192 when others =>
kono
parents:
diff changeset
193 Report.Failed ("Wrong exception raised: ");
kono
parents:
diff changeset
194 end;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 if not TC_Tasking_Error_Handled then
kono
parents:
diff changeset
198 Report.Failed ("Tasking_Error not properly propagated");
kono
parents:
diff changeset
199 end if;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 Report.Result;
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 exception
kono
parents:
diff changeset
204 when Tasking_Error =>
kono
parents:
diff changeset
205 Report.Failed ("Tasking_Error propagated to wrong handler");
kono
parents:
diff changeset
206 Report.Result;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 end C974010;