source: rtems/testsuites/sptests/spcbssched02/init.c @ 4e8589d

4.115
Last change on this file since 4e8589d was 4e8589d, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/29/11 at 16:20:49

2011-09-29 Ralf Corsépius <ralf.corsepius@…>

  • sp75/init.c, spcbssched01/init.c, spcbssched01/task1.c spcbssched02/init.c, spcbssched02/task_periodic.c, spcbssched03/init.c, spcbssched03/tasks_aperiodic.c, spcbssched03/tasks_periodic.c, spedfsched01/init.c, spedfsched01/task1.c, spedfsched02/getall.c, spedfsched02/init.c, spedfsched02/task1.c, spedfsched03/init.c, spedfsched03/tasks_aperiodic.c, spedfsched03/tasks_periodic.c, sprbtree01/init.c: Add HAVE_CONFIG_H.
  • Property mode set to 100644
File size: 10.3 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 parameters:
10 *    argument - task argument
11 *
12 *  Output parameters:  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#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24
25#define CONFIGURE_INIT
26#include "system.h"
27
28rtems_task Init(
29  rtems_task_argument argument
30)
31{
32  rtems_status_code status;
33  rtems_cbs_server_id server_id, server_id2;
34  time_t approved_budget, exec_time, abs_time, remaining_budget;
35  rtems_cbs_parameters params, params1, params2, params3, params4;
36
37  Priority = 30;
38  Period    = 30;
39  Execution = 10;
40  Phase = 0;
41
42  params.deadline = 1;
43  params.budget = 1;
44
45  params1 = params2 = params3 = params4 = params;
46  params1.budget = -1;
47  params2.budget = SCHEDULER_EDF_PRIO_MSB + 1;
48  params3.deadline = -1;
49  params4.deadline = SCHEDULER_EDF_PRIO_MSB + 1;
50
51  puts( "\n\n*** TEST CBS SCHEDULER 2 ***" );
52
53  Task_name = rtems_build_name( 'P', 'T', '1', ' ' );
54  Task_name2 = rtems_build_name( 'P', 'T', '2', ' ' );
55
56  status = rtems_task_create(
57    Task_name,
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  status = rtems_task_create(
67    Task_name2,
68    Priority,
69    RTEMS_MINIMUM_STACK_SIZE * 4,
70    RTEMS_NO_PREEMPT,
71    RTEMS_DEFAULT_ATTRIBUTES,
72    &Task_id2
73  );
74  directive_failed( status, "rtems_task_create loop" );
75
76  printf( "Init: Initializing the CBS\n" );
77  if ( rtems_cbs_initialize() )
78    printf( "ERROR: CBS INITIALIZATION FAILED\n" );
79
80  /* Error checks for Create server and Destroy server  */
81  printf( "Init: Create server and Destroy server\n" );
82  if ( rtems_cbs_destroy_server( -5 ) !=
83       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
84    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
85  if ( rtems_cbs_destroy_server( 5 ) !=
86       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
87    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
88  if ( rtems_cbs_destroy_server( 0 ) != SCHEDULER_CBS_ERROR_NOSERVER )
89    printf( "ERROR: DESTROY SERVER PASSED UNEXPECTEDLY\n" );
90  if ( rtems_cbs_create_server( &params1, NULL, &server_id ) !=
91       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
92    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
93  if ( rtems_cbs_create_server( &params2, NULL, &server_id ) !=
94       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
95    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
96  if ( rtems_cbs_create_server( &params3, NULL, &server_id ) !=
97       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
98    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
99  if ( rtems_cbs_create_server( &params4, NULL, &server_id ) !=
100       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
101    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
102  if ( rtems_cbs_create_server( &params, NULL, &server_id2 ) )
103    printf( "ERROR: CREATE SERVER FAILED\n" );
104  if ( rtems_cbs_create_server( &params, NULL, &server_id ) )
105    printf( "ERROR: CREATE SERVER FAILED\n" );
106  if ( rtems_cbs_create_server( &params, NULL, &server_id ) )
107    printf( "ERROR: CREATE SERVER FAILED\n" );
108  if ( rtems_cbs_create_server( &params, NULL, &server_id ) !=
109       SCHEDULER_CBS_ERROR_FULL )
110    printf( "ERROR: CREATE SERVER PASSED UNEXPECTEDLY\n" );
111
112  /* Error checks for Attach thread and Detach thread */
113  printf( "Init: Attach thread\n" );
114  if ( rtems_cbs_attach_thread( -5, RTEMS_SELF ) !=
115       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
116    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
117  if ( rtems_cbs_attach_thread( 5, RTEMS_SELF ) !=
118       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
119    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
120  if ( rtems_cbs_attach_thread( server_id, 1234 ) !=
121       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
122    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
123  if ( rtems_cbs_attach_thread( server_id, RTEMS_SELF ) )
124    printf( "ERROR: ATTACH THREAD FAILED\n" );
125  if ( rtems_cbs_attach_thread( server_id, RTEMS_SELF ) !=
126       SCHEDULER_CBS_ERROR_FULL )
127    printf( "ERROR: ATTACH THREAD AGAIN PASSED UNEXPECTEDLY\n" );
128  if ( rtems_cbs_attach_thread( server_id, Task_id ) !=
129       SCHEDULER_CBS_ERROR_FULL )
130    printf( "ERROR: ATTACH THREAD TO FULL SERVER PASSED UNEXPECTEDLY \n" );
131  if ( rtems_cbs_destroy_server( server_id ) )
132    printf( "ERROR: DESTROY SERVER WITH THREAD ATTACHED FAILED\n" );
133  if ( rtems_cbs_attach_thread( server_id, RTEMS_SELF ) !=
134       SCHEDULER_CBS_ERROR_NOSERVER )
135    printf( "ERROR: ATTACH THREAD PASSED UNEXPECTEDLY\n" );
136
137  printf( "Init: Detach thread\n" );
138  if ( rtems_cbs_detach_thread( -5, RTEMS_SELF ) !=
139       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
140    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
141  if ( rtems_cbs_detach_thread( 5, RTEMS_SELF ) !=
142       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
143    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY\n" );
144  if ( rtems_cbs_detach_thread( server_id2, 1234 ) !=
145       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
146    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY \n" );
147  if ( rtems_cbs_detach_thread( server_id, RTEMS_SELF ) !=
148       SCHEDULER_CBS_ERROR_NOSERVER )
149    printf( "ERROR: DETACH THREAD PASSED UNEXPECTEDLY4\n" );
150  rtems_cbs_destroy_server( server_id2 );
151
152  /* Error checks for Set parameters and Get parameters */
153  printf( "Init: Set parameters and Get parameters\n" );
154  if ( rtems_cbs_set_parameters( -5, &params ) !=
155       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
156    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
157  if ( rtems_cbs_set_parameters( 5, &params ) !=
158       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
159    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
160  if ( rtems_cbs_set_parameters( server_id, &params ) !=
161       SCHEDULER_CBS_ERROR_NOSERVER )
162    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
163
164  if ( rtems_cbs_get_parameters( -5, &params ) !=
165       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
166    printf( "ERROR: GET PARAMETERS PASSED UNEXPECTEDLY\n" );
167  if ( rtems_cbs_get_parameters( 5, &params ) !=
168       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
169    printf( "ERROR: GET PARAMETERS PASSED UNEXPECTEDLY\n" );
170  if ( rtems_cbs_get_parameters( server_id, &params ) !=
171       SCHEDULER_CBS_ERROR_NOSERVER )
172    printf( "ERROR: GET PARAMETERS PASSED UNEXPECTEDLY\n" );
173
174  if ( rtems_cbs_set_parameters( server_id, &params1 ) !=
175       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
176    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
177  if ( rtems_cbs_set_parameters( server_id, &params2 ) !=
178       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
179    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
180  if ( rtems_cbs_set_parameters( server_id, &params3 ) !=
181       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
182    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
183  if ( rtems_cbs_set_parameters( server_id, &params4 ) !=
184       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
185    printf( "ERROR: SET PARAMETERS PASSED UNEXPECTEDLY\n" );
186
187  /* Error checks for Get server id */
188  printf( "Init: Get server id\n" );
189  if ( rtems_cbs_get_server_id( RTEMS_SELF, &server_id ) !=
190       SCHEDULER_CBS_ERROR_NOSERVER )
191    printf( "ERROR: GET SERVER ID PASSED UNEXPECTEDLY\n" );
192
193  /* Error checks for Get approved budget */
194  printf( "Init: Get approved budget\n" );
195  if ( rtems_cbs_get_approved_budget( -5, &approved_budget ) !=
196       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
197    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
198  if ( rtems_cbs_get_approved_budget( 5, &approved_budget ) !=
199       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
200    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
201  if ( rtems_cbs_get_approved_budget( server_id, &approved_budget ) !=
202       SCHEDULER_CBS_ERROR_NOSERVER )
203    printf( "ERROR: GET APPROVED BUDGET PASSED UNEXPECTEDLY\n" );
204
205  /* Error checks for Get remaining budget */
206  printf( "Init: Get remaining budget\n" );
207  if ( rtems_cbs_get_remaining_budget( -5, &remaining_budget ) !=
208       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
209    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
210  if ( rtems_cbs_get_remaining_budget( 5, &remaining_budget ) !=
211       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
212    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
213  if ( rtems_cbs_get_remaining_budget( server_id, &remaining_budget ) !=
214       SCHEDULER_CBS_ERROR_NOSERVER )
215    printf( "ERROR: GET REMAINING BUDGET PASSED UNEXPECTEDLY\n" );
216
217  /* Error checks for Get execution time */
218  printf( "Init: Get execution time\n" );
219  if ( rtems_cbs_get_execution_time( -5, &exec_time, &abs_time ) !=
220       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
221    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
222  if ( rtems_cbs_get_execution_time( 5, &exec_time, &abs_time ) !=
223       SCHEDULER_CBS_ERROR_INVALID_PARAMETER )
224    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
225  if ( rtems_cbs_get_execution_time( server_id, &exec_time, &abs_time ) !=
226       SCHEDULER_CBS_ERROR_NOSERVER )
227    printf( "ERROR: GET EXECUTION TIME PASSED UNEXPECTEDLY\n" );
228
229  /* Restart CBS library */
230  printf( "Init: Cleaning up CBS\n" );
231  if ( rtems_cbs_cleanup() )
232    printf( "ERROR: CBS CLEANUP FAILED\n" );
233  printf( "Init: Initializing the CBS\n" );
234  if ( rtems_cbs_initialize() )
235    printf( "ERROR: CBS INITIALIZATION FAILED\n" );
236
237  /* Start periodic tasks */
238  printf( "Init: Starting periodic task\n" );
239  status = rtems_task_start( Task_id, Task_Periodic, 1 );
240  directive_failed( status, "rtems_task_start periodic" );
241  status = rtems_task_start( Task_id2, Task_Periodic, 2 );
242  directive_failed( status, "rtems_task_start periodic" );
243
244  rtems_task_wake_after( 130 );
245
246  printf( "Init: Checking server with a deleted task\n" );
247  if ( rtems_cbs_get_execution_time( 0, &exec_time, &abs_time ) )
248    printf( "ERROR: GET EXECUTION TIME FAILED\n" );
249  if ( rtems_cbs_get_remaining_budget( 0, &remaining_budget) )
250    printf( "ERROR: GET REMAINING BUDGET FAILED\n" );
251
252  if ( rtems_cbs_cleanup() )
253    printf( "ERROR: CBS CLEANUP\n" );
254
255  fflush(stdout);
256  puts( "*** END OF TEST CBS SCHEDULER 2 ***" );
257  rtems_test_exit( 0 );
258}
Note: See TracBrowser for help on using the repository browser.