annotate gcc/testsuite/ada/acats/tests/c9/c960004.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 -- C960004.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 -- With the triggering statement being a delay and with the Asynchronous
kono
parents:
diff changeset
28 -- Select statement being in a tasking situation complete the abortable
kono
parents:
diff changeset
29 -- part before the delay expires. Check that the delay is cancelled
kono
parents:
diff changeset
30 -- and that the optional statements in the triggering part are not
kono
parents:
diff changeset
31 -- executed.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- TEST DESCRIPTION:
kono
parents:
diff changeset
34 -- Simulate the creation of a carrier task to control the output of
kono
parents:
diff changeset
35 -- a message via a line driver. If the message sending process is
kono
parents:
diff changeset
36 -- not complete (the completion of the rendezvous) within a
kono
parents:
diff changeset
37 -- specified time the carrier task is designed to take corrective action.
kono
parents:
diff changeset
38 -- Use an asynchronous select to control the timing; arrange that
kono
parents:
diff changeset
39 -- the abortable part (the rendezvous) completes almost immediately.
kono
parents:
diff changeset
40 -- Check that the optional statements are not executed and that the
kono
parents:
diff changeset
41 -- test completes well before the time of the trigger delay request thus
kono
parents:
diff changeset
42 -- showing that it has been cancelled.
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 --
kono
parents:
diff changeset
45 -- CHANGE HISTORY:
kono
parents:
diff changeset
46 -- 06 Dec 94 SAIC ACVC 2.0
kono
parents:
diff changeset
47 --
kono
parents:
diff changeset
48 --!
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 with Report;
kono
parents:
diff changeset
52 with Ada.Calendar;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure C960004 is
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 function "-" (Left, Right : Ada.Calendar.Time)
kono
parents:
diff changeset
57 return Duration renames Ada.Calendar."-";
kono
parents:
diff changeset
58 TC_Start_Time : Ada.Calendar.Time := Ada.Calendar.Clock;
kono
parents:
diff changeset
59 TC_Elapsed_Time : duration;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 -- Note: a properly executing test will complete immediately.
kono
parents:
diff changeset
62 Allowable_ACK_Time : duration := 600.0;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 begin
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Report.Test ("C960004", "ATC: When abortable part completes before " &
kono
parents:
diff changeset
67 "a triggering delay, check that the delay " &
kono
parents:
diff changeset
68 "is cancelled & optional statements " &
kono
parents:
diff changeset
69 "are not performed. Tasking situation");
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 declare -- To get the Report.Result after all has completed
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 type Sequence_Number is range 1..1_999_999; -- Message Number
kono
parents:
diff changeset
74 subtype S_length_subtype is integer range 1..80;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 type Message_Type (Max_String : S_length_subtype := 1) is
kono
parents:
diff changeset
77 record
kono
parents:
diff changeset
78 Message_Number : Sequence_Number;
kono
parents:
diff changeset
79 Alpha : string(1..Max_String);
kono
parents:
diff changeset
80 end record;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 -- TC: Dummy message for the test
kono
parents:
diff changeset
83 Dummy_Alpha : constant string := "This could be printed";
kono
parents:
diff changeset
84 Message_to_Send : Message_Type (Max_string => Dummy_Alpha'length);
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 -- This is the carrier task. One of these is created for each
kono
parents:
diff changeset
88 -- message that requires ACK
kono
parents:
diff changeset
89 --
kono
parents:
diff changeset
90 task type Require_ACK_task is
kono
parents:
diff changeset
91 entry Message_In (Message_to_Send: Message_Type);
kono
parents:
diff changeset
92 end Require_ACK_task;
kono
parents:
diff changeset
93 type acc_Require_ACK_task is access Require_ACK_task;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 --:::::::::::::::::::::::::::::::::
kono
parents:
diff changeset
97 -- There would also be another task type "No_ACK_Task" which would
kono
parents:
diff changeset
98 -- be the carrier task for those messages not requiring an ACK.
kono
parents:
diff changeset
99 -- This task would call Send_Message.ACK_Not_Required. It is not
kono
parents:
diff changeset
100 -- shown in this test as it is not used.
kono
parents:
diff changeset
101 --:::::::::::::::::::::::::::::::::
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 task Send_Message is
kono
parents:
diff changeset
106 entry ACK_Required (Message_to_Send: Message_Type);
kono
parents:
diff changeset
107 entry ACK_Not_Required (Message_to_Send: Message_Type);
kono
parents:
diff changeset
108 end Send_Message;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 -- This is the carrier task. One of these is created for each
kono
parents:
diff changeset
112 -- message that requires ACK
kono
parents:
diff changeset
113 --
kono
parents:
diff changeset
114 task body Require_ACK_task is
kono
parents:
diff changeset
115 Hold_Message : Message_Type;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure Time_Out (Failed_Message_Number : Sequence_Number) is
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 -- Take remedial action on the timed-out message
kono
parents:
diff changeset
120 null; -- stub
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 Report.Failed ("Optional statements in triggering part" &
kono
parents:
diff changeset
123 " were performed");
kono
parents:
diff changeset
124 end Time_out;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 begin
kono
parents:
diff changeset
127 accept Message_In (Message_to_Send: Message_Type) do
kono
parents:
diff changeset
128 Hold_Message := Message_to_Send; -- to release caller
kono
parents:
diff changeset
129 end Message_In;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 -- Now put the message out to the Send_Message task and
kono
parents:
diff changeset
132 -- wait (no more than Allowable_Ack_Time) for its completion
kono
parents:
diff changeset
133 --
kono
parents:
diff changeset
134 select
kono
parents:
diff changeset
135 delay Allowable_ACK_Time;
kono
parents:
diff changeset
136 -- ACK not received in specified time
kono
parents:
diff changeset
137 Time_out (Hold_Message.Message_Number);
kono
parents:
diff changeset
138 then abort
kono
parents:
diff changeset
139 -- If the rendezvous is not completed in the above time, this
kono
parents:
diff changeset
140 -- call is cancelled
kono
parents:
diff changeset
141 -- Note: for this test this call will complete immediately
kono
parents:
diff changeset
142 -- and thus the trigger should be cancelled
kono
parents:
diff changeset
143 Send_Message.ACK_Required (Hold_Message);
kono
parents:
diff changeset
144 end select;
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 exception
kono
parents:
diff changeset
147 when others =>
kono
parents:
diff changeset
148 Report.Failed ("Unexpected exception in Require_ACK_task");
kono
parents:
diff changeset
149 end Require_ACK_task;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 -- This is the Line Driver task
kono
parents:
diff changeset
153 --
kono
parents:
diff changeset
154 task body Send_Message is
kono
parents:
diff changeset
155 Hold_Non_ACK_Message : Message_Type;
kono
parents:
diff changeset
156 begin
kono
parents:
diff changeset
157 loop
kono
parents:
diff changeset
158 select
kono
parents:
diff changeset
159 accept ACK_Required (Message_to_Send: Message_Type) do
kono
parents:
diff changeset
160 -- Here send the message from within the rendezvous
kono
parents:
diff changeset
161 -- waiting for full transmission to complete
kono
parents:
diff changeset
162 null; -- stub
kono
parents:
diff changeset
163 -- Note: In this test this accept will complete immediately
kono
parents:
diff changeset
164 end ACK_Required;
kono
parents:
diff changeset
165 or
kono
parents:
diff changeset
166 accept ACK_Not_Required (Message_to_Send: Message_Type) do
kono
parents:
diff changeset
167 Hold_Non_ACK_Message := Message_to_Send;
kono
parents:
diff changeset
168 end ACK_Not_Required;
kono
parents:
diff changeset
169 -- Here send the message from outside the rendezvous
kono
parents:
diff changeset
170 null; -- stub
kono
parents:
diff changeset
171 or
kono
parents:
diff changeset
172 terminate;
kono
parents:
diff changeset
173 end select;
kono
parents:
diff changeset
174 end loop;
kono
parents:
diff changeset
175 exception
kono
parents:
diff changeset
176 when others => Report.Failed ("Unexpected exception in Send_Message");
kono
parents:
diff changeset
177 end Send_Message;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 begin -- declare
kono
parents:
diff changeset
180 -- Build a dummy message
kono
parents:
diff changeset
181 Message_to_Send.Alpha := Dummy_Alpha;
kono
parents:
diff changeset
182 Message_to_Send.Message_Number := 110_693;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 declare
kono
parents:
diff changeset
185 New_Require_ACK_task : acc_Require_ACK_task :=
kono
parents:
diff changeset
186 new Require_ACK_task;
kono
parents:
diff changeset
187 begin
kono
parents:
diff changeset
188 -- Create a carrier task for this message and pass the latter in
kono
parents:
diff changeset
189 New_Require_ACK_task.Message_In (Message_to_Send);
kono
parents:
diff changeset
190 end; -- declare
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 end; -- declare
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 --Once we are out of the above declarative region, all tasks have completed
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 TC_Elapsed_Time := Ada.Calendar.Clock - TC_Start_Time;
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 -- Check that the test has completed well before the time of the requested
kono
parents:
diff changeset
199 -- delay to ensure the delay was cancelled
kono
parents:
diff changeset
200 --
kono
parents:
diff changeset
201 if (TC_Elapsed_Time > Allowable_ACK_Time/2) then
kono
parents:
diff changeset
202 Report.Failed ("Triggering delay statement was not cancelled");
kono
parents:
diff changeset
203 end if;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 Report.Result;
kono
parents:
diff changeset
206 end C960004;