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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
enabled-by: true
functional-type: action
links:
- role: interface-function
uid: ../if/catch
post-conditions:
- name: Status
states:
- name: Ok
test-code: |
T_rsc_success( ctx->catch_status );
text: |
The return status of ${../if/catch:/name} shall be
${../../status/if/successful:/name}.
- name: NotImplIntLvl
test-code: |
T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
text: |
The return status of ${../if/catch:/name} shall be
${../../status/if/not-implemented:/name}.
- name: NotImplIntLvlSMP
test-code: |
if ( rtems_configuration_get_maximum_processors() > 1 ) {
T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
} else {
T_rsc_success( ctx->catch_status );
}
text: |
Where the system needs inter-processor interrupts, the return status of
${../if/catch:/name} shall be ${../../status/if/not-implemented:/name}.
Where the system does not need inter-processor interrupts, the return
status of ${../if/catch:/name} shall be
${../../status/if/successful:/name}.
- name: NotImplNoPreempt
test-code: |
if ( rtems_configuration_get_maximum_processors() > 1 ) {
T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
} else {
T_rsc_success( ctx->catch_status );
}
text: |
Where the scheduler does not support the no-preempt mode, the return
status of ${../if/catch:/name} shall be
${../../status/if/not-implemented:/name}.
Where the scheduler does support the no-preempt mode, the return status
of ${../if/catch:/name} shall be ${../../status/if/successful:/name}.
test-epilogue: null
test-prologue: null
- name: ASRInfo
states:
- name: NopIntLvl
test-code: |
CheckNoASRChange( ctx );
text: |
The ASR information of the caller of ${../if/catch:/name} shall not be
changed by the ${../if/catch:/name} call.
- name: NopIntLvlSMP
test-code: |
if ( rtems_configuration_get_maximum_processors() > 1 ) {
CheckNoASRChange( ctx );
} else {
CheckNewASRSettings( ctx );
}
text: |
Where the system needs inter-processor interrupts, the ASR information of
the caller of ${../if/catch:/name} shall not be changed by the
${../if/catch:/name} call.
Where the system does not need inter-processor interrupts, the ASR
processing for the caller of ${../if/catch:/name} shall be done using the
handler specified by ${../if/catch:/params[0]/name} in the mode specified
by ${../if/catch:/params[1]/name}.
- name: NopNoPreempt
test-code: |
if ( rtems_configuration_get_maximum_processors() > 1 ) {
CheckNoASRChange( ctx );
} else {
CheckNewASRSettings( ctx );
}
text: |
Where the scheduler does not support the no-preempt mode, the ASR
information of the caller of ${../if/catch:/name} shall not be changed by
the ${../if/catch:/name} call.
Where the scheduler does support the no-preempt mode, the ASR processing
for the caller of ${../if/catch:/name} shall be done using the handler
specified by ${../if/catch:/params[0]/name} in the mode specified by
${../if/catch:/params[1]/name}.
- name: New
test-code: |
CheckNewASRSettings( ctx );
text: |
The ASR processing for the caller of ${../if/catch:/name} shall be done
using the handler specified by ${../if/catch:/params[0]/name} in the mode
specified by ${../if/catch:/params[1]/name}.
- name: Inactive
test-code: |
T_rsc( ctx->send_status, RTEMS_NOT_DEFINED );
T_eq_u32( ctx->default_handler_calls, 0 );
T_eq_u32( ctx->handler_calls, 0 );
T_eq_u32( ctx->handler_mode, 0xffffffff );
text: |
The ASR processing for the caller of ${../if/catch:/name} shall be
deactivated.
The pending signals of the caller of ${../if/catch:/name} shall be cleared.
test-epilogue: null
test-prologue: null
pre-conditions:
- name: Pending
states:
- name: 'Yes'
test-code: |
if ( rtems_scheduler_get_processor_maximum() > 1 ) {
ctx->pending_signals = 1;
} else {
ctx->pending_signals = 0;
}
text: |
Where the system has more than one processor, while the calling task has
pending signals.
Where the system has exactly one processor, while the calling task has no
pending signals.
- name: 'No'
test-code: |
ctx->pending_signals = 0;
text: |
While the calling task has no pending signals.
test-epilogue: null
test-prologue: null
- name: Handler
states:
- name: Invalid
test-code: |
ctx->handler = NULL;
text: |
While the ${../if/catch:/params[0]/name} parameter is ${/c/if/null:/name}.
- name: Valid
test-code: |
ctx->handler = SignalHandler;
text: |
While the ${../if/catch:/params[0]/name} parameter is a valid ASR handler.
test-epilogue: null
test-prologue: null
- name: Preempt
states:
- name: 'Yes'
test-code: |
if ( rtems_configuration_get_maximum_processors() == 1 ) {
ctx->normal_mode |= RTEMS_NO_PREEMPT;
}
text: |
While the ${../if/catch:/params[1]/name} parameter specifies that
preemption is enabled.
- name: 'No'
test-code: |
ctx->mode |= RTEMS_NO_PREEMPT;
text: |
While the ${../if/catch:/params[1]/name} parameter specifies that
preemption is disabled.
test-epilogue: null
test-prologue: null
- name: Timeslice
states:
- name: 'Yes'
test-code: |
ctx->mode |= RTEMS_TIMESLICE;
text: |
While the ${../if/catch:/params[1]/name} parameter specifies that
timeslicing is enabled.
- name: 'No'
test-code: |
ctx->normal_mode |= RTEMS_TIMESLICE;
text: |
While the ${../if/catch:/params[1]/name} parameter specifies that
timeslicing is disabled.
test-epilogue: null
test-prologue: null
- name: ASR
states:
- name: 'Yes'
test-code: |
/*
* We cannot disable ASR processing at normal task level for this state.
*/
text: |
While the ${../if/catch:/params[1]/name} parameter specifies that
ASR processing is enabled.
- name: 'No'
test-code: |
ctx->mode |= RTEMS_NO_ASR;
text: |
While the ${../if/catch:/params[1]/name} parameter specifies that
ASR processing is disabled.
test-epilogue: null
test-prologue: null
- name: IntLvl
states:
- name: Zero
test-code: |
#if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE && !defined(RTEMS_SMP)
ctx->normal_mode |= RTEMS_INTERRUPT_LEVEL( 1 );
#endif
text: |
While the ${../if/catch:/params[1]/name} parameter specifies an interrupt
level of zero.
- name: Positive
test-code: |
ctx->mode |= RTEMS_INTERRUPT_LEVEL( 1 );
text: |
While the ${../if/catch:/params[1]/name} parameter specifies an interrupt
level greater than or equal to one and less than or equal to
${/score/cpu/if/modes-interrupt-mask:/name}.
test-epilogue: null
test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
rtems_status_code sc;
rtems_mode mode;
if ( ctx->pending_signals != 0 ) {
rtems_interrupt_level level;
rtems_interrupt_local_disable(level);
_SMP_barrier_Wait( &ctx->barrier, &ctx->runner_barrier_state, 2 );
_SMP_barrier_Wait( &ctx->barrier, &ctx->runner_barrier_state, 2 );
ctx->catch_status = rtems_signal_catch( ctx->handler, ctx->mode );
rtems_interrupt_local_enable(level);
} else {
ctx->catch_status = rtems_signal_catch( ctx->handler, ctx->mode );
}
sc = rtems_task_mode( ctx->normal_mode, RTEMS_ALL_MODE_MASKS, &mode );
T_rsc_success( sc );
ctx->send_status = rtems_signal_send( RTEMS_SELF, 0xdeadbeef );
sc = rtems_task_mode( mode, RTEMS_ALL_MODE_MASKS, &mode );
T_rsc_success( sc );
test-brief: null
test-cleanup: null
test-context:
- brief: |
This member contains the object identifier of the runner task.
description: null
member: |
rtems_id runner_id
- brief: |
This member contains the object identifier of the worker task.
description: null
member: |
rtems_id worker_id
- brief: null
If this member is non-zero, then rtems_signal_catch() is called with
pending signals, otherwise it is called with no pending signals.
description: null
member: |
uint32_t pending_signals
- brief:
This member provides a barrier to synchronize the runner and worker tasks.
description: null
member: |
SMP_barrier_Control barrier
- brief: |
This member is used for barrier operations done by the runner task.
description: null
member: |
SMP_barrier_State runner_barrier_state
- brief: |
When the default handler is called, this member is incremented.
description: null
member: |
uint32_t default_handler_calls
- brief: |
When the handler is called, this member is incremented.
description: null
member: |
uint32_t handler_calls
- brief: |
This member contains the mode observed in the last handler call.
description: null
member: |
rtems_mode handler_mode
- brief: |
This member specifies the normal task mode for the action.
description: null
member: |
rtems_mode normal_mode
- brief: |
This member specifies the handler for the action.
description: null
member: |
rtems_asr_entry handler
- brief: |
This member specifies the task mode for the action.
description: null
member: |
rtems_mode mode
- brief: |
This member contains the return status of the rtems_signal_catch() call of
the action.
description: null
member: |
rtems_status_code catch_status
- brief: |
This member contains the return status of the rtems_signal_send() call of
the action.
description: null
member: |
rtems_status_code send_status
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
- string.h
- rtems/score/smpbarrier.h
test-local-includes:
- tx-support.h
test-prepare: |
rtems_status_code sc;
ctx->default_handler_calls = 0;
ctx->handler_calls = 0;
ctx->handler_mode = 0xffffffff;
ctx->normal_mode = RTEMS_DEFAULT_MODES;
ctx->handler = NULL;
ctx->mode = RTEMS_DEFAULT_MODES;
sc = rtems_signal_catch( DefaultHandler, RTEMS_NO_ASR );
T_rsc_success( sc );
test-setup:
brief: null
code: |
memset( ctx, 0, sizeof( *ctx ) );
ctx->runner_id = rtems_task_self();
_SMP_barrier_Control_initialize( &ctx->barrier );
_SMP_barrier_State_initialize( &ctx->runner_barrier_state );
if ( rtems_scheduler_get_processor_maximum() > 1 ) {
rtems_status_code sc;
rtems_id scheduler_id;
ctx->worker_id = CreateTask( "WORK", 1 );
sc = rtems_scheduler_ident_by_processor( 1, &scheduler_id );
T_assert_rsc_success( sc );
sc = rtems_task_set_scheduler( ctx->worker_id, scheduler_id, 1 );
T_assert_rsc_success( sc );
StartTask( ctx->worker_id, Worker, ctx );
}
description: null
test-stop: null
test-support: |
typedef ${.:/test-context-type} Context;
static void DefaultHandler( rtems_signal_set signal_set )
{
Context *ctx;
ctx = T_fixture_context();
++ctx->default_handler_calls;
if ( ctx->pending_signals != 0 && ctx->default_handler_calls == 1 ) {
T_eq_u32( signal_set, 0x600df00d );
} else {
T_eq_u32( signal_set, 0xdeadbeef );
}
}
static void SignalHandler( rtems_signal_set signal_set )
{
Context *ctx;
rtems_status_code sc;
ctx = T_fixture_context();
++ctx->handler_calls;
sc = rtems_task_mode(
RTEMS_DEFAULT_MODES,
RTEMS_CURRENT_MODE,
&ctx->handler_mode
);
T_rsc_success( sc );
if ( ctx->pending_signals != 0 && ctx->handler_calls == 1 ) {
T_eq_u32( signal_set, 0x600df00d );
} else {
T_eq_u32( signal_set, 0xdeadbeef );
}
}
static void CheckNoASRChange( Context *ctx )
{
T_rsc_success( ctx->send_status );
T_eq_u32( ctx->default_handler_calls, 1 + ctx->pending_signals );
T_eq_u32( ctx->handler_calls, 0 );
T_eq_u32( ctx->handler_mode, 0xffffffff );
}
static void CheckNewASRSettings( Context *ctx )
{
T_rsc_success( ctx->send_status );
T_eq_u32( ctx->default_handler_calls, 0 );
T_eq_u32( ctx->handler_calls, 1 + ctx->pending_signals );
T_eq_u32( ctx->handler_mode, ctx->mode );
}
static void Worker( rtems_task_argument arg )
{
Context *ctx;
SMP_barrier_State barrier_state;
ctx = (Context *) arg;
_SMP_barrier_State_initialize( &barrier_state );
while ( true ) {
rtems_status_code sc;
_SMP_barrier_Wait( &ctx->barrier, &barrier_state, 2 );
sc = rtems_signal_send( ctx->runner_id, 0x600df00d );
T_rsc_success( sc );
_SMP_barrier_Wait( &ctx->barrier, &barrier_state, 2 );
}
}
test-target: testsuites/validation/tc-signal-catch.c
test-teardown:
brief: null
code: |
DeleteTask( ctx->worker_id );
RestoreRunnerASR();
description: null
text: ${.:text-template}
transition-map:
- enabled-by: true
post-conditions:
Status: Ok
ASRInfo:
- if:
pre-conditions:
Handler: Valid
then: New
- else: Inactive
pre-conditions:
Pending: all
Handler: all
Preempt: all
Timeslice: all
ASR: all
IntLvl: all
- enabled-by: CPU_ENABLE_ROBUST_THREAD_DISPATCH
post-conditions:
Status: NotImplIntLvl
ASRInfo: NopIntLvl
pre-conditions:
Pending: all
Handler:
- Valid
Preempt: all
Timeslice: all
ASR: all
IntLvl:
- Positive
- enabled-by: RTEMS_SMP
post-conditions:
Status:
- if:
pre-conditions:
IntLvl: Positive
then: NotImplIntLvlSMP
- if:
pre-conditions:
Preempt: 'No'
then: NotImplNoPreempt
- else: Ok
ASRInfo:
- if:
pre-conditions:
IntLvl: Positive
then: NopIntLvlSMP
- if:
pre-conditions:
Preempt: 'No'
then: NopNoPreempt
- else: New
pre-conditions:
Pending: all
Handler:
- Valid
Preempt: all
Timeslice: all
ASR: all
IntLvl: all
type: requirement
|