source: rtems/testsuites/sptests/spfatal_support/init.c @ dc6e830

4.115
Last change on this file since dc6e830 was dc6e830, checked in by Sebastian Huber <sebastian.huber@…>, on 11/13/12 at 16:40:33

sapi: Add and use rtems_internal_error_description

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17static void print_test_begin_message(void)
18{
19  static bool done = false;
20
21  if (!done) {
22    done = true;
23    printk( "\n\n\n*** TEST FATAL " FATAL_ERROR_TEST_NAME " ***\n" );
24  }
25}
26
27rtems_task Init(
28  rtems_task_argument argument
29)
30{
31  print_test_begin_message();
32  force_error();
33  printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION );
34  rtems_test_exit(0);
35}
36
37char *Sources[] = {
38  "INTERNAL_ERROR_CORE",
39  "INTERNAL_ERROR_RTEMS_API",
40  "INTERNAL_ERROR_POSIX_API",
41};
42
43
44char *Errors_Rtems[] = {
45  "RTEMS_SUCCESSFUL",               /* successful completion */
46  "RTEMS_TASK_EXITTED",             /* returned from a task */
47  "RTEMS_MP_NOT_CONFIGURED",        /* multiprocessing not configured */
48  "RTEMS_INVALID_NAME",             /* invalid object name */
49  "RTEMS_INVALID_ID",               /* invalid object id */
50  "RTEMS_TOO_MANY",                 /* too many */
51  "RTEMS_TIMEOUT",                  /* timed out waiting */
52  "RTEMS_OBJECT_WAS_DELETED",       /* object was deleted while waiting */
53  "RTEMS_INVALID_SIZE",             /* specified size was invalid */
54  "RTEMS_INVALID_ADDRESS",          /* address specified is invalid */
55  "RTEMS_INVALID_NUMBER",           /* number was invalid */
56  "RTEMS_NOT_DEFINED",              /* item has not been initialized */
57  "RTEMS_RESOURCE_IN_USE",          /* resources still outstanding */
58  "RTEMS_UNSATISFIED",              /* request not satisfied */
59  "RTEMS_INCORRECT_STATE",          /* task is in wrong state */
60  "RTEMS_ALREADY_SUSPENDED",        /* task already in state */
61  "RTEMS_ILLEGAL_ON_SELF",          /* illegal operation on calling task */
62  "RTEMS_ILLEGAL_ON_REMOTE_OBJECT", /* illegal operation for remote object */
63  "RTEMS_CALLED_FROM_ISR",          /* called from ISR */
64  "RTEMS_INVALID_PRIORITY",         /* invalid task priority */
65  "RTEMS_INVALID_CLOCK",            /* invalid date/time */
66  "RTEMS_INVALID_NODE",             /* invalid node id */
67  "RTEMS_NOT_OWNER_OF_RESOURCE",    /* not owner of resource */
68  "RTEMS_NOT_CONFIGURED",           /* directive not configured */
69  "RTEMS_NOT_IMPLEMENTED"           /* directive not implemented */
70};
71
72void Put_Error( uint32_t source, uint32_t error )
73{
74  if ( source == INTERNAL_ERROR_CORE ) {
75    printk( rtems_internal_error_description( error ) );
76  }
77  else if (source == INTERNAL_ERROR_RTEMS_API ){
78    if (error >  RTEMS_NOT_IMPLEMENTED )
79      printk("Unknown Internal Rtems Error (0x%08x)", error);
80    else
81      printk( Errors_Rtems[ error ] );
82  }
83}
84
85void Put_Source( uint32_t source )
86{
87  if ( source > INTERNAL_ERROR_POSIX_API )
88    printk("Unknown Source (%d)", source);
89  else
90    printk( Sources[ source ] );
91}
92
93
94void Fatal_extension(
95  uint32_t   source,
96  bool       is_internal,
97  uint32_t   error
98)
99{
100  print_test_begin_message();
101  printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION );
102
103  if ( source != FATAL_ERROR_EXPECTED_SOURCE ){
104    printk( "ERROR==> Fatal Extension source Expected (");
105    Put_Source( FATAL_ERROR_EXPECTED_SOURCE );
106    printk( ") received (");
107    Put_Source( source );
108    printk( ")\n" );
109  }
110
111  if ( is_internal !=  FATAL_ERROR_EXPECTED_IS_INTERNAL )
112  {
113    if ( is_internal == TRUE )
114      printk(
115        "ERROR==> Fatal Extension is internal set to TRUE expected FALSE\n"
116      );
117    else
118      printk(
119        "ERROR==> Fatal Extension is internal set to FALSE expected TRUE\n"
120      );
121  }
122
123  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
124    printk( "ERROR==> Fatal Error Expected (");
125    Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
126    printk( ") received (");
127    Put_Error( source, error );
128    printk( ")\n" );
129  }
130
131  if (
132    source == FATAL_ERROR_EXPECTED_SOURCE
133      && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
134      && error == FATAL_ERROR_EXPECTED_ERROR
135  ) {
136    printk( "*** END OF TEST FATAL " FATAL_ERROR_TEST_NAME " ***\n" );
137  }
138
139  if ( _System_state_Is_up( _System_state_Get() ) )
140    _Thread_Stop_multitasking();
141}
142
Note: See TracBrowser for help on using the repository browser.