source: rtems/testsuites/psxtests/psxfatal_support/init.c @ 190f165b

4.115
Last change on this file since 190f165b was 190f165b, checked in by Sebastian Huber <sebastian.huber@…>, on 07/07/10 at 09:11:25

2010-07-07 Sebastian Huber <Sebastian.Huber@…>

  • psxfatal_support/init.c: Print end of test message in case of success. Stop multitasking in the fatal error extension.
  • psxfatal01/psxfatal01.scn, psxfatal02/psxfatal02.scn: Update.
  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*  POSIX_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 *  COPYRIGHT (c) 1989-2009.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.com/license/LICENSE.
20 *
21 *  $Id$
22 */
23
24#define CONFIGURE_INIT
25#include "system.h"
26
27void *POSIX_Init(
28  void *argument
29)
30{
31  force_error();
32  printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION );
33  rtems_test_exit(0);
34}
35
36char *Sources[] = {
37  "INTERNAL_ERROR_CORE",
38  "INTERNAL_ERROR_RTEMS_API",
39  "INTERNAL_ERROR_POSIX_API",
40};
41
42char *Errors_Rtems[] = {
43  "RTEMS_SUCCESSFUL",               /* successful completion */
44  "RTEMS_TASK_EXITTED",             /* returned from a task */
45  "RTEMS_MP_NOT_CONFIGURED",        /* multiprocessing not configured */
46  "RTEMS_INVALID_NAME",             /* invalid object name */
47  "RTEMS_INVALID_ID",               /* invalid object id */
48  "RTEMS_TOO_MANY",                 /* too many */
49  "RTEMS_TIMEOUT",                  /* timed out waiting */
50  "RTEMS_OBJECT_WAS_DELETED",       /* object was deleted while waiting */
51  "RTEMS_INVALID_SIZE",             /* specified size was invalid */
52  "RTEMS_INVALID_ADDRESS",          /* address specified is invalid */
53  "RTEMS_INVALID_NUMBER",           /* number was invalid */
54  "RTEMS_NOT_DEFINED",              /* item has not been initialized */
55  "RTEMS_RESOURCE_IN_USE",          /* resources still outstanding */
56  "RTEMS_UNSATISFIED",              /* request not satisfied */
57  "RTEMS_INCORRECT_STATE",          /* task is in wrong state */
58  "RTEMS_ALREADY_SUSPENDED",        /* task already in state */
59  "RTEMS_ILLEGAL_ON_SELF",          /* illegal operation on calling task */
60  "RTEMS_ILLEGAL_ON_REMOTE_OBJECT", /* illegal operation for remote object */
61  "RTEMS_CALLED_FROM_ISR",          /* called from ISR */
62  "RTEMS_INVALID_PRIORITY",         /* invalid task priority */
63  "RTEMS_INVALID_CLOCK",            /* invalid date/time */
64  "RTEMS_INVALID_NODE",             /* invalid node id */
65  "RTEMS_NOT_OWNER_OF_RESOURCE",    /* not owner of resource */
66  "RTEMS_NOT_CONFIGURED",           /* directive not configured */
67  "RTEMS_NOT_IMPLEMENTED"           /* directive not implemented */
68};
69
70char *Errors_Core[] = {
71  "INTERNAL_ERROR_NO_CONFIGURATION_TABLE",
72  "INTERNAL_ERROR_NO_CPU_TABLE",
73  "INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS",
74  "INTERNAL_ERROR_TOO_LITTLE_WORKSPACE",
75  "INTERNAL_ERROR_WORKSPACE_ALLOCATION",
76  "INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL",
77  "INTERNAL_ERROR_THREAD_EXITTED",
78  "INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION",
79  "INTERNAL_ERROR_INVALID_NODE",
80  "INTERNAL_ERROR_NO_MPCI",
81  "INTERNAL_ERROR_BAD_PACKET",
82  "INTERNAL_ERROR_OUT_OF_PACKETS",
83  "INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS",
84  "INTERNAL_ERROR_OUT_OF_PROXIES",
85  "INTERNAL_ERROR_INVALID_GLOBAL_ID",
86  "INTERNAL_ERROR_BAD_STACK_HOOK",
87  "INTERNAL_ERROR_BAD_ATTRIBUTES",
88  "INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY",
89  "INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
90  "INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE"
91};
92
93void Put_Error( uint32_t source, uint32_t error )
94{
95  if ( source == INTERNAL_ERROR_CORE ) {
96    if ( error >  INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE )
97      printk("Unknown Internal Core Error (%d)", error);
98    else
99      printk( Errors_Core[ error ] );
100  }
101  else if (source == INTERNAL_ERROR_RTEMS_API ){
102    if (error >  RTEMS_NOT_IMPLEMENTED )
103      printk("Unknown Internal Rtems Error (%d)", error);
104    else
105      printk( Errors_Rtems[ error ] );
106  }
107  else if (source == INTERNAL_ERROR_POSIX_API ) {
108      printk( "SOURCE=%d ERROR=%d %s", source, error, strerror( error ) );
109  }
110}
111
112void Put_Source( uint32_t source )
113{
114  if ( source > INTERNAL_ERROR_POSIX_API )
115    printk("Unknown Source (%d)", source);
116  else
117    printk( Sources[ source ] );
118}
119
120
121void Fatal_extension(
122  uint32_t   source,
123  bool       is_internal,
124  uint32_t   error
125)
126{
127  printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION );
128
129  if ( source != FATAL_ERROR_EXPECTED_SOURCE ){
130    printk( "ERROR==> Fatal Extension source Expected (");
131    Put_Source( FATAL_ERROR_EXPECTED_SOURCE );
132    printk( ") received (");
133    Put_Source( source );
134    printk( ")\n" );
135  }
136
137  if ( is_internal !=  FATAL_ERROR_EXPECTED_IS_INTERNAL )
138  {
139    if ( is_internal == TRUE )
140      printk( "ERROR==> Fatal Extension is internal set to TRUE expected FALSE\n" );
141    else
142      printk( "ERROR==> Fatal Extension is internal set to FALSE expected TRUE\n" );
143  }
144
145  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
146    printk( "ERROR==> Fatal Error Expected (");
147    Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
148    printk( ") received (");
149    Put_Error( source, error );
150    printk( ")\n" );
151  }
152
153  if (
154    source == FATAL_ERROR_EXPECTED_SOURCE
155      && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
156      && error == FATAL_ERROR_EXPECTED_ERROR
157  ) {
158    printk( "*** END OF TEST ***\n" );
159  }
160
161  _Thread_Stop_multitasking();
162}
163
Note: See TracBrowser for help on using the repository browser.