source: rtems/testsuites/sptests/spqreslib/init.c

Last change on this file was 51b3cbca, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 4, 2018 at 1:23:25 PM

tests: Use rtems_task_exit()

Update #3533.

  • Property mode set to 100644
File size: 7.7 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.org/license/LICENSE.
17 */
18
19#define CONFIGURE_INIT
20#include "system.h"
21
22#include <rtems/score/scheduleredfimpl.h>
23
24const char rtems_test_name[] = "SPQRESLIB";
25
26rtems_id   Task_id;
27rtems_task_priority Priority;
28time_t  Period;
29time_t  Execution;
30time_t  Phase;
31
32rtems_task Init(
33  rtems_task_argument argument
34)
35{
36  rtems_status_code status;
37  qres_sid_t server_id, server_id2;
38  time_t approved_budget, exec_time, abs_time, current_budget;
39  qres_params_t params, params1, params3;
40
41  Priority = 30;
42  Period    = 30;
43  Execution = 10;
44  Phase = 0;
45
46  params.P = 1;
47  params.Q = 1;
48
49  params1 = params3 = params;
50  params1.Q = -1;
51  params3.P = -1;
52
53  TEST_BEGIN();
54
55
56  status = rtems_task_create(
57    rtems_build_name( 'P', 'T', '1', ' ' ),
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( &params3, &server_id ) !=
84       QOS_E_INVALID_PARAM )
85    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
86  if ( qres_create_server( &params, &server_id2 ) )
87    printf( "ERROR: CREATE SERVER FAILED\n" );
88  if ( qres_create_server( &params, &server_id ) )
89    printf( "ERROR: CREATE SERVER FAILED\n" );
90  if ( qres_create_server( &params, &server_id ) !=
91       QOS_E_FULL )
92    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
93
94  /* Error checks for Attach thread and Detach thread */
95  printf( "Init: Attach thread\n" );
96  if ( qres_attach_thread( -5, 0, RTEMS_SELF ) !=
97       QOS_E_INVALID_PARAM )
98    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
99  if ( qres_attach_thread( 5, 0, RTEMS_SELF ) !=
100       QOS_E_INVALID_PARAM )
101    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
102  if ( qres_attach_thread( server_id, 0, 1234 ) !=
103       QOS_E_INVALID_PARAM )
104    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
105  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) )
106    printf( "ERROR: ATTACH THREAD FAILED\n" );
107  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
108       QOS_E_FULL )
109    printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
110  if ( qres_attach_thread( server_id, 0, Task_id ) !=
111       QOS_E_FULL )
112    printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
113  if ( qres_destroy_server( server_id ) )
114    printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
115  if ( qres_attach_thread( server_id, 0, RTEMS_SELF ) !=
116       QOS_E_NOSERVER )
117    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
118
119  printf( "Init: Detach thread\n" );
120  if ( qres_detach_thread( -5, 0, RTEMS_SELF ) !=
121       QOS_E_INVALID_PARAM )
122    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
123  if ( qres_detach_thread( 5, 0, RTEMS_SELF ) !=
124       QOS_E_INVALID_PARAM )
125    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
126  if ( qres_detach_thread( server_id2, 0, 1234 ) !=
127       QOS_E_INVALID_PARAM )
128    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
129  if ( qres_detach_thread( server_id, 0, RTEMS_SELF ) !=
130       QOS_E_NOSERVER )
131    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
132  qres_destroy_server( server_id2 );
133
134  /* Error checks for Set params and Get params */
135  printf( "Init: Set params and Get params\n" );
136  if ( qres_set_params( -5, &params ) !=
137       QOS_E_INVALID_PARAM )
138    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
139  if ( qres_set_params( 5, &params ) !=
140       QOS_E_INVALID_PARAM )
141    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
142  if ( qres_set_params( server_id, &params ) !=
143       QOS_E_NOSERVER )
144    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
145
146  if ( qres_get_params( -5, &params ) !=
147       QOS_E_INVALID_PARAM )
148    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
149  if ( qres_get_params( 5, &params ) !=
150       QOS_E_INVALID_PARAM )
151    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
152  if ( qres_get_params( server_id, &params ) !=
153       QOS_E_NOSERVER )
154    printf( "ERROR: GET PARAMS PASSED UNEXPECTEDLY\n" );
155
156  if ( qres_set_params( server_id, &params1 ) !=
157       QOS_E_INVALID_PARAM )
158    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
159  if ( qres_set_params( server_id, &params3 ) !=
160       QOS_E_INVALID_PARAM )
161    printf( "ERROR: SET PARAMS PASSED UNEXPECTEDLY\n" );
162
163  /* Error checks for Get server id */
164  printf( "Init: Get server id\n" );
165  if ( qres_get_sid( 0, RTEMS_SELF, &server_id ) !=
166       QOS_E_NOSERVER )
167    printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
168
169  /* Error checks for Get approved budget */
170  printf( "Init: Get approved budget\n" );
171  if ( qres_get_appr_budget( -5, &approved_budget ) !=
172       QOS_E_INVALID_PARAM )
173    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
174  if ( qres_get_appr_budget( 5, &approved_budget ) !=
175       QOS_E_INVALID_PARAM )
176    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
177  if ( qres_get_appr_budget( server_id, &approved_budget ) !=
178       QOS_E_NOSERVER )
179    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
180
181  /* Error checks for Get current budget */
182  printf( "Init: Get current budget\n" );
183  if ( qres_get_curr_budget( -5, &current_budget ) !=
184       QOS_E_INVALID_PARAM )
185    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
186  if ( qres_get_curr_budget( 5, &current_budget ) !=
187       QOS_E_INVALID_PARAM )
188    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
189  if ( qres_get_curr_budget( server_id, &current_budget ) !=
190       QOS_E_NOSERVER )
191    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
192
193  /* Error checks for Get execution time */
194  printf( "Init: Get execution time\n" );
195  if ( qres_get_exec_time( -5, &exec_time, &abs_time ) !=
196       QOS_E_INVALID_PARAM )
197    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
198  if ( qres_get_exec_time( 5, &exec_time, &abs_time ) !=
199       QOS_E_INVALID_PARAM )
200    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
201  if ( qres_get_exec_time( server_id, &exec_time, &abs_time ) !=
202       QOS_E_NOSERVER )
203    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
204
205  /* Restart QRES library */
206  printf( "Init: Cleaning up QRES\n" );
207  if ( qres_cleanup() )
208    printf( "ERROR: QRES CLEANUP FAILED\n" );
209  printf( "Init: Initializing the QRES\n" );
210  if ( qres_init() )
211    printf( "ERROR: QRES INITIALIZATION FAILED\n" );
212
213  /* Start periodic task */
214  printf( "Init: Starting periodic task\n" );
215  status = rtems_task_start( Task_id, Task_Periodic, 1 );
216  directive_failed( status, "rtems_task_start periodic" );
217
218  rtems_task_exit();
219}
Note: See TracBrowser for help on using the repository browser.