summaryrefslogtreecommitdiffstats
path: root/spec/rtems/intr/req/handler-iterate.yml
blob: b04a0c1bac15698b2c26c1059ae5a3e2f8ed16ef (plain) (blame)
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
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/handler-iterate
post-conditions:
- name: Status
  states:
  - name: Ok
    test-code: |
      T_rsc_success( ctx->status );
    text: |
      The return status of ${../if/handler-iterate:/name} shall be
      ${../../status/if/successful:/name}.
  - name: InvAddr
    test-code: |
      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
    text: |
      The return status of ${../if/handler-iterate:/name} shall be
      ${../../status/if/invalid-address:/name}.
  - name: IncStat
    test-code: |
      T_rsc( ctx->status, RTEMS_INCORRECT_STATE );
    text: |
      The return status of ${../if/handler-iterate:/name} shall be
      ${../../status/if/incorrect-state:/name}.
  - name: InvId
    test-code: |
      T_rsc( ctx->status, RTEMS_INVALID_ID );
    text: |
      The return status of ${../if/handler-iterate:/name} shall be
      ${../../status/if/invalid-id:/name}.
  - name: CalledFromISR
    test-code: |
      T_rsc( ctx->status, RTEMS_CALLED_FROM_ISR );
    text: |
      The return status of ${../if/handler-iterate:/name} shall be
      ${../../status/if/called-from-isr:/name}.
  test-epilogue: null
  test-prologue: null
- name: Visit
  states:
  - name: 'Yes'
    test-code: |
      T_eq_u32( ctx->visited_entries, 1 );
    text: |
      For each interrupt entry installed at the interrupt vector specified by
      ${../if/handler-iterate:/params[0]/name} the visitor routine specified by
      ${../if/handler-iterate:/params[1]/name} shall be called with the
      argument specified by ${../if/handler-iterate:/params[2]/name}, the entry
      information, the entry install options, the entry handler routine, and
      the entry handler argument.
  - name: Nop
    test-code: |
      T_eq_u32( ctx->visited_entries, 0 );
    text: |
      The visitor routine specified by ${../if/handler-iterate:/params[1]/name}
      shall not be called.
  test-epilogue: null
  test-prologue: null
pre-conditions:
- name: Vector
  states:
  - name: Valid
    test-code: |
      ctx->vector = ctx->test_vector;
    text: |
      While the ${../if/handler-iterate:/params[0]/name} parameter is
      associated with an interrupt vector.
  - name: Invalid
    test-code: |
      ctx->vector = BSP_INTERRUPT_VECTOR_COUNT;
    text: |
      While the ${../if/handler-iterate:/params[0]/name} parameter is
      not associated with an interrupt vector.
  test-epilogue: null
  test-prologue: null
- name: Routine
  states:
  - name: Valid
    test-code: |
      ctx->routine = VisitorRoutine;
    text: |
      While the visitor routine specified by the
      ${../if/handler-iterate:/params[1]/name} parameter is valid.
  - name: 'Null'
    test-code: |
      ctx->routine = NULL;
    text: |
      While the visitor routine specified by the
      ${../if/handler-iterate:/params[1]/name} parameter is equal to
      ${/c/if/null:/name}.
  test-epilogue: null
  test-prologue: null
- name: Init
  states:
  - name: 'Yes'
    test-code: |
      ctx->initialized = true;
    text: |
      While the service is initialized.
  - name: 'No'
    test-code: |
      ctx->initialized = false;
    text: |
      While the service is not initialized.
  test-epilogue: null
  test-prologue: null
- name: ISR
  states:
  - name: 'Yes'
    test-code: |
      ctx->isr = true;
    text: |
      While ${../if/handler-iterate:/name} is called from within interrupt
      context.
  - name: 'No'
    test-code: |
      ctx->isr = false;
    text: |
      While ${../if/handler-iterate:/name} is not called from within interrupt
      context.
  test-epilogue: null
  test-prologue: null
rationale: null
references: []
requirement-type: functional
skip-reasons: {}
test-action: |
  if ( ctx->isr ) {
    CallWithinISR( Action, ctx );
  } else {
    Action( ctx );
  }
test-brief: null
test-cleanup: null
test-context:
- brief: |
    If this member is true, then the service was initialized during setup.
  description: null
  member: |
    bool initialized_during_setup
- brief: |
    This member provides the vector number of a testable interrupt vector.
  description: null
  member: |
    rtems_vector_number test_vector
- brief: |
    If this member is true, then the testable interrupt vector was enabled at
    the test case begin.
  description: null
  member: |
    bool test_vector_was_enabled
- brief: |
    If this member is true, then the service shall be initialized.
  description: null
  member: |
    bool initialized
- brief: |
    If this member is true, then ${../if/handler-iterate:/name} shall be called
    from within interrupt context.
  description: null
  member: |
    bool isr
- brief: |
    This member provides the count of visited entries.
  description: null
  member: |
    uint32_t visited_entries
- brief: |
    This member provides an ${../if/entry:/name} object.
  description: null
  member: |
    rtems_interrupt_entry entry
- brief: |
    This member specifies if the ${../if/handler-iterate:/params[0]/name}
    parameter value.
  description: null
  member: |
    rtems_vector_number vector
- brief: |
    This member specifies if the ${../if/handler-iterate:/params[1]/name}
    parameter value.
  description: null
  member: |
    rtems_interrupt_per_handler_routine routine
- brief: |
    This member contains the return value of the ${../if/handler-iterate:/name}
    call.
  description: null
  member: |
    rtems_status_code status
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems/irq-extension.h
- bsp/irq-generic.h
test-local-includes:
- tx-support.h
test-prepare: null
test-setup:
  brief: null
  code: |
    rtems_status_code sc;

    ctx->initialized_during_setup = bsp_interrupt_is_initialized();
    ctx->test_vector = GetTestableInterruptVector( NULL );
    ctx->test_vector_was_enabled = false;
    (void) rtems_interrupt_vector_is_enabled(
      ctx->test_vector,
      &ctx->test_vector_was_enabled
    );
    rtems_interrupt_entry_initialize(
      &ctx->entry,
      EntryRoutine,
      &entry_arg,
      entry_info
    );
    sc = rtems_interrupt_entry_install(
      ctx->test_vector,
      RTEMS_INTERRUPT_UNIQUE,
      &ctx->entry
    );
    T_rsc_success( sc );
  description: null
test-stop: null
test-support: |
  typedef ${.:/test-context-type} Context;

  static char entry_arg;

  static char visitor_arg;

  static const char entry_info[] = "Entry";

  static void EntryRoutine( void *arg )
  {
    Context          *ctx;
    rtems_status_code sc;

    (void) arg;
    ctx = T_fixture_context();
    sc = rtems_interrupt_vector_disable( ctx->test_vector );
    T_rsc_success( sc );

    T_eq_ptr( arg, &entry_arg );
  }

  static void VisitorRoutine(
    void                   *arg,
    const char             *info,
    rtems_option            options,
    rtems_interrupt_handler handler_routine,
    void                   *handler_arg
  )
  {
    Context *ctx;

    ctx = T_fixture_context();
    ++ctx->visited_entries;
    T_eq_ptr( arg, &visitor_arg );
    T_eq_ptr( info, entry_info );
    T_eq_u32( options, RTEMS_INTERRUPT_UNIQUE );
    T_eq_ptr( handler_routine, EntryRoutine );
    T_eq_ptr( handler_arg, &entry_arg );
  }

  static void Action( void *arg )
  {
    Context *ctx;

    ctx = arg;
    ctx->visited_entries = 0;

    bsp_interrupt_set_handler_unique(
      BSP_INTERRUPT_DISPATCH_TABLE_SIZE,
      ctx->initialized
    );

    ctx->status = rtems_interrupt_handler_iterate(
      ctx->vector,
      ctx->routine,
      &visitor_arg
    );

    bsp_interrupt_set_handler_unique(
      BSP_INTERRUPT_DISPATCH_TABLE_SIZE,
      ctx->initialized_during_setup
    );
  }
test-target: testsuites/validation/tc-intr-handler-iterate.c
test-teardown:
  brief: null
  code: |
    rtems_status_code sc;

    sc = rtems_interrupt_entry_remove(
      ctx->test_vector,
      &ctx->entry
    );
    T_rsc_success( sc );

    if ( ctx->test_vector_was_enabled ) {
      (void) rtems_interrupt_vector_enable( ctx->test_vector );
    }
  description: null
text: ${.:text-template}
transition-map:
- enabled-by: true
  post-conditions:
    Status: Ok
    Visit: 'Yes'
  pre-conditions:
    Vector:
    - Valid
    Routine:
    - Valid
    Init:
    - 'Yes'
    ISR:
    - 'No'
- enabled-by: true
  post-conditions:
    Status: IncStat
    Visit: Nop
  pre-conditions:
    Vector: all
    Routine:
    - Valid
    Init:
    - 'No'
    ISR: all
- enabled-by: true
  post-conditions:
    Status: IncStat
    Visit: N/A
  pre-conditions:
    Vector: all
    Routine:
    - 'Null'
    Init:
    - 'No'
    ISR: all
- enabled-by: true
  post-conditions:
    Status: InvAddr
    Visit: N/A
  pre-conditions:
    Vector: all
    Routine:
    - 'Null'
    Init:
    - 'Yes'
    ISR: all
- enabled-by: true
  post-conditions:
    Status: InvId
    Visit: Nop
  pre-conditions:
    Vector:
    - Invalid
    Routine:
    - Valid
    Init:
    - 'Yes'
    ISR: all
- enabled-by: true
  post-conditions:
    Status: CalledFromISR
    Visit: Nop
  pre-conditions:
    Vector:
    - Valid
    Routine:
    - Valid
    Init:
    - 'Yes'
    ISR:
    - 'Yes'
type: requirement