1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021, 2023 embedded brains GmbH & Co. KG
enabled-by: true
functional-type: action
links:
- role: interface-function
uid: ../if/interrupt-handler-dispatch-unchecked
post-conditions:
- name: Result
states:
- name: FatalError
test-code: |
T_eq_u32( ctx->entry_counter, 0 );
T_eq_u32( ctx->fatal_counter, 1 );
text: |
A fatal error shall occur.
- name: Dispatch
test-code: |
T_eq_u32( ctx->entry_counter, 1 );
T_eq_u32( ctx->fatal_counter, 0 );
text: |
The interrupt entries installed at the interrupt vector specified by the
``vector`` parameter shall be dispatched.
test-epilogue: null
test-prologue: null
- name: FatalSource
states:
- name: SpuriousInterrupt
test-code: |
T_eq_int( ctx->fatal_source, RTEMS_FATAL_SOURCE_SPURIOUS_INTERRUPT );
text: |
The fatal source shall be equal to
${/score/interr/if/source-spurious-interrupt:/name}.
test-epilogue: null
test-prologue: null
- name: FatalCode
states:
- name: Vector
test-code: |
T_eq_ulong( ctx->fatal_code, ctx->test_vector );
text: |
The fatal code shall be equal to the ``vector`` parameter.
test-epilogue: null
test-prologue: null
pre-conditions:
- name: LoadFirst
states:
- name: 'Null'
test-code: |
*ctx->first = NULL;
text: |
While the first loaded value of the pointer to the first interrupt entry
of the interrupt vector specified by the ``vector`` parameter is equal to
${/c/if/null:/name}.
- name: Entry
test-code: |
*ctx->first = &ctx->entry;
text: |
While the first loaded value of the pointer to the first interrupt entry
of the interrupt vector specified by the ``vector`` parameter references
an object of type ${/rtems/intr/if/entry:/name}.
test-epilogue: null
test-prologue: null
- name: LoadFirstAgain
states:
- name: 'Null'
test-code: |
ctx->first_again = NULL;
text: |
While the second loaded value of the pointer to the first interrupt entry
of the interrupt vector specified by the ``vector`` parameter is equal to
${/c/if/null:/name}.
- name: Entry
test-code: |
ctx->first_again = &ctx->entry;
text: |
While the second loaded value of the pointer to the first interrupt entry
of the interrupt vector specified by the ``vector`` parameter references
an object of type ${/rtems/intr/if/entry:/name}.
test-epilogue: null
test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
ctx->interrupt_occurred = false;
ctx->entry_counter = 0;
ctx->fatal_counter = 0;
ctx->fatal_source = RTEMS_FATAL_SOURCE_LAST;
ctx->fatal_code = UINT32_MAX;
(void) rtems_interrupt_vector_enable( ctx->test_vector );
CallWithinISRRaise();
while ( !ctx->interrupt_occurred ) {
/* Wait */
}
Disable( ctx );
test-brief: null
test-cleanup: null
test-context:
- brief: |
This member references the interrupt entry to restore during test case
teardown.
description: null
member: |
rtems_interrupt_entry *entry_to_restore
- brief: |
This member provides a jump buffer to return from the fatal error.
description: null
member: |
jmp_buf before_call
- brief: |
This member provides an interrupt entry to be dispatched.
description: null
member: |
rtems_interrupt_entry entry
- brief: |
This member is true, then an interrupt occurred.
description: null
member: |
volatile bool interrupt_occurred
- brief: |
This member provides an entry dispatch counter.
description: null
member: |
uint32_t entry_counter
- brief: |
This member provides a fatal error counter.
description: null
member: |
uint32_t fatal_counter
- brief: |
This member contains the fatal source.
description: null
member: |
rtems_fatal_source fatal_source
- brief: |
This member contains a fatal code.
description: null
member: |
rtems_fatal_code fatal_code
- brief: |
This member contains the vector number of a testable interrupt.
description: null
member: |
rtems_vector_number test_vector
- brief: |
This member references the pointer to the first entry of the interrupt
vector.
description: null
member: |
rtems_interrupt_entry **first
- brief: |
This member references an interrupt entry for the first entry of the
interrupt vector or is NULL.
description: null
member: |
rtems_interrupt_entry *first_again
test-context-support: null
test-description: null
test-header: null
test-includes:
- bsp/irq-generic.h
- setjmp.h
test-local-includes:
- tx-support.h
test-prepare: null
test-setup:
brief: null
code: |
ctx->first = NULL;
ctx->test_vector = CallWithinISRGetVector();
T_assert_lt_u32( ctx->test_vector, BSP_INTERRUPT_VECTOR_COUNT );
ctx->first = &bsp_interrupt_dispatch_table[
bsp_interrupt_dispatch_index( ctx->test_vector )
];
ctx->entry_to_restore = *ctx->first;
rtems_interrupt_entry_initialize( &ctx->entry, EntryRoutine, ctx, "Info" );
test_case_active = true;
SetFatalHandler( Fatal, ctx );
description: null
test-stop: null
test-support: |
typedef ${.:/test-context-type} Context;
static bool test_case_active;
static void Disable( const Context *ctx )
{
(void) rtems_interrupt_vector_disable( ctx->test_vector );
}
static void ProcessInterrupt( Context *ctx )
{
ctx->interrupt_occurred = true;
CallWithinISRClear();
Disable( ctx );
}
static void EntryRoutine( void *arg )
{
Context *ctx;
ctx = arg;
++ctx->entry_counter;
ProcessInterrupt( ctx );
}
static void Fatal(
rtems_fatal_source source,
rtems_fatal_code code,
void *arg
)
{
Context *ctx;
ctx = arg;
ctx->fatal_source = source;
ctx->fatal_code = code;
++ctx->fatal_counter;
longjmp( ctx->before_call, 1 );
}
void __real_bsp_interrupt_handler_default( rtems_vector_number vector );
void __wrap_bsp_interrupt_handler_default( rtems_vector_number vector );
void __wrap_bsp_interrupt_handler_default( rtems_vector_number vector )
{
if ( test_case_active ) {
Context *ctx;
ctx = T_fixture_context();
ProcessInterrupt( ctx );
if ( setjmp( ctx->before_call ) == 0 ) {
__real_bsp_interrupt_handler_default( vector );
}
} else {
__real_bsp_interrupt_handler_default( vector );
}
}
#if defined(RTEMS_SMP)
void __real_bsp_interrupt_spurious( rtems_vector_number vector );
void __wrap_bsp_interrupt_spurious( rtems_vector_number vector );
void __wrap_bsp_interrupt_spurious( rtems_vector_number vector )
{
if ( test_case_active ) {
Context *ctx;
ctx = T_fixture_context();
*ctx->first = ctx->first_again;
}
__real_bsp_interrupt_spurious( vector );
}
#endif
test-target: testsuites/validation/tc-bsp-interrupt-handler-dispatch-unchecked.c
test-teardown:
brief: null
code: |
SetFatalHandler( NULL, NULL );
test_case_active = false;
if ( ctx->first != NULL ) {
*ctx->first = ctx->entry_to_restore;
}
description: null
text: ${.:text-template}
transition-map:
- enabled-by: true
post-conditions:
Result: FatalError
FatalSource: SpuriousInterrupt
FatalCode: Vector
pre-conditions:
LoadFirst:
- 'Null'
LoadFirstAgain: N/A
- enabled-by: true
post-conditions:
Result: Dispatch
FatalSource: N/A
FatalCode: N/A
pre-conditions:
LoadFirst:
- Entry
LoadFirstAgain: N/A
- enabled-by: RTEMS_SMP
post-conditions:
Result: FatalError
FatalSource: SpuriousInterrupt
FatalCode: Vector
pre-conditions:
LoadFirst:
- 'Null'
LoadFirstAgain:
- 'Null'
- enabled-by: RTEMS_SMP
post-conditions:
Result: Dispatch
FatalSource: N/A
FatalCode: N/A
pre-conditions:
LoadFirst:
- 'Null'
LoadFirstAgain:
- Entry
type: requirement
|