1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
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 TESTS_USE_PRINTK |
---|
15 | #include "tmacros.h" |
---|
16 | |
---|
17 | #define CONFIGURE_INIT |
---|
18 | #include "system.h" |
---|
19 | |
---|
20 | const char rtems_test_name[] = "PSXFATAL " FATAL_ERROR_TEST_NAME; |
---|
21 | |
---|
22 | static void print_test_begin_message(void) |
---|
23 | { |
---|
24 | static bool done = false; |
---|
25 | |
---|
26 | if (!done) { |
---|
27 | done = true; |
---|
28 | TEST_BEGIN(); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | void *POSIX_Init( |
---|
33 | void *argument |
---|
34 | ) |
---|
35 | { |
---|
36 | print_test_begin_message(); |
---|
37 | force_error(); |
---|
38 | printk( "Fatal error (%s) NOT hit\n", FATAL_ERROR_DESCRIPTION ); |
---|
39 | rtems_test_exit(0); |
---|
40 | } |
---|
41 | |
---|
42 | void Put_Error( uint32_t source, uint32_t error ) |
---|
43 | { |
---|
44 | if ( source == INTERNAL_ERROR_CORE ) { |
---|
45 | printk( rtems_internal_error_text( error ) ); |
---|
46 | } |
---|
47 | else if (source == INTERNAL_ERROR_RTEMS_API ){ |
---|
48 | if (error > RTEMS_NOT_IMPLEMENTED ) |
---|
49 | printk("Unknown Internal Rtems Error (%d)", error); |
---|
50 | else |
---|
51 | printk( "%s", rtems_status_text( error ) ); |
---|
52 | } |
---|
53 | else if (source == INTERNAL_ERROR_POSIX_API ) { |
---|
54 | printk( "SOURCE=%d ERROR=%d %s", source, error, strerror( error ) ); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | void Put_Source( rtems_fatal_source source ) |
---|
59 | { |
---|
60 | printk( "%s", rtems_fatal_source_text( source ) ); |
---|
61 | } |
---|
62 | |
---|
63 | void Fatal_extension( |
---|
64 | rtems_fatal_source source, |
---|
65 | bool always_set_to_false, |
---|
66 | rtems_fatal_code error |
---|
67 | ) |
---|
68 | { |
---|
69 | print_test_begin_message(); |
---|
70 | printk( "Fatal error (%s) hit\n", FATAL_ERROR_DESCRIPTION ); |
---|
71 | |
---|
72 | if ( source != FATAL_ERROR_EXPECTED_SOURCE ){ |
---|
73 | printk( "ERROR==> Fatal Extension source Expected ("); |
---|
74 | Put_Source( FATAL_ERROR_EXPECTED_SOURCE ); |
---|
75 | printk( ") received ("); |
---|
76 | Put_Source( source ); |
---|
77 | printk( ")\n" ); |
---|
78 | } |
---|
79 | |
---|
80 | if ( always_set_to_false ) |
---|
81 | printk( "ERROR==> Fatal Extension is internal set to true expected false\n" ); |
---|
82 | |
---|
83 | if ( error != FATAL_ERROR_EXPECTED_ERROR ) { |
---|
84 | printk( "ERROR==> Fatal Error Expected ("); |
---|
85 | Put_Error( source, FATAL_ERROR_EXPECTED_ERROR ); |
---|
86 | printk( ") received ("); |
---|
87 | Put_Error( source, error ); |
---|
88 | printk( ")\n" ); |
---|
89 | } |
---|
90 | |
---|
91 | if ( |
---|
92 | source == FATAL_ERROR_EXPECTED_SOURCE |
---|
93 | && !always_set_to_false |
---|
94 | && error == FATAL_ERROR_EXPECTED_ERROR |
---|
95 | ) { |
---|
96 | TEST_END(); |
---|
97 | } |
---|
98 | } |
---|