source: rtems/testsuites/sptests/spqreslib/init.c @ 1c2b94a

4.115
Last change on this file since 1c2b94a was 1c2b94a, checked in by Petr Benes <petben@…>, on 04/16/12 at 03:12:08

PR1908: QoS library for CBS scheduler

Add the lipqos and sptest.

  • Property mode set to 100644
File size: 8.4 KB
Line 
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
24rtems_task Init(
25  rtems_task_argument argument
26)
27{
28  rtems_status_code status;
29  qres_sid_t server_id, server_id2;
30  time_t approved_budget, exec_time, abs_time, current_budget;
31  qres_params_t params, params1, params2, params3, params4;
32
33  Priority = 30;
34  Period    = 30;
35  Execution = 10;
36  Phase = 0;
37
38  params.P = 1;
39  params.Q = 1;
40
41  params1 = params2 = params3 = params4 = params;
42  params1.Q = -1;
43  params2.Q = SCHEDULER_EDF_PRIO_MSB + 1;
44  params3.P = -1;
45  params4.P = SCHEDULER_EDF_PRIO_MSB + 1;
46
47  puts( "\n\n*** TEST QRES LIBRARY ***" );
48
49  Task_name = rtems_build_name( 'P', 'T', '1', ' ' );
50
51  status = rtems_task_create(
52    Task_name,
53    Priority,
54    RTEMS_MINIMUM_STACK_SIZE * 4,
55    RTEMS_DEFAULT_MODES,
56    RTEMS_DEFAULT_ATTRIBUTES,
57    &Task_id
58  );
59  directive_failed( status, "rtems_task_create loop" );
60
61  printf( "Init: Initializing the qres library\n" );
62  if ( qres_init() )
63    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
64
65  /* Error checks for Create server and Destroy server  */
66  printf( "Init: Create server and Destroy server\n" );
67  if ( qres_destroy_server( -5 ) !=
68       QOS_E_INVALID_PARAM )
69    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
70  if ( qres_destroy_server( 5 ) !=
71       QOS_E_INVALID_PARAM )
72    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
73  if ( qres_destroy_server( 0 ) != QOS_E_NOSERVER )
74    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
75  if ( qres_create_server( &params1, &server_id ) !=
76       QOS_E_INVALID_PARAM )
77    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
78  if ( qres_create_server( &params2, &server_id ) !=
79       QOS_E_INVALID_PARAM )
80    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
81  if ( qres_create_server( &params3, &server_id ) !=
82       QOS_E_INVALID_PARAM )
83    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
84  if ( qres_create_server( &params4, &server_id ) !=
85       QOS_E_INVALID_PARAM )
86    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
87  if ( qres_create_server( &params, &server_id2 ) )
88    printf( "ERROR: CREATE SERVER FAILED\n" );
89  if ( qres_create_server( &params, &server_id ) )
90    printf( "ERROR: CREATE SERVER FAILED\n" );
91  if ( qres_create_server( &params, &server_id ) !=
92       QOS_E_FULL )
93    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
94
95  /* Error checks for Attach thread and Detach thread */
96  printf( "Init: Attach thread\n" );
97  if ( qres_attach_thread( -5, 0, RTEMS_SELF ) !=
98       QOS_E_INVALID_PARAM )
99    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
100  if ( qres_attach_thread( 5, 0, RTEMS_SELF ) !=
101       QOS_E_INVALID_PARAM )
102    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
103  if ( qres_attach_thread( server_id, 0, 1234 ) !=
104       QOS_E_INVALID_PARAM )
105    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
106  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) )
107    printf( "ERROR: ATTACH THREAD FAILED\n" );
108  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
109       QOS_E_FULL )
110    printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
111  if ( qres_attach_thread( server_id, 0, Task_id ) !=
112       QOS_E_FULL )
113    printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
114  if ( qres_destroy_server( server_id ) )
115    printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
116  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
117       QOS_E_NOSERVER )
118    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
119
120  printf( "Init: Detach thread\n" );
121  if ( qres_detach_thread( -5, 0, RTEMS_SELF ) !=
122       QOS_E_INVALID_PARAM )
123    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
124  if ( qres_detach_thread( 5, 0, RTEMS_SELF ) !=
125       QOS_E_INVALID_PARAM )
126    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
127  if ( qres_detach_thread( server_id2, 0, 1234 ) !=
128       QOS_E_INVALID_PARAM )
129    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
130  if ( qres_detach_thread( server_id, 0, RTEMS_SELF ) !=
131       QOS_E_NOSERVER )
132    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
133  qres_destroy_server( server_id2 );
134
135  /* Error checks for Set params and Get params */
136  printf( "Init: Set params and Get params\n" );
137  if ( qres_set_params( -5, &params ) !=
138       QOS_E_INVALID_PARAM )
139    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
140  if ( qres_set_params( 5, &params ) !=
141       QOS_E_INVALID_PARAM )
142    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
143  if ( qres_set_params( server_id, &params ) !=
144       QOS_E_NOSERVER )
145    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
146
147  if ( qres_get_params( -5, &params ) !=
148       QOS_E_INVALID_PARAM )
149    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
150  if ( qres_get_params( 5, &params ) !=
151       QOS_E_INVALID_PARAM )
152    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
153  if ( qres_get_params( server_id, &params ) !=
154       QOS_E_NOSERVER )
155    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
156
157  if ( qres_set_params( server_id, &params1 ) !=
158       QOS_E_INVALID_PARAM )
159    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
160  if ( qres_set_params( server_id, &params2 ) !=
161       QOS_E_INVALID_PARAM )
162    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
163  if ( qres_set_params( server_id, &params3 ) !=
164       QOS_E_INVALID_PARAM )
165    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
166  if ( qres_set_params( server_id, &params4 ) !=
167       QOS_E_INVALID_PARAM )
168    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
169
170  /* Error checks for Get server id */
171  printf( "Init: Get server id\n" );
172  if ( qres_get_sid( 0, RTEMS_SELF, &server_id ) !=
173       QOS_E_NOSERVER )
174    printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
175
176  /* Error checks for Get approved budget */
177  printf( "Init: Get approved budget\n" );
178  if ( qres_get_appr_budget( -5, &approved_budget ) !=
179       QOS_E_INVALID_PARAM )
180    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
181  if ( qres_get_appr_budget( 5, &approved_budget ) !=
182       QOS_E_INVALID_PARAM )
183    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
184  if ( qres_get_appr_budget( server_id, &approved_budget ) !=
185       QOS_E_NOSERVER )
186    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
187
188  /* Error checks for Get current budget */
189  printf( "Init: Get current budget\n" );
190  if ( qres_get_curr_budget( -5, &current_budget ) !=
191       QOS_E_INVALID_PARAM )
192    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
193  if ( qres_get_curr_budget( 5, &current_budget ) !=
194       QOS_E_INVALID_PARAM )
195    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
196  if ( qres_get_curr_budget( server_id, &current_budget ) !=
197       QOS_E_NOSERVER )
198    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
199
200  /* Error checks for Get execution time */
201  printf( "Init: Get execution time\n" );
202  if ( qres_get_exec_time( -5, &exec_time, &abs_time ) !=
203       QOS_E_INVALID_PARAM )
204    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
205  if ( qres_get_exec_time( 5, &exec_time, &abs_time ) !=
206       QOS_E_INVALID_PARAM )
207    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
208  if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) !=
209       QOS_E_NOSERVER )
210    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
211
212  /* Restart QRES library */
213  printf( "Init: Cleaning up QRES\n" );
214  if ( qres_cleanup() )
215    printf( "ERROR: QRES CLEANUP FAILED\n" );
216  printf( "Init: Initializing the QRES\n" );
217  if ( qres_init() )
218    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
219
220  /* Start periodic task */
221  printf( "Init: Starting periodic task\n" );
222  status = rtems_task_start( Task_id, Task_Periodic, 1 );
223  directive_failed( status, "rtems_task_start periodic" );
224
225  status = rtems_task_delete( RTEMS_SELF );
226  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
227}
Note: See TracBrowser for help on using the repository browser.