source: rtems/c/src/tests/itrontests/itrontask02/init.c @ e8c902c

4.104.114.84.95
Last change on this file since e8c902c was e8c902c, checked in by Joel Sherrill <joel.sherrill@…>, on 11/12/99 at 21:26:54

+ Added check for priority over 256.
+ Modified output to correctly state the error.

  • Property mode set to 100644
File size: 14.2 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 self (0) - E_ID" );
114  status = cre_tsk( 0, &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 self - E_OBJ" );
178  status = del_tsk( 1 );
179  assert( status == E_OBJ );
180
181  puts( "Init - del_tsk - task is not DORMANT - E_OBJ" );
182  status = del_tsk( 1 );
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 SELF - E_OBJ" );
194  status = del_tsk( 0 );
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 SELF - E_OBJ" );
219  status = sta_tsk( 0, 1 );
220  assert( status == E_OBJ );
221
222  puts( "Init - sta_tsk - task is not DORMANT  - E_OBJ" );
223  status = sta_tsk( 1, 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 SELF (0) - E_OBJ" );
259  status = ter_tsk( 0 );
260  assert( status == E_OBJ );
261
262  puts( "Init - ter_tsk - task is not DORMANT - E_OBJ" );
263  status = ter_tsk( 1 );
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 SELF - E_OBJ" );
298  status = chg_pri( 0, 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( 1, 1 );
305  assert( status == E_OBJ );
306  */
307
308  puts( "Init - chg_pri - task does not exist - E_NOEXS" );
309  status = chg_pri( 5, 1 );
310  assert( status == E_NOEXS );
311
312  puts( "Init - chg_pri - access violation ( id less than -4) - E_OACV" );
313  status =  chg_pri( -5, 1 );
314  assert( status == E_OACV );
315
316  puts( "Init - chg_pri - invalid priority - E_PAR" );
317  status =  chg_pri( 1, -1 );
318  assert( status == E_PAR );
319
320#if (0)
321  /* these errors can not be generated for chg_pri at this time */
322  assert( status == EN_OBJNO );
323  assert( status == EN_CTXID );
324  assert( status == EN_PAR );
325#endif
326
327  /*  This gave me a nasty-gram
328   *  "core_find_mapping() - access to unmaped address, attach a default map
329   *   to handle this - addr=0x80002098 nr_bytes=0x4 processor=0x40134008
330   *   cia=0xc744"
331   */
332 
333   puts( "\n\n*** Rotate Ready Queue Errors ***" );
334   puts( "Init - rot_rdq - priority  -1 - E_PAR" );
335   status = rot_rdq( -1 );
336   assert( status == E_PAR );
337   puts( "Init - rot_rdq - priority  257 - E_PAR" );
338   status = rot_rdq( 257 );
339   assert( status == E_PAR );
340
341#if (0)
342  /* This routine is not coded */
343  rel_wai( ID );
344  assert( status == E_OK );
345  assert( status == E_ID );
346  assert( status == E_NOEXS );
347  assert( status == E_OACV );
348  assert( status == E_OBJ );
349  assert( status == EN_OBJNO );
350  assert( status == EN_CTXID );
351#endif
352
353
354#if (0)
355  get_tid( ID );
356  assert( status == E_OK );
357#endif
358
359  puts( "\n\n*** Reference Task Status Errors ***" );
360  puts( "Init - ref_tsk - bad id (between 0 and -4) - E_ID" );
361  status = ref_tsk( &pk_rtsk, -2 );
362  assert( status == E_ID );
363
364  /*  Call from task independent portion to cause E_ID
365  puts( "Init - ref_tsk - reference SELF - E_ID" );
366  status = ref_tsk( &pk_rtsk, 0 );
367  assert( status == E_ID );
368  */
369
370  puts( "Init - ref_tsk - task does not exist - E_NOEXS" );
371  status = ref_tsk( &pk_rtsk, 5 );
372  assert( status == E_NOEXS );
373
374  puts( "Init - ref_tsk - access violation ( id less than -4) - E_OACV" );
375  status =  ref_tsk( &pk_rtsk, -5 );
376  assert( status == E_OACV );
377
378  puts( "Init - ref_tsk - packet address is bad - E_PAR" );
379  status =  ref_tsk( NULL, 1 );
380  assert( status == E_PAR );
381
382
383#if (0)
384  /*  these errors can not be generated for ref_tsk at this time */
385  assert( status == EN_OBJNO );
386  assert( status == EN_CTXID );
387  assert( status == EN_RPAR );
388#endif
389
390
391  puts( "\n\n*** Suspend Task Errors ***" );
392
393  puts( "Init - sus_tsk - access violation ( id less than -4) - E_OACV" );
394  status = sus_tsk( -5 );
395  assert( status == E_OACV );
396
397  puts( "Init - sus_tsk - bad id (between 0 and -4) - E_ID" );
398  status = sus_tsk( -2 );
399  assert( status == E_ID );
400
401  puts( "Init - sus_tsk - cannot suspend SELF - E_OBJ" );
402  status = sus_tsk( 0 );
403  assert( status == E_OBJ );
404
405  puts( "Init - sus_tsk - task does not exist - E_NOEXS" );
406  status = sus_tsk( 5 );
407  assert( status == E_NOEXS );
408#if (0)
409  puts( "Init - sus_tsk - no support for nested SUSPENDS - E_QOVR" );
410  status = sus_tsk( 1 );
411  assert( status == E_QOVR );
412
413  puts( "Init - sus_tsk - exceeded limit for nested SUSPENDS - E_QOVR" );
414  status = sus_tsk( 1 );
415  assert( status == E_QOVR );
416#endif
417
418#if (0)
419  /* these errors can not be generated for sus_tsk at this time */
420  assert( status == EN_OBJNO );
421  assert( status == EN_CTXID );
422#endif
423
424
425  puts( "\n\n*** Resume Task Errors ***" );
426
427  puts( "Init - rsm_tsk - access violation ( id less than -4) - E_OACV" );
428  status = rsm_tsk( -5 );
429  assert( status == E_OACV );
430
431  puts( "Init - rsm_tsk - bad id (between 0 and -4) - E_ID" );
432  status = rsm_tsk( -2 );
433  assert( status == E_ID );
434
435  puts( "Init - rsm_tsk - cannot resume SELF - E_OBJ" );
436  status = rsm_tsk( 0 );
437  assert( status == E_OBJ );
438
439  puts( "Init - rsm_tsk - task is DORMANT - E_OBJ" );
440  status = rsm_tsk( 1 );
441  assert( status == E_OBJ );
442
443  puts( "Init - rsm_tsk - task does not exist - E_NOEXS" );
444  status = rsm_tsk( 5 );
445  assert( status == E_NOEXS );
446
447#if (0)
448  /* these errors can not be generated for rsm_tsk at this time */
449  assert( status == EN_OBJNO );
450  assert( status == EN_CTXID );
451#endif
452
453
454  puts( "\n\n*** Forcibly Resume Task Errors ***" );
455
456  puts( "Init - frsm_tsk - access violation ( id less than -4) - E_OACV" );
457  status = frsm_tsk( -5 );
458  assert( status == E_OACV );
459
460  puts( "Init - frsm_tsk - bad id (between 0 and -4) - E_ID" );
461  status = frsm_tsk( -2 );
462  assert( status == E_ID );
463
464  puts( "Init - frsm_tsk - cannot forcibly resume SELF - E_OBJ" );
465  status = frsm_tsk( 0 );
466  assert( status == E_OBJ );
467
468  puts( "Init - frsm_tsk - task is DORMANT - E_OBJ" );
469  status = frsm_tsk( 1 );
470  assert( status == E_OBJ );
471
472  puts( "Init - frsm_tsk - task does not exist - E_NOEXS" );
473  status = frsm_tsk( 5 );
474  assert( status == E_NOEXS );
475
476#if (0)
477  /* these errors can not be generated for frsm_tsk at this time */
478  assert( status == EN_OBJNO );
479  assert( status == EN_CTXID );
480#endif
481
482
483#if (0)
484  /* these directives are not coded */
485  slp_tsk( );
486  assert( status == E_OK );
487  assert( status == E_PAR );
488  assert( status == E_RLWAI );
489  assert( status == E_TMOUT );
490  assert( status == E_CTX );
491
492
493  tslp_tsk( TMO );
494  assert( status == E_OK );
495  assert( status == E_PAR );
496  assert( status == E_RLWAI );
497  assert( status == E_TMOUT );
498  assert( status == E_CTX );
499
500
501  wup_tsk( ID );
502  assert( status == E_OK );
503  assert( status == E_ID );
504  assert( status == E_NOEXS );
505  assert( status == E_OACV );
506  assert( status == E_OBJ );
507  assert( status == E_QOVR );
508  assert( status == EN_OBJNO );
509  assert( status == EN_CTXID );
510
511
512  can_tsk( INT, ID );
513  assert( status == E_OK );
514  assert( status == E_ID );
515  assert( status == E_NOEXS );
516  assert( status == E_OACV );
517  assert( status == E_OBJ );
518  assert( status == EN_OBJNO );
519  assert( status == EN_CTXID );
520  assert( status == EN_RPAR );
521#endif
522
523  puts( "*** ITRON TASK TEST 2 ***" );
524  exit( 0 );
525}
Note: See TracBrowser for help on using the repository browser.