source: rtems/testsuites/sptests/spfatal_support/init.c @ 565d8da

4.115
Last change on this file since 565d8da was 565d8da, checked in by Sebastian Huber <sebastian.huber@…>, on 01/27/13 at 12:05:13

testsuites: Use rtems_fatal_source_description()

  • Property mode set to 100644
File size: 4.0 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 *Errors_Rtems[] = {
38  "RTEMS_SUCCESSFUL",               /* successful completion */
39  "RTEMS_TASK_EXITTED",             /* returned from a task */
40  "RTEMS_MP_NOT_CONFIGURED",        /* multiprocessing not configured */
41  "RTEMS_INVALID_NAME",             /* invalid object name */
42  "RTEMS_INVALID_ID",               /* invalid object id */
43  "RTEMS_TOO_MANY",                 /* too many */
44  "RTEMS_TIMEOUT",                  /* timed out waiting */
45  "RTEMS_OBJECT_WAS_DELETED",       /* object was deleted while waiting */
46  "RTEMS_INVALID_SIZE",             /* specified size was invalid */
47  "RTEMS_INVALID_ADDRESS",          /* address specified is invalid */
48  "RTEMS_INVALID_NUMBER",           /* number was invalid */
49  "RTEMS_NOT_DEFINED",              /* item has not been initialized */
50  "RTEMS_RESOURCE_IN_USE",          /* resources still outstanding */
51  "RTEMS_UNSATISFIED",              /* request not satisfied */
52  "RTEMS_INCORRECT_STATE",          /* task is in wrong state */
53  "RTEMS_ALREADY_SUSPENDED",        /* task already in state */
54  "RTEMS_ILLEGAL_ON_SELF",          /* illegal operation on calling task */
55  "RTEMS_ILLEGAL_ON_REMOTE_OBJECT", /* illegal operation for remote object */
56  "RTEMS_CALLED_FROM_ISR",          /* called from ISR */
57  "RTEMS_INVALID_PRIORITY",         /* invalid task priority */
58  "RTEMS_INVALID_CLOCK",            /* invalid date/time */
59  "RTEMS_INVALID_NODE",             /* invalid node id */
60  "RTEMS_NOT_OWNER_OF_RESOURCE",    /* not owner of resource */
61  "RTEMS_NOT_CONFIGURED",           /* directive not configured */
62  "RTEMS_NOT_IMPLEMENTED"           /* directive not implemented */
63};
64
65void Put_Error( uint32_t source, uint32_t error )
66{
67  if ( source == INTERNAL_ERROR_CORE ) {
68    printk( rtems_internal_error_description( error ) );
69  }
70  else if (source == INTERNAL_ERROR_RTEMS_API ){
71    if (error >  RTEMS_NOT_IMPLEMENTED )
72      printk("Unknown Internal Rtems Error (0x%08x)", error);
73    else
74      printk( Errors_Rtems[ error ] );
75  }
76}
77
78void Put_Source( rtems_fatal_source source )
79{
80  printk( "%s", rtems_fatal_source_description( source ) );
81}
82
83
84void Fatal_extension(
85  uint32_t   source,
86  bool       is_internal,
87  uint32_t   error
88)
89{
90  print_test_begin_message();
91  printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION );
92
93  if ( source != FATAL_ERROR_EXPECTED_SOURCE ){
94    printk( "ERROR==> Fatal Extension source Expected (");
95    Put_Source( FATAL_ERROR_EXPECTED_SOURCE );
96    printk( ") received (");
97    Put_Source( source );
98    printk( ")\n" );
99  }
100
101  if ( is_internal !=  FATAL_ERROR_EXPECTED_IS_INTERNAL )
102  {
103    if ( is_internal == TRUE )
104      printk(
105        "ERROR==> Fatal Extension is internal set to TRUE expected FALSE\n"
106      );
107    else
108      printk(
109        "ERROR==> Fatal Extension is internal set to FALSE expected TRUE\n"
110      );
111  }
112
113  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
114    printk( "ERROR==> Fatal Error Expected (");
115    Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
116    printk( ") received (");
117    Put_Error( source, error );
118    printk( ")\n" );
119  }
120
121  if (
122    source == FATAL_ERROR_EXPECTED_SOURCE
123      && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
124      && error == FATAL_ERROR_EXPECTED_ERROR
125  ) {
126    printk( "*** END OF TEST FATAL " FATAL_ERROR_TEST_NAME " ***\n" );
127  }
128}
129
Note: See TracBrowser for help on using the repository browser.