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

4.115
Last change on this file since ecd8c8ad was ecd8c8ad, checked in by Sebastian Huber <sebastian.huber@…>, on 03/28/14 at 10:58:20

tests/fatal: Fix test names

  • Property mode set to 100644
File size: 2.7 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    rtems_test_begink();
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%08x)", 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 !=  FATAL_ERROR_EXPECTED_IS_INTERNAL )
84  {
85    if ( is_internal == TRUE )
86      printk(
87        "ERROR==> Fatal Extension is internal set to TRUE expected FALSE\n"
88      );
89    else
90      printk(
91        "ERROR==> Fatal Extension is internal set to FALSE expected TRUE\n"
92      );
93  }
94
95#ifdef FATAL_ERROR_EXPECTED_ERROR
96  if ( error !=  FATAL_ERROR_EXPECTED_ERROR ) {
97    printk( "ERROR==> Fatal Error Expected (");
98    Put_Error( source, FATAL_ERROR_EXPECTED_ERROR );
99    printk( ") received (");
100    Put_Error( source, error );
101    printk( ")\n" );
102  }
103#endif /* FATAL_ERROR_EXPECTED_ERROR */
104
105  if (
106    source == FATAL_ERROR_EXPECTED_SOURCE
107      && is_internal == FATAL_ERROR_EXPECTED_IS_INTERNAL
108      && is_expected_error( error )
109  ) {
110    rtems_test_endk();
111  }
112}
113
Note: See TracBrowser for help on using the repository browser.