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