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

5
Last change on this file since b6606e8 was b6606e8, checked in by Sebastian Huber <sebastian.huber@…>, on 12/08/16 at 15:41:30

score: Remove fatal is internal indicator

The fatal is internal indicator is redundant since the fatal source and
error code uniquely identify a fatal error. Keep the fatal user
extension is internal parameter for backward compatibility and set it to
false always.

Update #2825.

  • Property mode set to 100644
File size: 2.4 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.org/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
17const char rtems_test_name[] = "SPFATAL " FATAL_ERROR_TEST_NAME;
18
19static void print_test_begin_message(void)
20{
21  static bool done = false;
22
23  if (!done) {
24    done = true;
25    TEST_BEGIN();
26  }
27}
28
29rtems_task Init(
30  rtems_task_argument argument
31)
32{
33  print_test_begin_message();
34  force_error();
35  printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION );
36  rtems_test_exit(0);
37}
38
39void Put_Error( uint32_t source, uint32_t error )
40{
41  if ( source == INTERNAL_ERROR_CORE ) {
42    printk( rtems_internal_error_text( error ) );
43  }
44  else if (source == INTERNAL_ERROR_RTEMS_API ){
45    if (error >  RTEMS_NOT_IMPLEMENTED )
46      printk("Unknown Internal Rtems Error (0x%08" PRIx32 ")", error);
47    else
48      printk( "%s", rtems_status_text( error ) );
49  }
50}
51
52void Put_Source( rtems_fatal_source source )
53{
54  printk( "%s", rtems_fatal_source_text( source ) );
55}
56
57static bool is_expected_error( rtems_fatal_code error )
58{
59#ifdef FATAL_ERROR_EXPECTED_ERROR
60  return error == FATAL_ERROR_EXPECTED_ERROR;
61#else /* FATAL_ERROR_EXPECTED_ERROR */
62  return FATAL_ERROR_EXPECTED_ERROR_CHECK( error );
63#endif /* FATAL_ERROR_EXPECTED_ERROR */
64}
65
66void Fatal_extension(
67  rtems_fatal_source source,
68  bool               is_internal,
69  rtems_fatal_code   error
70)
71{
72  print_test_begin_message();
73  printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION );
74
75  if ( source != FATAL_ERROR_EXPECTED_SOURCE ){
76    printk( "ERROR==> Fatal Extension source Expected (");
77    Put_Source( FATAL_ERROR_EXPECTED_SOURCE );
78    printk( ") received (");
79    Put_Source( source );
80    printk( ")\n" );
81  }
82
83  if ( is_internal )
84    printk(
85      "ERROR==> Fatal Extension is internal set to true expected false\n"
86    );
87
88#ifdef FATAL_ERROR_EXPECTED_ERROR
89  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
90    printk( "ERROR==> Fatal Error Expected (");
91    Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
92    printk( ") received (");
93    Put_Error( source, error );
94    printk( ")\n" );
95  }
96#endif /* FATAL_ERROR_EXPECTED_ERROR */
97
98  if (
99    source == FATAL_ERROR_EXPECTED_SOURCE
100      && !is_internal
101      && is_expected_error( error )
102  ) {
103    TEST_END();
104  }
105}
Note: See TracBrowser for help on using the repository browser.