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

4.104.114.84.95
Last change on this file since ec0b5ce was ec0b5ce, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 12, 1999 at 2:50:42 PM

Test name changed to reflect placement after merger.

Changed output to reflect what was actually being tested.

  • Property mode set to 100644
File size: 14.0 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 - invalid priority - E_PAR" );
335   status = rot_rdq( -1 );
336   assert( status == E_PAR );
337
338#if (0)
339  /* This routine is not coded */
340  rel_wai( ID );
341  assert( status == E_OK );
342  assert( status == E_ID );
343  assert( status == E_NOEXS );
344  assert( status == E_OACV );
345  assert( status == E_OBJ );
346  assert( status == EN_OBJNO );
347  assert( status == EN_CTXID );
348#endif
349
350
351#if (0)
352  get_tid( ID );
353  assert( status == E_OK );
354#endif
355
356  puts( "\n\n*** Reference Task Status Errors ***" );
357  puts( "Init - ref_tsk - bad id (between 0 and -4) - E_ID" );
358  status = ref_tsk( &pk_rtsk, -2 );
359  assert( status == E_ID );
360
361  /*  Call from task independent portion to cause E_ID
362  puts( "Init - ref_tsk - reference SELF - E_ID" );
363  status = ref_tsk( &pk_rtsk, 0 );
364  assert( status == E_ID );
365  */
366
367  puts( "Init - ref_tsk - task does not exist - E_NOEXS" );
368  status = ref_tsk( &pk_rtsk, 5 );
369  assert( status == E_NOEXS );
370
371  puts( "Init - ref_tsk - access violation ( id less than -4) - E_OACV" );
372  status =  ref_tsk( &pk_rtsk, -5 );
373  assert( status == E_OACV );
374
375  puts( "Init - ref_tsk - packet address is bad - E_PAR" );
376  status =  ref_tsk( NULL, 1 );
377  assert( status == E_PAR );
378
379
380#if (0)
381  /*  these errors can not be generated for ref_tsk at this time */
382  assert( status == EN_OBJNO );
383  assert( status == EN_CTXID );
384  assert( status == EN_RPAR );
385#endif
386
387
388  puts( "\n\n*** Suspend Task Errors ***" );
389
390  puts( "Init - sus_tsk - access violation ( id less than -4) - E_OACV" );
391  status = sus_tsk( -5 );
392  assert( status == E_OACV );
393
394  puts( "Init - sus_tsk - bad id (between 0 and -4) - E_ID" );
395  status = sus_tsk( -2 );
396  assert( status == E_ID );
397
398  puts( "Init - sus_tsk - cannot suspend SELF - E_OBJ" );
399  status = sus_tsk( 0 );
400  assert( status == E_OBJ );
401
402  puts( "Init - sus_tsk - task does not exist - E_NOEXS" );
403  status = sus_tsk( 5 );
404  assert( status == E_NOEXS );
405#if (0)
406  puts( "Init - sus_tsk - no support for nested SUSPENDS - E_QOVR" );
407  status = sus_tsk( 1 );
408  assert( status == E_QOVR );
409
410  puts( "Init - sus_tsk - exceeded limit for nested SUSPENDS - E_QOVR" );
411  status = sus_tsk( 1 );
412  assert( status == E_QOVR );
413#endif
414
415#if (0)
416  /* these errors can not be generated for sus_tsk at this time */
417  assert( status == EN_OBJNO );
418  assert( status == EN_CTXID );
419#endif
420
421
422  puts( "\n\n*** Resume Task Errors ***" );
423
424  puts( "Init - rsm_tsk - access violation ( id less than -4) - E_OACV" );
425  status = rsm_tsk( -5 );
426  assert( status == E_OACV );
427
428  puts( "Init - rsm_tsk - bad id (between 0 and -4) - E_ID" );
429  status = rsm_tsk( -2 );
430  assert( status == E_ID );
431
432  puts( "Init - rsm_tsk - cannot resume SELF - E_OBJ" );
433  status = rsm_tsk( 0 );
434  assert( status == E_OBJ );
435
436  puts( "Init - rsm_tsk - task is DORMANT - E_OBJ" );
437  status = rsm_tsk( 1 );
438  assert( status == E_OBJ );
439
440  puts( "Init - rsm_tsk - task does not exist - E_NOEXS" );
441  status = rsm_tsk( 5 );
442  assert( status == E_NOEXS );
443
444#if (0)
445  /* these errors can not be generated for rsm_tsk at this time */
446  assert( status == EN_OBJNO );
447  assert( status == EN_CTXID );
448#endif
449
450
451  puts( "\n\n*** Forcibly Resume Task Errors ***" );
452
453  puts( "Init - frsm_tsk - access violation ( id less than -4) - E_OACV" );
454  status = frsm_tsk( -5 );
455  assert( status == E_OACV );
456
457  puts( "Init - frsm_tsk - bad id (between 0 and -4) - E_ID" );
458  status = frsm_tsk( -2 );
459  assert( status == E_ID );
460
461  puts( "Init - frsm_tsk - cannot forcibly resume SELF - E_OBJ" );
462  status = frsm_tsk( 0 );
463  assert( status == E_OBJ );
464
465  puts( "Init - frsm_tsk - task is DORMANT - E_OBJ" );
466  status = frsm_tsk( 1 );
467  assert( status == E_OBJ );
468
469  puts( "Init - frsm_tsk - task does not exist - E_NOEXS" );
470  status = frsm_tsk( 5 );
471  assert( status == E_NOEXS );
472
473#if (0)
474  /* these errors can not be generated for frsm_tsk at this time */
475  assert( status == EN_OBJNO );
476  assert( status == EN_CTXID );
477#endif
478
479
480#if (0)
481  /* these directives are not coded */
482  slp_tsk( );
483  assert( status == E_OK );
484  assert( status == E_PAR );
485  assert( status == E_RLWAI );
486  assert( status == E_TMOUT );
487  assert( status == E_CTX );
488
489
490  tslp_tsk( TMO );
491  assert( status == E_OK );
492  assert( status == E_PAR );
493  assert( status == E_RLWAI );
494  assert( status == E_TMOUT );
495  assert( status == E_CTX );
496
497
498  wup_tsk( ID );
499  assert( status == E_OK );
500  assert( status == E_ID );
501  assert( status == E_NOEXS );
502  assert( status == E_OACV );
503  assert( status == E_OBJ );
504  assert( status == E_QOVR );
505  assert( status == EN_OBJNO );
506  assert( status == EN_CTXID );
507
508
509  can_tsk( INT, ID );
510  assert( status == E_OK );
511  assert( status == E_ID );
512  assert( status == E_NOEXS );
513  assert( status == E_OACV );
514  assert( status == E_OBJ );
515  assert( status == EN_OBJNO );
516  assert( status == EN_CTXID );
517  assert( status == EN_RPAR );
518#endif
519
520  puts( "*** ITRON TASK TEST 2 ***" );
521  exit( 0 );
522}
Note: See TracBrowser for help on using the repository browser.