source: rtems/testsuites/sptests/spqreslib/init.c @ 2824e63

4.115
Last change on this file since 2824e63 was c100ba13, checked in by Joel Sherrill <joel.sherrill@…>, on 05/08/12 at 21:39:30

spqreslib - Make global data extern in system.h

Global data was declared in system.h but should have been extern
in system.h and declared in init.c. There were duplicate symbol
linking errors on at least powerpc/mpc8260ads.

  • Property mode set to 100644
File size: 8.4 KB
RevLine 
[1c2b94a]1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is a user initialization task and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input params:
10 *    argument - task argument
11 *
12 *  Output params:  NONE
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#define CONFIGURE_INIT
22#include "system.h"
23
[c100ba13]24rtems_id   Task_id;
25rtems_task_priority Priority;
26time_t  Period;
27time_t  Execution;
28time_t  Phase;
29
[1c2b94a]30rtems_task Init(
31  rtems_task_argument argument
32)
33{
34  rtems_status_code status;
35  qres_sid_t server_id, server_id2;
36  time_t approved_budget, exec_time, abs_time, current_budget;
37  qres_params_t params, params1, params2, params3, params4;
38
39  Priority = 30;
40  Period    = 30;
41  Execution = 10;
42  Phase = 0;
43
44  params.P = 1;
45  params.Q = 1;
46
47  params1 = params2 = params3 = params4 = params;
48  params1.Q = -1;
49  params2.Q = SCHEDULER_EDF_PRIO_MSB + 1;
50  params3.P = -1;
51  params4.P = SCHEDULER_EDF_PRIO_MSB + 1;
52
53  puts( "\n\n*** TEST QRES LIBRARY ***" );
54
55
56  status = rtems_task_create(
[c100ba13]57    rtems_build_name( 'P', 'T', '1', ' ' ),
[1c2b94a]58    Priority,
59    RTEMS_MINIMUM_STACK_SIZE * 4,
60    RTEMS_DEFAULT_MODES,
61    RTEMS_DEFAULT_ATTRIBUTES,
62    &Task_id
63  );
64  directive_failed( status, "rtems_task_create loop" );
65
66  printf( "Init: Initializing the qres library\n" );
67  if ( qres_init() )
68    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
69
70  /* Error checks for Create server and Destroy server  */
71  printf( "Init: Create server and Destroy server\n" );
72  if ( qres_destroy_server( -5 ) !=
73       QOS_E_INVALID_PARAM )
74    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
75  if ( qres_destroy_server( 5 ) !=
76       QOS_E_INVALID_PARAM )
77    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
78  if ( qres_destroy_server( 0 ) != QOS_E_NOSERVER )
79    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
80  if ( qres_create_server( &params1, &server_id ) !=
81       QOS_E_INVALID_PARAM )
82    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
83  if ( qres_create_server( &params2, &server_id ) !=
84       QOS_E_INVALID_PARAM )
85    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
86  if ( qres_create_server( &params3, &server_id ) !=
87       QOS_E_INVALID_PARAM )
88    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
89  if ( qres_create_server( &params4, &server_id ) !=
90       QOS_E_INVALID_PARAM )
91    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
92  if ( qres_create_server( &params, &server_id2 ) )
93    printf( "ERROR: CREATE SERVER FAILED\n" );
94  if ( qres_create_server( &params, &server_id ) )
95    printf( "ERROR: CREATE SERVER FAILED\n" );
96  if ( qres_create_server( &params, &server_id ) !=
97       QOS_E_FULL )
98    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
99
100  /* Error checks for Attach thread and Detach thread */
101  printf( "Init: Attach thread\n" );
102  if ( qres_attach_thread( -5, 0, RTEMS_SELF ) !=
103       QOS_E_INVALID_PARAM )
104    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
105  if ( qres_attach_thread( 5, 0, RTEMS_SELF ) !=
106       QOS_E_INVALID_PARAM )
107    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
108  if ( qres_attach_thread( server_id, 0, 1234 ) !=
109       QOS_E_INVALID_PARAM )
110    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
111  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) )
112    printf( "ERROR: ATTACH THREAD FAILED\n" );
113  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
114       QOS_E_FULL )
115    printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
116  if ( qres_attach_thread( server_id, 0, Task_id ) !=
117       QOS_E_FULL )
118    printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
119  if ( qres_destroy_server( server_id ) )
120    printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
121  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
122       QOS_E_NOSERVER )
123    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
124
125  printf( "Init: Detach thread\n" );
126  if ( qres_detach_thread( -5, 0, RTEMS_SELF ) !=
127       QOS_E_INVALID_PARAM )
128    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
129  if ( qres_detach_thread( 5, 0, RTEMS_SELF ) !=
130       QOS_E_INVALID_PARAM )
131    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
132  if ( qres_detach_thread( server_id2, 0, 1234 ) !=
133       QOS_E_INVALID_PARAM )
134    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
135  if ( qres_detach_thread( server_id, 0, RTEMS_SELF ) !=
136       QOS_E_NOSERVER )
137    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
138  qres_destroy_server( server_id2 );
139
140  /* Error checks for Set params and Get params */
141  printf( "Init: Set params and Get params\n" );
142  if ( qres_set_params( -5, &params ) !=
143       QOS_E_INVALID_PARAM )
144    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
145  if ( qres_set_params( 5, &params ) !=
146       QOS_E_INVALID_PARAM )
147    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
148  if ( qres_set_params( server_id, &params ) !=
149       QOS_E_NOSERVER )
150    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
151
152  if ( qres_get_params( -5, &params ) !=
153       QOS_E_INVALID_PARAM )
154    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
155  if ( qres_get_params( 5, &params ) !=
156       QOS_E_INVALID_PARAM )
157    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
158  if ( qres_get_params( server_id, &params ) !=
159       QOS_E_NOSERVER )
160    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
161
162  if ( qres_set_params( server_id, &params1 ) !=
163       QOS_E_INVALID_PARAM )
164    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
165  if ( qres_set_params( server_id, &params2 ) !=
166       QOS_E_INVALID_PARAM )
167    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
168  if ( qres_set_params( server_id, &params3 ) !=
169       QOS_E_INVALID_PARAM )
170    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
171  if ( qres_set_params( server_id, &params4 ) !=
172       QOS_E_INVALID_PARAM )
173    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
174
175  /* Error checks for Get server id */
176  printf( "Init: Get server id\n" );
177  if ( qres_get_sid( 0, RTEMS_SELF, &server_id ) !=
178       QOS_E_NOSERVER )
179    printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
180
181  /* Error checks for Get approved budget */
182  printf( "Init: Get approved budget\n" );
183  if ( qres_get_appr_budget( -5, &approved_budget ) !=
184       QOS_E_INVALID_PARAM )
185    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
186  if ( qres_get_appr_budget( 5, &approved_budget ) !=
187       QOS_E_INVALID_PARAM )
188    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
189  if ( qres_get_appr_budget( server_id, &approved_budget ) !=
190       QOS_E_NOSERVER )
191    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
192
193  /* Error checks for Get current budget */
194  printf( "Init: Get current budget\n" );
195  if ( qres_get_curr_budget( -5, &current_budget ) !=
196       QOS_E_INVALID_PARAM )
197    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
198  if ( qres_get_curr_budget( 5, &current_budget ) !=
199       QOS_E_INVALID_PARAM )
200    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
201  if ( qres_get_curr_budget( server_id, &current_budget ) !=
202       QOS_E_NOSERVER )
203    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
204
205  /* Error checks for Get execution time */
206  printf( "Init: Get execution time\n" );
207  if ( qres_get_exec_time( -5, &exec_time, &abs_time ) !=
208       QOS_E_INVALID_PARAM )
209    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
210  if ( qres_get_exec_time( 5, &exec_time, &abs_time ) !=
211       QOS_E_INVALID_PARAM )
212    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
213  if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) !=
214       QOS_E_NOSERVER )
215    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
216
217  /* Restart QRES library */
218  printf( "Init: Cleaning up QRES\n" );
219  if ( qres_cleanup() )
220    printf( "ERROR: QRES CLEANUP FAILED\n" );
221  printf( "Init: Initializing the QRES\n" );
222  if ( qres_init() )
223    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
224
225  /* Start periodic task */
226  printf( "Init: Starting periodic task\n" );
227  status = rtems_task_start( Task_id, Task_Periodic, 1 );
228  directive_failed( status, "rtems_task_start periodic" );
229
230  status = rtems_task_delete( RTEMS_SELF );
231  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
232}
Note: See TracBrowser for help on using the repository browser.