annotate gcc/testsuite/ada/acats/tests/c9/c974007.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 -- C974007.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 sequence of statements of the triggering alternative
kono
parents:
diff changeset
28 -- of an asynchronous select statement is not executed if the triggering
kono
parents:
diff changeset
29 -- statement is a protected entry call, and the entry is not accepted
kono
parents:
diff changeset
30 -- before the abortable part completes. Check that execution continues
kono
parents:
diff changeset
31 -- immediately following the asynchronous select.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION:
kono
parents:
diff changeset
34 -- Declare a main procedure containing an asynchronous select with a
kono
parents:
diff changeset
35 -- protected entry call as triggering statement. Declare a protected
kono
parents:
diff changeset
36 -- procedure which sets the protected entry's barrier true. Ensure
kono
parents:
diff changeset
37 -- that the entry call is never accepted by not calling the protected
kono
parents:
diff changeset
38 -- procedure; the barrier remains false, and the entry call from
kono
parents:
diff changeset
39 -- asynchronous select is queued. Since the abortable part will complete
kono
parents:
diff changeset
40 -- before the entry is accepted, the sequence of statements of the
kono
parents:
diff changeset
41 -- triggering alternative is never executed.
kono
parents:
diff changeset
42 --
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 -- CHANGE HISTORY:
kono
parents:
diff changeset
45 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
46 --
kono
parents:
diff changeset
47 --!
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 package C974007_0 is -- Automated teller machine abstraction.
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 -- Flags for testing purposes:
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 Abortable_Part_Executed : Boolean := False;
kono
parents:
diff changeset
56 Perform_Transaction_Executed : Boolean := False;
kono
parents:
diff changeset
57 Triggering_Statement_Executed : Boolean := False;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 type Key_Enum is (None, Cancel, Deposit, Withdraw);
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 type Card_Number_Type is private;
kono
parents:
diff changeset
63 type Card_PIN_Type is private;
kono
parents:
diff changeset
64 type ATM_Card_Type is private;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 Transaction_Canceled : exception;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 protected type ATM_Keyboard_Protected is
kono
parents:
diff changeset
71 entry Cancel_Pressed;
kono
parents:
diff changeset
72 procedure Read_Key;
kono
parents:
diff changeset
73 private
kono
parents:
diff changeset
74 Last_Key_Pressed : Key_Enum := None;
kono
parents:
diff changeset
75 end ATM_Keyboard_Protected;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 procedure Read_Card (Card : in out ATM_Card_Type);
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Validate_Card (Card : in ATM_Card_Type);
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 procedure Perform_Transaction (Card : in ATM_Card_Type);
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 private
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type Card_Number_Type is range 1 .. 9999;
kono
parents:
diff changeset
87 type Card_PIN_Type is range 100 .. 999;
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 type ATM_Card_Type is record
kono
parents:
diff changeset
90 Number : Card_Number_Type;
kono
parents:
diff changeset
91 PIN : Card_PIN_Type;
kono
parents:
diff changeset
92 end record;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 end C974007_0;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 --==================================================================--
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 with Report;
kono
parents:
diff changeset
101 package body C974007_0 is
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 protected body ATM_Keyboard_Protected is
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- Barrier is false for the live of the test
kono
parents:
diff changeset
107 entry Cancel_Pressed when (Last_Key_Pressed = Cancel) is
kono
parents:
diff changeset
108 begin
kono
parents:
diff changeset
109 Triggering_Statement_Executed := true; -- Test has failed
kono
parents:
diff changeset
110 -- (Note: cannot call Report.Failed in the protected entry body]
kono
parents:
diff changeset
111 end Cancel_Pressed;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Read_Key is -- Never
kono
parents:
diff changeset
114 begin -- called.
kono
parents:
diff changeset
115 -- Simulate a procedure which reads user keyboard input, and
kono
parents:
diff changeset
116 -- which is called by some interrupt handler.
kono
parents:
diff changeset
117 Last_Key_Pressed := Cancel;
kono
parents:
diff changeset
118 end Read_Key;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 end ATM_Keyboard_Protected;
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Read_Card (Card : in out ATM_Card_Type) is
kono
parents:
diff changeset
124 begin
kono
parents:
diff changeset
125 Card.Number := 9999;
kono
parents:
diff changeset
126 Card.PIN := 111;
kono
parents:
diff changeset
127 end Read_Card;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 procedure Validate_Card (Card : in ATM_Card_Type) is
kono
parents:
diff changeset
131 begin
kono
parents:
diff changeset
132 Abortable_Part_Executed := True;
kono
parents:
diff changeset
133 end Validate_Card;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 procedure Perform_Transaction (Card : in ATM_Card_Type) is
kono
parents:
diff changeset
137 begin
kono
parents:
diff changeset
138 Perform_Transaction_Executed := True;
kono
parents:
diff changeset
139 end Perform_Transaction;
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 end C974007_0;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 --==================================================================--
kono
parents:
diff changeset
146 with Report;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 with C974007_0; -- Automated teller machine abstraction.
kono
parents:
diff changeset
149 use C974007_0;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 procedure C974007 is
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 Card_Data : ATM_Card_Type;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 begin
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 Report.Test ("C974007", "ATC: trigger is protected entry call" &
kono
parents:
diff changeset
158 " and abortable part completes first");
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 Read_Card (Card_Data);
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 declare
kono
parents:
diff changeset
163 Keyboard : C974007_0.ATM_Keyboard_Protected;
kono
parents:
diff changeset
164 begin
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- --
kono
parents:
diff changeset
167 -- Asynchronous select is tested here --
kono
parents:
diff changeset
168 -- --
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 select
kono
parents:
diff changeset
171 Keyboard.Cancel_Pressed; -- Barrier is never set true, so
kono
parents:
diff changeset
172 -- entry call is queued and never
kono
parents:
diff changeset
173 -- accepted.
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 raise Transaction_Canceled; -- Should not be executed.
kono
parents:
diff changeset
176 then abort
kono
parents:
diff changeset
177 Validate_Card (Card_Data); -- This call completes before
kono
parents:
diff changeset
178 -- Keyboard.Cancel_Pressed can be
kono
parents:
diff changeset
179 -- accepted.
kono
parents:
diff changeset
180 end select;
kono
parents:
diff changeset
181 Perform_Transaction (Card_Data); -- Execution proceeds here after
kono
parents:
diff changeset
182 -- Validate_Card completes.
kono
parents:
diff changeset
183 exception
kono
parents:
diff changeset
184 when Transaction_Canceled =>
kono
parents:
diff changeset
185 Report.Failed ("Triggering alternative sequence of statements " &
kono
parents:
diff changeset
186 "executed");
kono
parents:
diff changeset
187 end;
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 if Triggering_Statement_Executed then
kono
parents:
diff changeset
191 Report.Failed ("Triggering statement was executed");
kono
parents:
diff changeset
192 end if;
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 if not Abortable_Part_Executed then
kono
parents:
diff changeset
195 Report.Failed ("Abortable part not executed");
kono
parents:
diff changeset
196 end if;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 if not Perform_Transaction_Executed then
kono
parents:
diff changeset
199 Report.Failed ("Statements following asynchronous select not " &
kono
parents:
diff changeset
200 "executed");
kono
parents:
diff changeset
201 end if;
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 Report.Result;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 end C974007;