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