OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c9/] [c954026.a] - Blame information for rev 294

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- C954026.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 if the original protected entry call was a conditional
28
--      entry call, the call is cancelled if a requeue-with-abort of the
29
--      call is not selected immediately.
30
--      Check that if the original protected entry call was a timed entry
31
--      call, the expiration time for a requeue-with-abort is the original
32
--      expiration time.
33
--
34
-- TEST DESCRIPTION:
35
--      In this test the main task makes a variety of calls to the protected
36
--      object Initial_PO.  These calls include a simple call, a conditional
37
--      call, and a timed call.  The timed calls include calls with enough
38
--      time and those with less than the needed amount of time to get through
39
--      the requeue performed by Initial_PO.
40
--      Initial_PO requeues its entry call to Final_PO.
41
--      Final_PO does not accept the requeued call until the protected
42
--      procedure Ok_To_Take_Requeue is called.
43
--      A separate task, Delayed_Opener, is used to call Ok_To_Take_Requeue
44
--      after a delay amount specified by the main task has expired.
45
--
46
--
47
-- CHANGE HISTORY:
48
--      15 DEC 95   SAIC    ACVC 2.1
49
--      10 JUL 96   SAIC    Incorporated reviewer comments.
50
--      10 OCT 96   SAIC    Incorporated fix provided by vendor.
51
--
52
--!
53
 
54
with Calendar;
55
use type Calendar.Time;
56
with Report;
57
with Impdef;
58
procedure C954026 is
59
    Verbose : constant Boolean := False;
60
    Final_Po_Reached : Boolean := False;
61
    Allowed_Time : constant Duration := 2.0 * Impdef.One_Long_Second;
62
    Plenty_Of_Time : constant Duration :=
63
       Allowed_Time + Impdef.Clear_Ready_Queue + 1.0 * Impdef.One_Long_Second;
64
    Not_Enough_Time : constant Duration := Allowed_Time - 0.5 * Impdef.One_Long_Second;
65
begin
66
    Report.Test ("C954026",
67
                 "Check that if the original entry" &
68
                    " call was a conditional or timed entry call," &
69
                    " the expiration time for a requeue with" &
70
                    " abort to a protected" &
71
                    " entry is the original expiration time");
72
    declare
73
 
74
        protected Initial_Po is
75
            entry Start_Here;
76
        end Initial_Po;
77
 
78
        protected Final_Po is
79
            entry Requeue_Target;
80
            procedure Ok_To_Take_Requeue;
81
            procedure Close_Requeue;
82
        private
83
            Open : Boolean := False;
84
        end Final_Po;
85
 
86
        -- the Delayed_Opener task is used to notify Final_PO that it can
87
        -- accept the Requeue_Target entry.
88
        task Delayed_Opener is
89
            entry Start_Timer (Amt : Duration);
90
            entry Cancel_Timer;
91
        end Delayed_Opener;
92
 
93
        task body Delayed_Opener is
94
            Wait_Amt : Duration;
95
        begin
96
            loop
97
                accept Start_Timer (Amt : Duration) do
98
                    Wait_Amt := Amt;
99
                end Start_Timer;
100
                exit when Wait_Amt < 0.0;
101
                if Verbose then
102
                    Report.Comment ("Timer started");
103
                end if;
104
                select
105
                    accept Cancel_Timer do
106
                        Final_Po.Close_Requeue;
107
                    end Cancel_Timer;
108
                or
109
                    delay Wait_Amt;
110
                    Final_Po.Ok_To_Take_Requeue;
111
                    accept Cancel_Timer do
112
                        Final_Po.Close_Requeue;
113
                    end Cancel_Timer;
114
                end select;
115
            end loop;
116
        exception
117
            when others =>
118
                Report.Failed ("exception in Delayed_Opener");
119
        end Delayed_Opener;
120
 
121
        protected body Initial_Po is
122
            entry Start_Here when True is
123
            begin
124
                Final_Po_Reached := False;
125
                requeue Final_Po.Requeue_Target with abort;
126
            end Start_Here;
127
        end Initial_Po;
128
 
129
        protected body Final_Po is
130
            entry Requeue_Target when Open is
131
            begin
132
                Open := False;
133
                Final_Po_Reached := True;
134
            end Requeue_Target;
135
 
136
            procedure Ok_To_Take_Requeue is
137
            begin
138
                Open := True;
139
            end Ok_To_Take_Requeue;
140
 
141
            procedure Close_Requeue is
142
            begin
143
                Open := False;
144
            end Close_Requeue;
145
        end Final_Po;
146
 
147
    begin   -- test encapsulation
148
        -- unconditional entry call to check the simple case
149
        Delayed_Opener.Start_Timer (0.0);
150
        Initial_Po.Start_Here;
151
        if Final_Po_Reached then
152
            if Verbose then
153
                Report.Comment ("simple case passed");
154
            end if;
155
        else
156
            Report.Failed ("simple case");
157
        end if;
158
        Delayed_Opener.Cancel_Timer;
159
 
160
 
161
        -- timed but with plenty of time - delay relative
162
        Delayed_Opener.Start_Timer (Allowed_Time);
163
        select
164
            Initial_Po.Start_Here;
165
        or
166
            delay Plenty_Of_Time;
167
            Report.Failed ("plenty of time timed out (1)");
168
            if Final_Po_Reached then
169
                Report.Failed (
170
                   "plenty of time timed out after accept (1)");
171
            end if;
172
        end select;
173
        if Final_Po_Reached then
174
            if Verbose then
175
                Report.Comment ("plenty of time case passed (1)");
176
            end if;
177
        else
178
            Report.Failed ("plenty of time (1)");
179
        end if;
180
        Delayed_Opener.Cancel_Timer;
181
 
182
 
183
        -- timed but with plenty of time  -- delay until
184
        Delayed_Opener.Start_Timer (Allowed_Time);
185
        select
186
            Initial_Po.Start_Here;
187
        or
188
            delay until Calendar.Clock + Plenty_Of_Time;
189
            Report.Failed ("plenty of time timed out (2)");
190
            if Final_Po_Reached then
191
                Report.Failed (
192
                  "plenty of time timed out after accept(2)");
193
            end if;
194
        end select;
195
        if Final_Po_Reached then
196
            if Verbose then
197
                Report.Comment ("plenty of time case passed (2)");
198
            end if;
199
        else
200
            Report.Failed ("plenty of time (2)");
201
        end if;
202
        Delayed_Opener.Cancel_Timer;
203
 
204
 
205
        -- timed without enough time - delay relative
206
        Delayed_Opener.Start_Timer (Allowed_Time);
207
        select
208
            Initial_Po.Start_Here;
209
            Report.Failed ("not enough time completed accept (1)");
210
        or
211
            delay Not_Enough_Time;
212
        end select;
213
        if Final_Po_Reached then
214
            Report.Failed ("not enough time (1)");
215
        else
216
            if Verbose then
217
                Report.Comment ("not enough time case passed (1)");
218
            end if;
219
        end if;
220
        Delayed_Opener.Cancel_Timer;
221
 
222
 
223
        -- timed without enough time - delay until
224
        Delayed_Opener.Start_Timer (Allowed_Time);
225
        select
226
            Initial_Po.Start_Here;
227
            Report.Failed ("not enough time completed accept (2)");
228
        or
229
            delay until Calendar.Clock + Not_Enough_Time;
230
        end select;
231
        if Final_Po_Reached then
232
            Report.Failed ("not enough time (2)");
233
        else
234
            if Verbose then
235
                Report.Comment ("not enough time case passed (2)");
236
            end if;
237
        end if;
238
        Delayed_Opener.Cancel_Timer;
239
 
240
 
241
        -- conditional case
242
        Delayed_Opener.Start_Timer (Allowed_Time);
243
        select
244
            Initial_Po.Start_Here;
245
            Report.Failed ("no time completed accept");
246
        else
247
            if Verbose then
248
                Report.Comment ("conditional case - else taken");
249
            end if;
250
        end select;
251
        if Final_Po_Reached then
252
            Report.Failed ("no time");
253
        else
254
            if Verbose then
255
                Report.Comment ("no time case passed");
256
            end if;
257
        end if;
258
        Delayed_Opener.Cancel_Timer;
259
 
260
        -- kill off the Delayed_Opener task
261
        Delayed_Opener.Start_Timer (-10.0);
262
 
263
    exception
264
        when others =>
265
            Report.Failed ("exception in main");
266
    end;
267
 
268
    Report.Result;
269
end C954026;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.