source: rtems/c/src/ada-tests/mptests/mp06/mptest.adb @ 23848bbd

4.104.114.95
Last change on this file since 23848bbd was 23848bbd, checked in by Joel Sherrill <joel.sherrill@…>, on 10/01/07 at 22:58:09

2007-10-01 Joel Sherrill <joel.sherrill@…>

  • mptests/mp01/mptest.adb, mptests/mp01/mptest.ads, mptests/mp01/node1/Makefile.am, 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, support/init.c, support/test_support.adb, support/test_support.ads: Most of single processor Ada tests now build. Some run.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1--
2--  MPTEST / BODY
3--
4--  DESCRIPTION:
5--
6--  This package is the implementation for Test 6 of the RTEMS
7--  Multiprocessor 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 MPTEST 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( "*** TEST 6 -- NODE " );
44      UNSIGNED32_IO.PUT(
45         TEST_SUPPORT.NODE,
46         WIDTH => 1
47      );
48      TEXT_IO.PUT_LINE( " ***" );
49
50      MPTEST.TASK_NAME( 1 ) := RTEMS.BUILD_NAME(  '1', '1', '1', ' ' );
51      MPTEST.TASK_NAME( 2 ) := RTEMS.BUILD_NAME(  '2', '2', '2', ' ' );
52
53      TEXT_IO.PUT_LINE( "Creating Test_task (Global)" );
54
55      RTEMS.TASK_CREATE(
56         MPTEST.TASK_NAME( TEST_SUPPORT.NODE ),
57         TEST_SUPPORT.NODE,
58         2048,
59         RTEMS.DEFAULT_MODES,
60         RTEMS.GLOBAL,
61         MPTEST.TASK_ID( 1 ),
62         STATUS
63      );
64      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_CREATE" );
65
66      TEXT_IO.PUT_LINE( "Starting Test_task (Global)" );
67
68      RTEMS.TASK_START(
69         MPTEST.TASK_ID( 1 ),
70         MPTEST.TEST_TASK'ACCESS,
71         0,
72         STATUS
73      );
74      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_START" );
75
76      MPTEST.TIMER_NAME( 1 ) := RTEMS.BUILD_NAME(  'T', 'M', '1', ' ' );
77      MPTEST.TIMER_NAME( 2 ) := RTEMS.BUILD_NAME(  'T', 'M', '2', ' ' );
78
79      RTEMS.TIMER_CREATE(
80         MPTEST.TIMER_NAME( TEST_SUPPORT.NODE ),
81         MPTEST.TIMER_ID( 1 ),
82         STATUS
83      );
84      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_CREATE" );
85
86      TEXT_IO.PUT_LINE( "Deleting initialization task" );
87
88      RTEMS.TASK_DELETE( RTEMS.SELF, STATUS );
89      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TASK_DELETE OF SELF" );
90
91   end INIT;
92
93--PAGE
94--
95--  STOP_TEST_TSR
96--
97 
98   procedure STOP_TEST_TSR (
99      IGNORED1 : in     RTEMS.ID;
100      IGNORED2 : in     RTEMS.ADDRESS
101   ) is
102   begin
103 
104      MPTEST.STOP_TEST := TRUE;
105 
106   end STOP_TEST_TSR;
107 
108--PAGE
109--
110--  TEST_TASK
111--
112
113   procedure TEST_TASK (
114      ARGUMENT : in     RTEMS.TASK_ARGUMENT
115   ) is
116      COUNT                    : RTEMS.UNSIGNED32;
117      EVENT_OUT                : RTEMS.EVENT_SET;
118      EVENT_FOR_THIS_ITERATION : RTEMS.EVENT_SET;
119      STATUS                   : RTEMS.STATUS_CODES;
120   begin
121
122      MPTEST.STOP_TEST := FALSE;
123
124      if TEST_SUPPORT.NODE = 1 then
125         MPTEST.REMOTE_NODE     := 2;
126      else
127         MPTEST.REMOTE_NODE     := 1;
128      end if;
129
130      TEXT_IO.PUT( "Remote task's name is : " );
131      TEST_SUPPORT.PUT_NAME( MPTEST.TASK_NAME( MPTEST.REMOTE_NODE ), TRUE );
132
133      TEXT_IO.PUT_LINE( "Getting TID of remote task" );
134
135      loop
136
137         RTEMS.TASK_IDENT(
138            MPTEST.TASK_NAME( MPTEST.REMOTE_NODE ),
139            RTEMS.SEARCH_ALL_NODES,
140            MPTEST.REMOTE_TID,
141            STATUS
142         );
143
144         exit when RTEMS.IS_STATUS_SUCCESSFUL( STATUS );
145
146      end loop;
147
148      if TEST_SUPPORT.NODE = 1 then
149         TEXT_IO.PUT_LINE( "Sending events to remote task" );
150      else
151         TEXT_IO.PUT_LINE( "Receiving events from remote task" );
152      end if;
153
154      RTEMS.TIMER_FIRE_AFTER(
155         MPTEST.TIMER_ID( 1 ),
156         5 * TEST_SUPPORT.TICKS_PER_SECOND,
157         MPTEST.STOP_TEST_TSR'ACCESS,
158         RTEMS.NULL_ADDRESS,
159         STATUS
160      );
161      TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "TIMER_FIRE_AFTER" );
162 
163      COUNT := 0;
164
165      loop
166 
167         exit when MPTEST.STOP_TEST = TRUE;
168
169         EVENT_FOR_THIS_ITERATION :=
170            MPTEST.EVENT_SET_TABLE(
171               INTEGER( COUNT ) mod MPTEST.EVENT_SET_TABLE'LAST + 1
172            );
173
174         if TEST_SUPPORT.NODE = 1 then
175
176            RTEMS.EVENT_SEND(
177               MPTEST.REMOTE_TID,
178               EVENT_FOR_THIS_ITERATION,
179               STATUS
180            );
181            TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "EVENT_SEND" );
182
183         else
184
185            RTEMS.EVENT_RECEIVE(
186               EVENT_FOR_THIS_ITERATION,
187               RTEMS.DEFAULT_OPTIONS,
188               1 * TEST_SUPPORT.TICKS_PER_SECOND,
189               EVENT_OUT,
190               STATUS
191            );
192
193            if RTEMS.ARE_STATUSES_EQUAL( STATUS, RTEMS.TIMEOUT ) then
194               TEXT_IO.NEW_LINE( 1 );
195
196               if TEST_SUPPORT.NODE = 2 then
197                  TEXT_IO.PUT_LINE(
198                     "Correct behavior if the other node exitted."
199                  );
200               else
201                  TEXT_IO.PUT_LINE(
202                     "ERROR... node 1 died"
203                  );
204               end if;
205
206               exit;
207
208            else
209
210               TEST_SUPPORT.DIRECTIVE_FAILED( STATUS, "EVENT_RECEIVE" );
211
212            end if;
213
214         end if;
215
216         if (COUNT mod MPTEST.MAXIMUM_DOTS) = 0 then
217
218            TEST_SUPPORT.PUT_DOT( "." );
219
220         end if;
221
222         COUNT := COUNT + 1;
223
224      end loop;
225
226      TEXT_IO.NEW_LINE;
227
228      if TEST_SUPPORT.NODE = 2 then
229
230         RTEMS.EVENT_RECEIVE(
231            RTEMS.EVENT_16,
232            RTEMS.DEFAULT_OPTIONS,
233            1 * TEST_SUPPORT.TICKS_PER_SECOND,
234            EVENT_OUT,
235            STATUS
236         );
237         TEST_SUPPORT.FATAL_DIRECTIVE_STATUS(
238            RTEMS.TIMEOUT,
239            STATUS,
240            "EVENT_RECEIVE"
241         );
242
243         TEXT_IO.NEW_LINE;
244         TEXT_IO.PUT_LINE( "event_receive - correctly returned TIMEOUT" );
245
246      end if;
247
248      TEXT_IO.PUT_LINE( "*** END OF TEST 6 ***" );
249
250      RTEMS.SHUTDOWN_EXECUTIVE( 0 );
251
252   end TEST_TASK;
253
254end MPTEST;
Note: See TracBrowser for help on using the repository browser.