source: rtems/c/src/ada-tests/sptests/sp20/sptest.adb @ 35e4691

4.104.114.84.95
Last change on this file since 35e4691 was 35e4691, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:50:41

2003-09-04 Joel Sherrill <joel@…>

  • mptests/mp01/config.h, mptests/mp01/mp01.adb, mptests/mp01/mptest.adb, mptests/mp01/mptest.ads, mptests/mp02/mptest.adb, mptests/mp02/mptest.ads, mptests/mp03/mptest.adb, mptests/mp03/mptest.ads, mptests/mp04/mptest.adb, mptests/mp04/mptest.ads, mptests/mp05/mptest.adb, mptests/mp05/mptest.ads, mptests/mp06/mptest.adb, mptests/mp06/mptest.ads, mptests/mp07/mptest.adb, mptests/mp07/mptest.ads, mptests/mp08/mptest.adb, mptests/mp08/mptest.ads, mptests/mp09/mptest.adb, mptests/mp09/mptest.ads, mptests/mp10/mptest.adb, mptests/mp10/mptest.ads, mptests/mp11/mptest.adb, mptests/mp11/mptest.ads, mptests/mp12/mptest.adb, mptests/mp12/mptest.ads, mptests/mp13/mptest.adb, mptests/mp13/mptest.ads, mptests/mp14/mptest.adb, mptests/mp14/mptest.ads, samples/base_mp/config.h, samples/base_mp/mptest.adb, samples/base_mp/mptest.ads, samples/base_sp/base_sp.adb, samples/base_sp/config.h, samples/base_sp/sptest.adb, samples/base_sp/sptest.ads, samples/hello/config.h, samples/hello/hello.adb, samples/hello/sptest.adb, samples/hello/sptest.ads, samples/ticker/config.h, samples/ticker/sptest.adb, samples/ticker/sptest.ads, samples/ticker/ticker.adb, sptests/sp01/config.h, sptests/sp01/sp01.adb, sptests/sp01/sptest.adb, sptests/sp01/sptest.ads, sptests/sp02/config.h, sptests/sp02/sp02.adb, sptests/sp02/sptest.adb, sptests/sp02/sptest.ads, sptests/sp03/config.h, sptests/sp03/sp03.adb, sptests/sp03/sptest.adb, sptests/sp03/sptest.ads, sptests/sp04/config.h, sptests/sp04/sp04.adb, sptests/sp04/sptest.adb, sptests/sp04/sptest.ads, sptests/sp05/config.h, sptests/sp05/sp05.adb, sptests/sp05/sptest.adb, sptests/sp05/sptest.ads, sptests/sp06/config.h, sptests/sp06/sp06.adb, sptests/sp06/sptest.adb, sptests/sp06/sptest.ads, sptests/sp07/config.h, sptests/sp07/sp07.adb, sptests/sp07/sptest.adb, sptests/sp07/sptest.ads, sptests/sp08/config.h, sptests/sp08/sp08.adb, sptests/sp08/sptest.adb, sptests/sp08/sptest.ads, sptests/sp09/config.h, sptests/sp09/sp09.adb, sptests/sp09/sptest.adb, sptests/sp09/sptest.ads, sptests/sp11/config.h, sptests/sp11/sp11.adb, sptests/sp11/sptest.adb, sptests/sp11/sptest.ads, sptests/sp12/config.h, sptests/sp12/sp12.adb, sptests/sp12/sptest.adb, sptests/sp12/sptest.ads, sptests/sp13/config.h, sptests/sp13/sp13.adb, sptests/sp13/sptest.adb, sptests/sp13/sptest.ads, sptests/sp14/config.h, sptests/sp14/sp14.adb, sptests/sp14/sptest.adb, sptests/sp14/sptest.ads, sptests/sp15/config.h, sptests/sp15/sp15.adb, sptests/sp15/sptest.adb, sptests/sp15/sptest.ads, sptests/sp16/config.h, sptests/sp16/sp16.adb, sptests/sp16/sptest.adb, sptests/sp16/sptest.ads, sptests/sp17/config.h, sptests/sp17/sp17.adb, sptests/sp17/sptest.adb, sptests/sp17/sptest.ads, sptests/sp19/config.h, sptests/sp19/sp19.adb, sptests/sp19/sptest.ads, sptests/sp20/config.h, sptests/sp20/sp20.adb, sptests/sp20/sptest.adb, sptests/sp20/sptest.ads, sptests/sp21/config.h, sptests/sp21/sp21.adb, sptests/sp21/sptest.adb, sptests/sp21/sptest.ads, sptests/sp22/config.h, sptests/sp22/sp22.adb, sptests/sp22/sptest.adb, sptests/sp22/sptest.ads, sptests/sp23/config.h, sptests/sp23/sp23.adb, sptests/sp23/sptest.adb, sptests/sp23/sptest.ads, sptests/sp24/config.h, sptests/sp24/sp24.adb, sptests/sp24/sptest.adb, sptests/sp24/sptest.ads, sptests/sp25/config.h, sptests/sp25/sp25.adb, sptests/sp25/sptest.adb, sptests/sp25/sptest.ads, sptests/spsize/spsize.adb, sptests/spsize/sptest.adb, sptests/spsize/sptest.ads, support/address_io.adb, support/address_io.ads, support/float_io.ads, support/fp.inc, support/integer.inc, support/rtems_calling_overhead.ads, support/status_io.ads, support/test_support.adb, support/test_support.ads, support/time_test_support.adb, support/time_test_support.ads, support/timer_driver.adb, support/timer_driver.ads, support/unsigned32_io.ads, tmtests/tm01/config.h, tmtests/tm01/tm01.adb, tmtests/tm01/tmtest.adb, tmtests/tm01/tmtest.ads, tmtests/tm02/config.h, tmtests/tm02/tm02.adb, tmtests/tm02/tmtest.adb, tmtests/tm02/tmtest.ads, tmtests/tm03/config.h, tmtests/tm03/tm03.adb, tmtests/tm03/tmtest.adb, tmtests/tm03/tmtest.ads, tmtests/tm04/config.h, tmtests/tm04/tm04.adb, tmtests/tm04/tmtest.adb, tmtests/tm04/tmtest.ads, tmtests/tm05/config.h, tmtests/tm05/tm05.adb, tmtests/tm05/tmtest.adb, tmtests/tm05/tmtest.ads, tmtests/tm06/config.h, tmtests/tm06/tm06.adb, tmtests/tm06/tmtest.adb, tmtests/tm06/tmtest.ads, tmtests/tm07/config.h, tmtests/tm07/tm07.adb, tmtests/tm07/tmtest.adb, tmtests/tm07/tmtest.ads, tmtests/tm08/config.h, tmtests/tm08/tm08.adb, tmtests/tm08/tmtest.adb, tmtests/tm08/tmtest.ads, tmtests/tm09/config.h, tmtests/tm09/tm09.adb, tmtests/tm09/tmtest.adb, tmtests/tm09/tmtest.ads, tmtests/tm10/config.h, tmtests/tm10/tm10.adb, tmtests/tm10/tmtest.adb, tmtests/tm10/tmtest.ads, tmtests/tm11/config.h, tmtests/tm11/tm11.adb, tmtests/tm11/tmtest.adb, tmtests/tm11/tmtest.ads, tmtests/tm12/config.h, tmtests/tm12/tm12.adb, tmtests/tm12/tmtest.adb, tmtests/tm12/tmtest.ads, tmtests/tm13/config.h, tmtests/tm13/tm13.adb, tmtests/tm13/tmtest.adb, tmtests/tm13/tmtest.ads, tmtests/tm14/config.h, tmtests/tm14/tm14.adb, tmtests/tm14/tmtest.adb, tmtests/tm14/tmtest.ads, tmtests/tm15/config.h, tmtests/tm15/tm15.adb, tmtests/tm15/tmtest.adb, tmtests/tm15/tmtest.ads, tmtests/tm16/config.h, tmtests/tm16/tm16.adb, tmtests/tm16/tmtest.adb, tmtests/tm16/tmtest.ads, tmtests/tm17/config.h, tmtests/tm17/tm17.adb, tmtests/tm17/tmtest.adb, tmtests/tm17/tmtest.ads, tmtests/tm18/config.h, tmtests/tm18/tm18.adb, tmtests/tm18/tmtest.adb, tmtests/tm18/tmtest.ads, tmtests/tm19/config.h, tmtests/tm19/tm19.adb, tmtests/tm19/tmtest.adb, tmtests/tm19/tmtest.ads, tmtests/tm20/config.h, tmtests/tm20/tm20.adb, tmtests/tm20/tmtest.adb, tmtests/tm20/tmtest.ads, tmtests/tm21/config.h, tmtests/tm21/tm21.adb, tmtests/tm21/tmtest.adb, tmtests/tm21/tmtest.ads, tmtests/tm22/config.h, tmtests/tm22/tm22.adb, tmtests/tm22/tmtest.adb, tmtests/tm22/tmtest.ads, tmtests/tm23/config.h, tmtests/tm23/tm23.adb, tmtests/tm23/tmtest.adb, tmtests/tm23/tmtest.ads, tmtests/tm24/config.h, tmtests/tm24/tm24.adb, tmtests/tm24/tmtest.adb, tmtests/tm24/tmtest.ads, tmtests/tm25/config.h, tmtests/tm25/tm25.adb, tmtests/tm25/tmtest.adb, tmtests/tm25/tmtest.ads, tmtests/tm28/config.h, tmtests/tm28/tm28.adb, tmtests/tm28/tmtest.adb, tmtests/tm28/tmtest.ads, tmtests/tm29/config.h, tmtests/tm29/tm29.adb, tmtests/tm29/tmtest.adb, tmtests/tm29/tmtest.ads, tmtests/tmck/config.h, tmtests/tmck/tmck.adb, tmtests/tmck/tmtest.adb, tmtests/tmck/tmtest.ads, tmtests/tmoverhd/config.h, tmtests/tmoverhd/dummy_rtems.adb, tmtests/tmoverhd/dummy_rtems.ads, tmtests/tmoverhd/tmoverhd.adb, tmtests/tmoverhd/tmtest.adb, tmtests/tmoverhd/tmtest.ads: URL for license changed.
  • Property mode set to 100644
File size: 7.1 KB
Line 
1--
2--  SPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation of Test 20 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--
16--  The license and distribution terms for this file may in
17--  the file LICENSE in this distribution or at
18--  http://www.rtems.com/license/LICENSE.
19--
20--  $Id$
21--
22
23with INTERFACES; use INTERFACES;
24with RTEMS;
25with TEST_SUPPORT;
26with TEXT_IO;
27with UNSIGNED32_IO;
28
29package body SPTEST is
30
31--PAGE
32--
33--  INIT
34--
35
36   procedure INIT (
37      ARGUMENT : in     RTEMS.TASK_ARGUMENT
38   ) is
39      STATUS : RTEMS.STATUS_CODES;
40   begin
41
42      TEXT_IO.NEW_LINE( 2 );
43      TEXT_IO.PUT_LINE( "*** TEST 20 ***" );
44
45      SPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'A', '1', ' ' );
46      SPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  'T', 'A', '2', ' ' );
47      SPTEST.TASK_NAME( 3 ) := RTEMS.BUILD_NAME(  'T', 'A', '3', ' ' );
48      SPTEST.TASK_NAME( 4 ) := RTEMS.BUILD_NAME(  'T', 'A', '4', ' ' );
49      SPTEST.TASK_NAME( 5 ) := RTEMS.BUILD_NAME(  'T', 'A', '5', ' ' );
50
51      for INDEX in 1 .. 5
52      loop
53
54         SPTEST.COUNT( INDEX ) := 0;
55
56         RTEMS.TASK_CREATE(
57            SPTEST.TASK_NAME( INDEX ),
58            SPTEST.PRIORITIES( INDEX ),
59            4096,
60            RTEMS.DEFAULT_MODES,
61            RTEMS.DEFAULT_ATTRIBUTES,
62            SPTEST.TASK_ID( INDEX ),
63            STATUS
64         );
65         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE LOOP" );
66
67      end loop;
68
69      for INDEX in 1 .. 5
70      loop
71
72         RTEMS.TASK_START(
73            SPTEST.TASK_ID( INDEX ),
74            SPTEST.TASK_1_THROUGH_5'ACCESS,
75            RTEMS.TASK_ARGUMENT( INDEX ),
76            STATUS
77         );
78         TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START LOOP" );
79 
80      end loop;
81
82      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
83      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
84
85   end INIT;
86
87--PAGE
88--
89--  TASK_1_THROUGH_5
90--
91
92   procedure TASK_1_THROUGH_5 (
93      ARGUMENT : in     RTEMS.TASK_ARGUMENT
94   ) is
95      RMID      : RTEMS.ID;
96      TEST_RMID : RTEMS.ID;
97      INDEX     : RTEMS.UNSIGNED32;
98      PASS      : RTEMS.UNSIGNED32;
99      FAILED    : RTEMS.UNSIGNED32;
100      STATUS    : RTEMS.STATUS_CODES;
101   begin
102
103      RTEMS.RATE_MONOTONIC_CREATE( ARGUMENT, RMID, STATUS );
104      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "RATE_MONOTONIC_CREATE" );
105      TEST_SUPPORT.PUT_NAME( SPTEST.TASK_NAME( INTEGER( ARGUMENT ) ), FALSE );
106      TEXT_IO.PUT( "- rate_monotonic_create id = " );
107      UNSIGNED32_IO.PUT( RMID, WIDTH => 8, BASE => 16 );
108      TEXT_IO.NEW_LINE;
109 
110      RTEMS.RATE_MONOTONIC_IDENT( ARGUMENT, TEST_RMID, STATUS );
111      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "RATE_MONOTONIC_IDENT" );
112      TEST_SUPPORT.PUT_NAME( SPTEST.TASK_NAME( INTEGER( ARGUMENT ) ), FALSE );
113      TEXT_IO.PUT( "- rate_monotonic_ident id = " );
114      UNSIGNED32_IO.PUT( RMID, WIDTH => 8, BASE => 16 );
115      TEXT_IO.NEW_LINE;
116      if TEST_RMID /= RMID then
117         TEXT_IO.PUT_LINE( "RMID's DO NOT MATCH!!!" );
118         RTEMS.SHUTDOWN_EXECUTIVE( 0 );
119      end if;
120
121      TEST_SUPPORT.PUT_NAME( SPTEST.TASK_NAME( INTEGER( ARGUMENT ) ), FALSE );
122      TEXT_IO.PUT( " - (" );
123      UNSIGNED32_IO.PUT( RMID, WIDTH => 1, BASE => 16 );
124      TEXT_IO.PUT( ") period " );
125      UNSIGNED32_IO.PUT(
126         SPTEST.PERIODS( INTEGER( ARGUMENT ) ),
127         WIDTH => 1,
128         BASE => 10
129      );
130      TEXT_IO.NEW_LINE;
131       
132      RTEMS.TASK_WAKE_AFTER( 2, STATUS );
133      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_WAKE_AFTER" );
134   
135      case ARGUMENT is
136         when 1 .. 4 =>
137            loop
138               RTEMS.RATE_MONOTONIC_PERIOD(
139                  RMID,
140                  SPTEST.PERIODS( INTEGER( ARGUMENT ) ),
141                  STATUS
142               );
143
144               TEST_SUPPORT.DIRECTIVE_FAILED(
145                  STATUS,
146                  "RATE_MONOTONIC_PERIOD"
147               );
148
149               SPTEST.COUNT( INTEGER( ARGUMENT ) ) :=
150                  SPTEST.COUNT( INTEGER( ARGUMENT ) ) + 1;
151
152            end loop;
153
154         when 5 =>
155
156            PASS   := 0;
157            FAILED := 0;
158
159            RTEMS.RATE_MONOTONIC_PERIOD(
160               RMID,
161               SPTEST.PERIODS( INTEGER( ARGUMENT ) ),
162               STATUS
163            );
164
165            TEST_SUPPORT.DIRECTIVE_FAILED(
166               STATUS,
167               "RATE_MONOTONIC_PERIOD 1 OF TA5"
168            );
169
170            SPTEST.GET_ALL_COUNTERS;
171
172            loop
173
174               RTEMS.RATE_MONOTONIC_PERIOD(
175                  RMID,
176                  SPTEST.PERIODS( INTEGER( ARGUMENT ) ),
177                  STATUS
178               );
179
180               TEST_SUPPORT.DIRECTIVE_FAILED(
181                  STATUS,
182                  "RATE_MONOTONIC_PERIOD 2 OF TA5"
183               );
184
185               SPTEST.GET_ALL_COUNTERS;
186
187               for INDEX in 1 .. 4
188               loop
189
190                  if SPTEST.TEMPORARY_COUNT( INDEX ) /=
191                        SPTEST.ITERATIONS( INDEX ) then
192
193                     TEXT_IO.PUT( "FAIL -- " );
194                     TEST_SUPPORT.PUT_NAME(
195                        SPTEST.TASK_NAME( INDEX ),
196                        FALSE
197                     );
198                     TEXT_IO.PUT( "ACTUAL=" );
199                     UNSIGNED32_IO.PUT(
200                        SPTEST.TEMPORARY_COUNT( INDEX ),
201                        WIDTH => 3,
202                        BASE => 10
203                     );
204                     TEXT_IO.PUT( " EXPECTED=" );
205                     UNSIGNED32_IO.PUT(
206                        SPTEST.ITERATIONS( INDEX ),
207                        WIDTH => 3,
208                        BASE => 10
209                     );
210                     TEXT_IO.NEW_LINE;
211
212                     FAILED := FAILED + 1;
213
214                  end if;
215
216               end loop;
217
218               if FAILED = 5 then
219                  RTEMS.SHUTDOWN_EXECUTIVE( 0 );
220               end if;
221
222               PASS := PASS + 1;
223               TEXT_IO.PUT( "TA5 - PERIODS CHECK OK (" );
224               UNSIGNED32_IO.PUT( PASS, WIDTH => 1, BASE => 10 );
225               TEXT_IO.PUT_LINE( ")" );
226 
227               if PASS = 10 then
228                  TEXT_IO.PUT_LINE( "*** END OF TEST 20 ***" );
229                  RTEMS.SHUTDOWN_EXECUTIVE( 0 );
230               end if;
231
232            end loop;
233 
234         when others =>
235            NULL;
236           
237      end case;
238
239   end TASK_1_THROUGH_5;
240
241--PAGE
242--
243--  GET_ALL_COUNTERS
244--
245
246   procedure GET_ALL_COUNTERS
247   is
248      PREVIOUS_MODE : RTEMS.MODE;
249      STATUS        : RTEMS.STATUS_CODES;
250   begin
251
252      RTEMS.TASK_MODE(
253         RTEMS.NO_PREEMPT,
254         RTEMS.PREEMPT_MASK,
255         PREVIOUS_MODE,
256         STATUS
257      );
258      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE TO NO_PREEMPT" );
259
260      SPTEST.TEMPORARY_COUNT := SPTEST.COUNT;
261
262      for INDEX in 1 .. 5
263      loop
264
265         SPTEST.COUNT( INDEX ) := 0;
266
267      end loop;
268     
269      RTEMS.TASK_MODE(
270         RTEMS.PREEMPT,
271         RTEMS.PREEMPT_MASK,
272         PREVIOUS_MODE,
273         STATUS
274      );
275      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_MODE TO PREEMPT" );
276
277   end GET_ALL_COUNTERS;
278
279end SPTEST;
Note: See TracBrowser for help on using the repository browser.