source: rtems/c/src/ada-tests/sptests/sp22/sptest.adb @ 2af6056

4.104.114.84.95
Last change on this file since 2af6056 was bf9ae83, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 2, 1997 at 8:32:11 PM

modified copyright notice to be the same as RTEMS 4.0.0.

changed the CVS ID string to be a "development" version.

  • Property mode set to 100644
File size: 7.9 KB
Line 
1--
2--  SPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation of Test 22 of the RTEMS
7--  Single Processor Test Suite.
8--
9--  DEPENDENCIES:
10--
11-- 
12--
13--  COPYRIGHT (c) 1989-1997.
14--  On-Line Applications Research Corporation (OAR).
15--  Copyright assigned to U.S. Government, 1994.
16--
17--  The license and distribution terms for this file may in
18--  the file LICENSE in this distribution or at
19--  http://www.OARcorp.com/rtems/license.html.
20--
21--  $Id$
22--
23
24with INTERFACES; use INTERFACES;
25with RTEMS;
26with TEST_SUPPORT;
27with TEXT_IO;
28with UNSIGNED32_IO;
29
30package body SPTEST is
31
32--PAGE
33--
34--  INIT
35--
36
37   procedure INIT (
38      ARGUMENT : in     RTEMS.TASK_ARGUMENT
39   ) is
40      TIME   : RTEMS.TIME_OF_DAY;
41      STATUS : RTEMS.STATUS_CODES;
42   begin
43
44      TEXT_IO.NEW_LINE( 2 );
45      TEXT_IO.PUT_LINE( "*** TEST 22 ***" );
46
47      TIME := ( 1988, 12, 31, 9, 0, 0, 0 );
48
49      RTEMS.CLOCK_SET( TIME, STATUS );
50      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" );
51
52      SPTEST.TASK_NAME( 1 )  := RTEMS.BUILD_NAME(  'T', 'A', '1', ' ' );
53      SPTEST.TIMER_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'M', '1', ' ' );
54
55      RTEMS.TASK_CREATE( 
56         SPTEST.TASK_NAME( 1 ), 
57         1, 
58         2048, 
59         RTEMS.DEFAULT_MODES,
60         RTEMS.DEFAULT_ATTRIBUTES,
61         SPTEST.TASK_ID( 1 ),
62         STATUS
63      );
64      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE OF TA1" );
65
66      RTEMS.TASK_START(
67         SPTEST.TASK_ID( 1 ),
68         SPTEST.TASK_1'ACCESS,
69         0,
70         STATUS
71      );
72      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START OF TA1" );
73
74      TEXT_IO.PUT_LINE( "INIT - timer_create - creating timer 1" );
75      RTEMS.TIMER_CREATE(
76         SPTEST.TIMER_NAME( 1 ), 
77         SPTEST.TIMER_ID( 1 ),
78         STATUS
79      );
80      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CREATE OF TM1" );
81      TEXT_IO.PUT( "INIT - timer 1 has id (" );
82      UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ), WIDTH => 8, BASE => 16 );
83      TEXT_IO.PUT_LINE( ")" );
84     
85      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
86      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
87
88   end INIT;
89
90--PAGE
91--
92--  DELAYED_RESUME
93--
94
95   procedure DELAYED_RESUME (
96      IGNORED_ID      : in     RTEMS.ID;
97      IGNORED_ADDRESS : in     RTEMS.ADDRESS
98   ) is
99      STATUS : RTEMS.STATUS_CODES;
100   begin
101
102      RTEMS.TASK_RESUME( SPTEST.TASK_ID( 1 ), STATUS );
103      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_RESUME OF SELF" );
104
105   end DELAYED_RESUME;
106
107--PAGE
108--
109--  PRINT_TIME
110--
111
112   procedure PRINT_TIME 
113   is
114      TIME   : RTEMS.TIME_OF_DAY;
115      STATUS : RTEMS.STATUS_CODES;
116   begin
117
118      RTEMS.CLOCK_GET( RTEMS.CLOCK_GET_TOD, TIME'ADDRESS, STATUS );
119      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET" );
120
121      TEST_SUPPORT.PUT_NAME( 
122         SPTEST.TASK_NAME( 1 ),
123         FALSE
124      );
125
126      TEST_SUPPORT.PRINT_TIME( "- clock_get - ", TIME, "" );
127      TEXT_IO.NEW_LINE;
128
129   end PRINT_TIME;
130   
131--PAGE
132--
133--  TASK_1
134--
135
136   procedure TASK_1 (
137      ARGUMENT : in     RTEMS.TASK_ARGUMENT
138   ) is
139      TMID   : RTEMS.ID;
140      TIME   : RTEMS.TIME_OF_DAY;
141      STATUS : RTEMS.STATUS_CODES;
142   begin
143
144-- GET ID
145
146      TEXT_IO.PUT_LINE( "TA1 - timer_ident - identing timer 1" );
147      RTEMS.TIMER_IDENT( SPTEST.TIMER_NAME( 1 ), TMID, STATUS );
148      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_IDENT OF TM1" );
149      TEXT_IO.PUT( "TA1 - timer 1 has id (" );
150      UNSIGNED32_IO.PUT( SPTEST.TIMER_ID( 1 ), WIDTH => 8, BASE => 16 );
151      TEXT_IO.PUT_LINE( ")" );
152   
153-- AFTER WHICH IS ALLOWED TO FIRE
154
155      SPTEST.PRINT_TIME;
156
157      TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
158      RTEMS.TIMER_FIRE_AFTER( 
159         TMID, 
160         3 * TEST_SUPPORT.TICKS_PER_SECOND,
161         SPTEST.DELAYED_RESUME'ACCESS,
162         RTEMS.NULL_ADDRESS,
163         STATUS
164      );
165      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
166
167      TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
168      RTEMS.TASK_SUSPEND( RTEMS.SELF, STATUS );
169      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
170         
171      SPTEST.PRINT_TIME;
172
173-- AFTER WHICH IS RESET AND ALLOWED TO FIRE
174
175      TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
176      RTEMS.TIMER_FIRE_AFTER( 
177         TMID, 
178         3 * TEST_SUPPORT.TICKS_PER_SECOND,
179         SPTEST.DELAYED_RESUME'ACCESS,
180         RTEMS.NULL_ADDRESS,
181         STATUS
182      );
183      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
184
185      TEXT_IO.PUT_LINE( "TA1 - task_wake_after - 1 second" );
186      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
187      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
188         
189      SPTEST.PRINT_TIME;
190
191      TEXT_IO.PUT_LINE( "TA1 - timer_reset - timer 1" );
192      RTEMS.TIMER_RESET( TMID, STATUS );
193      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_RESET" );
194         
195      TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
196      RTEMS.TASK_SUSPEND( RTEMS.SELF, STATUS );
197      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
198
199      SPTEST.PRINT_TIME;
200
201TEST_SUPPORT.PAUSE;
202
203--
204-- Reset the time since we do not know how long the user waited
205-- before pressing <cr> at the pause.  This insures that the
206-- actual output matches the screen.
207--
208
209      TIME := ( 1988, 12, 31, 9, 0, 7, 0 );
210
211      RTEMS.CLOCK_SET( TIME, STATUS );
212      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_SET" );
213
214-- after which is canceled
215
216      TEXT_IO.PUT_LINE( "TA1 - timer_after - timer 1 in 3 seconds" );
217      RTEMS.TIMER_FIRE_AFTER( 
218         TMID, 
219         3 * TEST_SUPPORT.TICKS_PER_SECOND,
220         SPTEST.DELAYED_RESUME'ACCESS,
221         RTEMS.NULL_ADDRESS,
222         STATUS
223      );
224      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
225
226      TEXT_IO.PUT_LINE( "TA1 - timer_cancel - timer 1" );
227      RTEMS.TIMER_CANCEL( TMID, STATUS );
228      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CANCEL" );
229         
230-- when which is allowed to fire
231
232      SPTEST.PRINT_TIME;
233
234      RTEMS.CLOCK_GET( RTEMS.CLOCK_GET_TOD, TIME'ADDRESS, STATUS );
235      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET" );
236
237      TIME.SECOND := TIME.SECOND + 3;
238
239      TEXT_IO.PUT_LINE( "TA1 - timer_when - timer 1 in 3 seconds" );
240      RTEMS.TIMER_FIRE_WHEN( 
241         TMID, 
242         TIME,
243         SPTEST.DELAYED_RESUME'ACCESS,
244         RTEMS.NULL_ADDRESS,
245         STATUS
246      );
247      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_WHEN" );
248
249      TEXT_IO.PUT_LINE( "TA1 - task_suspend( SELF )" );
250      RTEMS.TASK_SUSPEND( RTEMS.SELF, STATUS );
251      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_SUSPEND" );
252
253      SPTEST.PRINT_TIME;
254
255-- when which is canceled
256
257      RTEMS.CLOCK_GET( RTEMS.CLOCK_GET_TOD, TIME'ADDRESS, STATUS );
258      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "CLOCK_GET" );
259
260      TIME.SECOND := TIME.SECOND + 3;
261
262      TEXT_IO.PUT_LINE( "TA1 - timer_when - timer 1 in 3 seconds" );
263      RTEMS.TIMER_FIRE_WHEN( 
264         TMID, 
265         TIME,
266         SPTEST.DELAYED_RESUME'ACCESS,
267         RTEMS.NULL_ADDRESS,
268         STATUS
269      );
270      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_WHEN" );
271
272      TEXT_IO.PUT_LINE( "TA1 - task_wake_after - 1 second" );
273      RTEMS.TASK_WAKE_AFTER( TEST_SUPPORT.TICKS_PER_SECOND, STATUS );
274      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
275         
276      SPTEST.PRINT_TIME;
277
278      TEXT_IO.PUT_LINE( "TA1 - timer_cancel - timer 1" );
279      RTEMS.TIMER_CANCEL( TMID, STATUS );
280      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CANCEL" );
281         
282-- delete
283         
284      TEXT_IO.PUT_LINE(
285         "TA1 - task_wake_after - YIELD (only task at priority)"
286      );
287      RTEMS.TASK_WAKE_AFTER( RTEMS.YIELD_PROCESSOR, STATUS );
288      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER YIELD" );
289         
290      TEXT_IO.PUT_LINE( "TA1 - timer_delete - timer 1" );
291      RTEMS.TIMER_DELETE( TMID, STATUS );
292      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_DELETE" );
293         
294      TEXT_IO.PUT_LINE( "*** END OF TEST 22 ***" );
295      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
296   
297   end TASK_1;
298
299end SPTEST;
Note: See TracBrowser for help on using the repository browser.