source: rtems/testsuites/itrontests/itrontask02/init.c @ afb11f8

4.104.114.84.95
Last change on this file since afb11f8 was afb11f8, checked in by Joel Sherrill <joel.sherrill@…>, on 11/12/99 at 22:00:10

+ Modified calls to use TSK_SLF for calls to self.
+ Modified calls to use the task id macro for calls to the PREEMPT task.

  • Property mode set to 100644
File size: 14.3 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is called from init_exec 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:  NONE
10 *
11 *  Output parameters:  NONE
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#define TEST_INIT
21#include "system.h"
22#include <stdio.h>
23#include <assert.h>
24
25void ITRON_Init( void )
26{
27
28  /*
29   *  Status Codes for these errors
30   *
31   *
32   *  E_OK - Normal Completion
33   *
34   *  E_NOMEM - Insufficient memory (Memory for control block and/or user
35   *            stack cannot be allocated)
36   *
37   *  E_ID - Invalid ID Number (tskid was invalid or could not be used)
38   *
39   *  E_RSATR - Reserved attribute (tskatr was invalid or could not be used)
40   *
41   *  E_OBJ - Invalid object state (a task of the same ID already exists)
42   *
43   *  E_OACV - Object access violation (A tskid less than -4 was specified
44   *           from a user task. This is implementation dependent.)
45   *
46   *  E_PAR - Parameter error (pk_ctsk, task, itskpri and/or stksz is invalid)
47   *
48   *  E_NOEXS - Object does not exist (the task specified by tskid does not
49   *            exist)
50   *
51   *  E_CTX - Context error (issued from task-independent portions or a task
52   *          in dispatch disabled state)
53   *
54   *
55   *
56   *  Network Specific Errors  (ITRON calls these Connection Function Errors)
57   *
58   *  EN_OBJNO - An object number which could not be accessed on the target
59   *             node is specified.
60   *
61   *  EN_CTXID - Specified an object on another node when the system call
62   *             was issued from a task in dispatch disabled state or from
63   *             a task-independent portion
64   *
65   *  EN_PAR - A value outside the range supported by the target node and/or
66   *           transmission packet format was specified as a parameter
67   *           (a value outside supported range was specified for exinf,
68   *           tskatr, task, itskpri and/or stksz)
69   *
70   *  EN_RPAR - A value outside the range supported by the requesting node
71   *            and/or transmission packet format was returned as a return
72   *            parameter (a value outside supported range was returned for
73   *            exinf, tskpri and/or tskstat)
74   *
75   */
76
77
78  rtems_time_of_day  time;
79  ER                 status;
80  T_CTSK             pk_ctsk;
81  T_RTSK             pk_rtsk;   /* Reference Task Packet */
82
83
84  puts( "\n\n*** ITRON TASK TEST 2 ***\n" );
85  puts( "\n*** Create Task Errors ***" );
86
87  build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
88  status = rtems_clock_set( &time );
89  directive_failed( status, "rtems_clock_set" );
90
91  pk_ctsk.exinf    = NULL;
92  pk_ctsk.tskatr   = TA_HLNG;
93  pk_ctsk.itskpri  = 1;
94  pk_ctsk.task     = Preempt_task;
95  pk_ctsk.stksz    = RTEMS_MINIMUM_STACK_SIZE;
96
97  puts( "Init - cre_tsk - Preempt Task" );
98  status = cre_tsk( PREEMPT_TASK_ID, &pk_ctsk );
99  assert( status == E_OK );
100
101  /*
102   *  Bad ID errors
103   */
104
105  puts( "Init - cre_tsk - access violation ( id less than -4) - E_OACV" );
106  status = cre_tsk( -5, &pk_ctsk );
107  assert( status == E_OACV );
108
109  puts( "Init - cre_tsk - bad id (between 0 and -4) - E_ID" );
110  status = cre_tsk( -2, &pk_ctsk );
111  assert( status == E_ID );
112
113  puts( "Init - cre_tsk - cannot create TSK_SELF  - E_ID" );
114  status = cre_tsk( TSK_SELF, &pk_ctsk );
115  assert( status == E_ID );
116
117  puts( "Init - cre_tsk - invalid id; id already exists  - E_OBJ" );
118  status = cre_tsk( 1, &pk_ctsk );
119  assert( status == E_OBJ );
120
121  /*
122   *  Bad task attribute errors
123   */
124
125  pk_ctsk.tskatr = -1;
126  puts( "Init - cre_tsk - tskatr is invalid - E_RSATR" );
127  status = cre_tsk( 5, &pk_ctsk );
128  assert( status == E_RSATR );
129
130  puts( "Init - cre_tsk - pk_ctsk is invalid - E_PAR" );
131  status = cre_tsk( 5, NULL );
132  assert( status == E_PAR );
133
134  pk_ctsk.tskatr = TA_HLNG;
135  pk_ctsk.itskpri = 0;
136  puts( "Init - cre_tsk - itskpri is 0 - E_PAR" );
137  status = cre_tsk( 5, &pk_ctsk );
138  assert( status == E_PAR );
139  pk_ctsk.itskpri = 257;         /* XXX Design parameter not requirement. */
140  puts( "Init - cre_tsk - itskpri is 257 - E_PAR" );
141  status = cre_tsk( 5, &pk_ctsk );
142  assert( status == E_PAR );
143
144  pk_ctsk.stksz = -1;
145  puts( "Init - cre_tsk - stksz is invalid - E_PAR" );
146  status = cre_tsk( 5, &pk_ctsk );
147  assert( status == E_PAR );
148
149  pk_ctsk.task = NULL;
150  puts( "Init - cre_tsk - task is invalid - E_PAR" );
151  status = cre_tsk( 5, &pk_ctsk );
152  assert( status == E_PAR );
153
154
155#if (0)
156  /* these errors can not be generated for cre_tsk at this time */
157  assert( status == E_NOMEM );
158  assert( status == EN_OBJNO );
159  assert( status == EN_CTXID );
160  assert( status == EN_PAR );
161#endif
162
163
164  puts( "\n\n*** Delete Task Errors ***" );
165
166  /*
167   *  Reset structure
168   */
169
170  pk_ctsk.exinf    = NULL;
171  pk_ctsk.tskatr   = TA_HLNG;
172  pk_ctsk.itskpri  = 1;
173  pk_ctsk.task     = Preempt_task;
174  pk_ctsk.stksz    = RTEMS_MINIMUM_STACK_SIZE;
175
176
177  puts( "Init - del_tsk - cannot delete TSK_SELF - E_OBJ" );
178  status = del_tsk( TSK_SELF );
179  assert( status == E_OBJ );
180
181  puts( "Init - del_tsk - task is not DORMANT - E_OBJ" );
182  status = del_tsk( PREEMPT_TASK_ID );
183  assert( status == E_OBJ );
184
185  puts( "Init - del_tsk - task does not exist - E_NOEXS" );
186  status = del_tsk( 5 );
187  assert( status == E_NOEXS );
188
189  puts( "Init - del_tsk - access violation ( id less than -4) - E_OACV" );
190  status =  del_tsk( -5 );
191  assert( status == E_OACV );
192
193  puts( "Init - del_tsk - cannot delete TSK_SELF - E_OBJ" );
194  status = del_tsk( TSK_SELF );
195  assert( status == E_OBJ );
196
197  puts( "Init - del_tsk - bad id (between 0 and -4) - E_ID" );
198  status = del_tsk( -3 );
199  assert( status == E_ID );
200
201#if (0)
202  /* these errors can not be generated for del_tsk at this time */
203  assert( status == EN_OBJNO );
204  assert( status == EN_CTXID );
205#endif
206
207
208  puts( "\n\n*** Start Task Errors ***" );
209
210  puts( "Init - sta_tsk - access violation ( id less than -4) - E_OACV" );
211  status = sta_tsk( -5, 1 );
212  assert( status == E_OACV );
213
214  puts( "Init - sta_tsk - bad id (between 0 and -4) - E_ID" );
215  status = sta_tsk( -2, 1 );
216  assert( status == E_ID );
217
218  puts( "Init - sta_tsk - cannot start TSK_SELF - E_OBJ" );
219  status = sta_tsk( TSK_SELF, 1 );
220  assert( status == E_OBJ );
221
222  puts( "Init - sta_tsk - task is not DORMANT  - E_OBJ" );
223  status = sta_tsk( PREEMPT_TASK_ID, 1 );
224  assert( status == E_OBJ );
225
226  puts( "Init - sta_tsk - task does not exist  - E_NOEXS" );
227  status = sta_tsk( 5, 1 );
228  assert( status == E_NOEXS );
229
230#if (0)
231  /* these errors can not be generated for sta_tsk at this time */
232  assert( status == EN_OBJNO );
233  assert( status == EN_CTXID );
234  assert( status == EN_PAR );
235#endif
236
237
238#if (0)
239  /* these errors can not be tested at this time */
240  puts( "\n\n*** Exit Task Errors ***" );
241  puts( "Init - ext_tsk - context error - E_CTX" );
242  status = ext_tsk(  );
243  assert( status == E_CTX );
244
245  puts( "\n\n*** Exit and Delete Task Errors ***" );
246  puts( "Init - exd_tsk - context error - E_CTX" );
247  status = exd_tsk(  );
248  assert( status == E_CTX );
249#endif
250
251
252  puts( "\n\n*** Terminate Other Task Errors ***" );
253
254  puts( "Init - ter_tsk - bad id (between 0 and -4) - E_ID" );
255  status = ter_tsk( -2 );
256  assert( status == E_ID );
257
258  puts( "Init - ter_tsk - cannot terminate TSK_SELF (0) - E_OBJ" );
259  status = ter_tsk( TSK_SELF );
260  assert( status == E_OBJ );
261
262  puts( "Init - ter_tsk - task is not DORMANT - E_OBJ" );
263  status = ter_tsk( PREEMPT_TASK_ID );
264  assert( status == E_OBJ );
265
266  puts( "Init - ter_tsk - task does not exist - E_NOEXS" );
267  status = ter_tsk( 5 );
268  assert( status == E_NOEXS );
269
270  puts( "Init - ter_tsk - access violation ( id less than -4) - E_OACV" );
271  status = ter_tsk( -5 );
272  assert( status == E_OACV );
273
274#if (0)
275  /* these errors can not be generated for ter_tsk at this time */
276  assert( status == EN_OBJNO );
277  assert( status == EN_CTXID );
278#endif
279
280
281#if (0)
282  status = dis_dsp( );
283  assert( status == E_CTX );
284
285  status = ena_dsp( );
286  assert( status == E_CTX );
287#endif
288
289
290  puts( "\n\n*** Change Priority Task Errors ***" );
291
292  puts( "Init - chg_pri - bad id (between 0 and -4) - E_ID" );
293  status = chg_pri( -2, 1 );
294  assert( status == E_ID );
295
296  /*  Call from task independent portion to cause E_OBJ
297  puts( "Init - chg_pri - change priority of TSK_SELF - E_OBJ" );
298  status = chg_pri( TSK_SELF, 1 );
299  assert( status == E_OBJ );
300  */
301
302  /*  Need a dormant task to call */
303  puts( "Init - chg_pri - task is not DORMANT - E_OBJ" );
304  status = chg_pri( PREEMPT_TASK_ID, 1 );
305  assert( status == E_OBJ );
306
307  puts( "Init - chg_pri - task does not exist - E_NOEXS" );
308  status = chg_pri( 5, 1 );
309  assert( status == E_NOEXS );
310
311  puts( "Init - chg_pri - access violation ( id less than -4) - E_OACV" );
312  status =  chg_pri( -5, 1 );
313  assert( status == E_OACV );
314
315  puts( "Init - chg_pri - invalid priority - E_PAR" );
316  status =  chg_pri( 1, -1 );
317  assert( status == E_PAR );
318
319#if (0)
320  /* these errors can not be generated for chg_pri at this time */
321  assert( status == EN_OBJNO );
322  assert( status == EN_CTXID );
323  assert( status == EN_PAR );
324#endif
325
326  /*  This gave me a nasty-gram
327   *  "core_find_mapping() - access to unmaped address, attach a default map
328   *   to handle this - addr=0x80002098 nr_bytes=0x4 processor=0x40134008
329   *   cia=0xc744"
330   */
331 
332   puts( "\n\n*** Rotate Ready Queue Errors ***" );
333   puts( "Init - rot_rdq - priority  -1 - E_PAR" );
334   status = rot_rdq( -1 );
335   assert( status == E_PAR );
336   puts( "Init - rot_rdq - priority  257 - E_PAR" );
337   status = rot_rdq( 257 );
338   assert( status == E_PAR );
339
340#if (0)
341  /* This routine is not coded */
342  rel_wai( ID );
343  assert( status == E_OK );
344  assert( status == E_ID );
345  assert( status == E_NOEXS );
346  assert( status == E_OACV );
347  assert( status == E_OBJ );
348  assert( status == EN_OBJNO );
349  assert( status == EN_CTXID );
350#endif
351
352
353#if (0)
354  get_tid( ID );
355  assert( status == E_OK );
356#endif
357
358  puts( "\n\n*** Reference Task Status Errors ***" );
359  puts( "Init - ref_tsk - bad id (between 0 and -4) - E_ID" );
360  status = ref_tsk( &pk_rtsk, -2 );
361  assert( status == E_ID );
362
363  /*  Call from task independent portion to cause E_ID
364  puts( "Init - ref_tsk - reference SELF - E_ID" );
365  status = ref_tsk( &pk_rtsk, TSK_SELF );
366  assert( status == E_ID );
367  */
368
369  puts( "Init - ref_tsk - task does not exist - E_NOEXS" );
370  status = ref_tsk( &pk_rtsk, 5 );
371  assert( status == E_NOEXS );
372
373  puts( "Init - ref_tsk - access violation ( id less than -4) - E_OACV" );
374  status =  ref_tsk( &pk_rtsk, -5 );
375  assert( status == E_OACV );
376
377  puts( "Init - ref_tsk - packet address is bad - E_PAR" );
378  status =  ref_tsk( NULL, 1 );
379  assert( status == E_PAR );
380
381
382#if (0)
383  /*  these errors can not be generated for ref_tsk at this time */
384  assert( status == EN_OBJNO );
385  assert( status == EN_CTXID );
386  assert( status == EN_RPAR );
387#endif
388
389
390  puts( "\n\n*** Suspend Task Errors ***" );
391
392  puts( "Init - sus_tsk - access violation ( id less than -4) - E_OACV" );
393  status = sus_tsk( -5 );
394  assert( status == E_OACV );
395
396  puts( "Init - sus_tsk - bad id (between 0 and -4) - E_ID" );
397  status = sus_tsk( -2 );
398  assert( status == E_ID );
399
400  puts( "Init - sus_tsk - cannot suspend SELF - E_OBJ" );
401  status = sus_tsk( TSK_SELF );
402  assert( status == E_OBJ );
403
404  puts( "Init - sus_tsk - task does not exist - E_NOEXS" );
405  status = sus_tsk( 5 );
406  assert( status == E_NOEXS );
407#if (0)
408  puts( "Init - sus_tsk - no support for nested SUSPENDS - E_QOVR" );
409  status = sus_tsk( 1 );
410  assert( status == E_QOVR );
411
412  puts( "Init - sus_tsk - exceeded limit for nested SUSPENDS - E_QOVR" );
413  status = sus_tsk( 1 );
414  assert( status == E_QOVR );
415#endif
416
417#if (0)
418  /* these errors can not be generated for sus_tsk at this time */
419  assert( status == EN_OBJNO );
420  assert( status == EN_CTXID );
421#endif
422
423
424  puts( "\n\n*** Resume Task Errors ***" );
425
426  puts( "Init - rsm_tsk - access violation ( id less than -4) - E_OACV" );
427  status = rsm_tsk( -5 );
428  assert( status == E_OACV );
429
430  puts( "Init - rsm_tsk - bad id (between 0 and -4) - E_ID" );
431  status = rsm_tsk( -2 );
432  assert( status == E_ID );
433
434  puts( "Init - rsm_tsk - cannot resume SELF - E_OBJ" );
435  status = rsm_tsk( TSK_SELF );
436  assert( status == E_OBJ );
437
438  puts( "Init - rsm_tsk - task is DORMANT - E_OBJ" );
439  status = rsm_tsk( PREEMPT_TASK_ID );
440  assert( status == E_OBJ );
441
442  puts( "Init - rsm_tsk - task does not exist - E_NOEXS" );
443  status = rsm_tsk( 5 );
444  assert( status == E_NOEXS );
445
446#if (0)
447  /* these errors can not be generated for rsm_tsk at this time */
448  assert( status == EN_OBJNO );
449  assert( status == EN_CTXID );
450#endif
451
452
453  puts( "\n\n*** Forcibly Resume Task Errors ***" );
454
455  puts( "Init - frsm_tsk - access violation ( id less than -4) - E_OACV" );
456  status = frsm_tsk( -5 );
457  assert( status == E_OACV );
458
459  puts( "Init - frsm_tsk - bad id (between 0 and -4) - E_ID" );
460  status = frsm_tsk( -2 );
461  assert( status == E_ID );
462
463  puts( "Init - frsm_tsk - cannot forcibly resume SELF - E_OBJ" );
464  status = frsm_tsk( TSK_SELF );
465  assert( status == E_OBJ );
466
467  puts( "Init - frsm_tsk - task is DORMANT - E_OBJ" );
468  status = frsm_tsk( PREEMPT_TASK_ID );
469  assert( status == E_OBJ );
470
471  puts( "Init - frsm_tsk - task does not exist - E_NOEXS" );
472  status = frsm_tsk( 5 );
473  assert( status == E_NOEXS );
474
475#if (0)
476  /* these errors can not be generated for frsm_tsk at this time */
477  assert( status == EN_OBJNO );
478  assert( status == EN_CTXID );
479#endif
480
481
482#if (0)
483  /* these directives are not coded */
484  slp_tsk( );
485  assert( status == E_OK );
486  assert( status == E_PAR );
487  assert( status == E_RLWAI );
488  assert( status == E_TMOUT );
489  assert( status == E_CTX );
490
491
492  tslp_tsk( TMO );
493  assert( status == E_OK );
494  assert( status == E_PAR );
495  assert( status == E_RLWAI );
496  assert( status == E_TMOUT );
497  assert( status == E_CTX );
498
499
500  wup_tsk( ID );
501  assert( status == E_OK );
502  assert( status == E_ID );
503  assert( status == E_NOEXS );
504  assert( status == E_OACV );
505  assert( status == E_OBJ );
506  assert( status == E_QOVR );
507  assert( status == EN_OBJNO );
508  assert( status == EN_CTXID );
509
510
511  can_tsk( INT, ID );
512  assert( status == E_OK );
513  assert( status == E_ID );
514  assert( status == E_NOEXS );
515  assert( status == E_OACV );
516  assert( status == E_OBJ );
517  assert( status == EN_OBJNO );
518  assert( status == EN_CTXID );
519  assert( status == EN_RPAR );
520#endif
521
522  puts( "*** ITRON TASK TEST 2 ***" );
523  exit( 0 );
524}
Note: See TracBrowser for help on using the repository browser.