1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSTestCaseRtemsIntrReqGetAffinity |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) |
---|
11 | * |
---|
12 | * Redistribution and use in source and binary forms, with or without |
---|
13 | * modification, are permitted provided that the following conditions |
---|
14 | * are met: |
---|
15 | * 1. Redistributions of source code must retain the above copyright |
---|
16 | * notice, this list of conditions and the following disclaimer. |
---|
17 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
18 | * notice, this list of conditions and the following disclaimer in the |
---|
19 | * documentation and/or other materials provided with the distribution. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
31 | * POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /* |
---|
35 | * This file is part of the RTEMS quality process and was automatically |
---|
36 | * generated. If you find something that needs to be fixed or |
---|
37 | * worded better please post a report or patch to an RTEMS mailing list |
---|
38 | * or raise a bug report: |
---|
39 | * |
---|
40 | * https://www.rtems.org/bugs.html |
---|
41 | * |
---|
42 | * For information on updating and regenerating please refer to the How-To |
---|
43 | * section in the Software Requirements Engineering chapter of the |
---|
44 | * RTEMS Software Engineering manual. The manual is provided as a part of |
---|
45 | * a release. For development sources please refer to the online |
---|
46 | * documentation at: |
---|
47 | * |
---|
48 | * https://docs.rtems.org |
---|
49 | */ |
---|
50 | |
---|
51 | #ifdef HAVE_CONFIG_H |
---|
52 | #include "config.h" |
---|
53 | #endif |
---|
54 | |
---|
55 | #include <string.h> |
---|
56 | #include <bsp/irq-generic.h> |
---|
57 | #include <rtems/irq-extension.h> |
---|
58 | |
---|
59 | #include "tx-support.h" |
---|
60 | |
---|
61 | #include <rtems/test.h> |
---|
62 | |
---|
63 | /** |
---|
64 | * @defgroup RTEMSTestCaseRtemsIntrReqGetAffinity \ |
---|
65 | * spec:/rtems/intr/req/get-affinity |
---|
66 | * |
---|
67 | * @ingroup RTEMSTestSuiteTestsuitesValidation0 |
---|
68 | * |
---|
69 | * @{ |
---|
70 | */ |
---|
71 | |
---|
72 | typedef enum { |
---|
73 | RtemsIntrReqGetAffinity_Pre_Vector_Valid, |
---|
74 | RtemsIntrReqGetAffinity_Pre_Vector_Invalid, |
---|
75 | RtemsIntrReqGetAffinity_Pre_Vector_NA |
---|
76 | } RtemsIntrReqGetAffinity_Pre_Vector; |
---|
77 | |
---|
78 | typedef enum { |
---|
79 | RtemsIntrReqGetAffinity_Pre_CPUSetSize_Valid, |
---|
80 | RtemsIntrReqGetAffinity_Pre_CPUSetSize_TooSmall, |
---|
81 | RtemsIntrReqGetAffinity_Pre_CPUSetSize_Askew, |
---|
82 | RtemsIntrReqGetAffinity_Pre_CPUSetSize_NA |
---|
83 | } RtemsIntrReqGetAffinity_Pre_CPUSetSize; |
---|
84 | |
---|
85 | typedef enum { |
---|
86 | RtemsIntrReqGetAffinity_Pre_CPUSet_Valid, |
---|
87 | RtemsIntrReqGetAffinity_Pre_CPUSet_Null, |
---|
88 | RtemsIntrReqGetAffinity_Pre_CPUSet_NA |
---|
89 | } RtemsIntrReqGetAffinity_Pre_CPUSet; |
---|
90 | |
---|
91 | typedef enum { |
---|
92 | RtemsIntrReqGetAffinity_Pre_CanGetAffinity_Yes, |
---|
93 | RtemsIntrReqGetAffinity_Pre_CanGetAffinity_No, |
---|
94 | RtemsIntrReqGetAffinity_Pre_CanGetAffinity_NA |
---|
95 | } RtemsIntrReqGetAffinity_Pre_CanGetAffinity; |
---|
96 | |
---|
97 | typedef enum { |
---|
98 | RtemsIntrReqGetAffinity_Post_Status_Ok, |
---|
99 | RtemsIntrReqGetAffinity_Post_Status_InvAddr, |
---|
100 | RtemsIntrReqGetAffinity_Post_Status_InvId, |
---|
101 | RtemsIntrReqGetAffinity_Post_Status_InvSize, |
---|
102 | RtemsIntrReqGetAffinity_Post_Status_Unsat, |
---|
103 | RtemsIntrReqGetAffinity_Post_Status_NA |
---|
104 | } RtemsIntrReqGetAffinity_Post_Status; |
---|
105 | |
---|
106 | typedef enum { |
---|
107 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Set, |
---|
108 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Partial, |
---|
109 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Zero, |
---|
110 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Nop, |
---|
111 | RtemsIntrReqGetAffinity_Post_CPUSetObj_NA |
---|
112 | } RtemsIntrReqGetAffinity_Post_CPUSetObj; |
---|
113 | |
---|
114 | typedef struct { |
---|
115 | uint16_t Skip : 1; |
---|
116 | uint16_t Pre_Vector_NA : 1; |
---|
117 | uint16_t Pre_CPUSetSize_NA : 1; |
---|
118 | uint16_t Pre_CPUSet_NA : 1; |
---|
119 | uint16_t Pre_CanGetAffinity_NA : 1; |
---|
120 | uint16_t Post_Status : 3; |
---|
121 | uint16_t Post_CPUSetObj : 3; |
---|
122 | } RtemsIntrReqGetAffinity_Entry; |
---|
123 | |
---|
124 | /** |
---|
125 | * @brief Test context for spec:/rtems/intr/req/get-affinity test case. |
---|
126 | */ |
---|
127 | typedef struct { |
---|
128 | /** |
---|
129 | * @brief This member contains the current vector number. |
---|
130 | */ |
---|
131 | rtems_vector_number vector; |
---|
132 | |
---|
133 | /** |
---|
134 | * @brief This member contains some valid vector number. |
---|
135 | */ |
---|
136 | rtems_vector_number some_vector; |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief This member provides the object referenced by the ``affinity`` |
---|
140 | * parameter. |
---|
141 | */ |
---|
142 | cpu_set_t cpuset_obj; |
---|
143 | |
---|
144 | /** |
---|
145 | * @brief This member contains the return value of the |
---|
146 | * rtems_interrupt_get_affinity() call. |
---|
147 | */ |
---|
148 | rtems_status_code status; |
---|
149 | |
---|
150 | /** |
---|
151 | * @brief If this member is true, then the ``vector`` parameter shall be |
---|
152 | * valid. |
---|
153 | */ |
---|
154 | bool valid_vector; |
---|
155 | |
---|
156 | /** |
---|
157 | * @brief This member specifies if the ``affinity_size`` parameter value. |
---|
158 | */ |
---|
159 | size_t cpusetsize; |
---|
160 | |
---|
161 | /** |
---|
162 | * @brief This member specifies if the ``affinity`` parameter value. |
---|
163 | */ |
---|
164 | cpu_set_t *cpuset; |
---|
165 | |
---|
166 | struct { |
---|
167 | /** |
---|
168 | * @brief This member defines the pre-condition states for the next action. |
---|
169 | */ |
---|
170 | size_t pcs[ 4 ]; |
---|
171 | |
---|
172 | /** |
---|
173 | * @brief If this member is true, then the test action loop is executed. |
---|
174 | */ |
---|
175 | bool in_action_loop; |
---|
176 | |
---|
177 | /** |
---|
178 | * @brief This member contains the next transition map index. |
---|
179 | */ |
---|
180 | size_t index; |
---|
181 | |
---|
182 | /** |
---|
183 | * @brief This member contains the current transition map entry. |
---|
184 | */ |
---|
185 | RtemsIntrReqGetAffinity_Entry entry; |
---|
186 | |
---|
187 | /** |
---|
188 | * @brief If this member is true, then the current transition variant |
---|
189 | * should be skipped. |
---|
190 | */ |
---|
191 | bool skip; |
---|
192 | } Map; |
---|
193 | } RtemsIntrReqGetAffinity_Context; |
---|
194 | |
---|
195 | static RtemsIntrReqGetAffinity_Context |
---|
196 | RtemsIntrReqGetAffinity_Instance; |
---|
197 | |
---|
198 | static const char * const RtemsIntrReqGetAffinity_PreDesc_Vector[] = { |
---|
199 | "Valid", |
---|
200 | "Invalid", |
---|
201 | "NA" |
---|
202 | }; |
---|
203 | |
---|
204 | static const char * const RtemsIntrReqGetAffinity_PreDesc_CPUSetSize[] = { |
---|
205 | "Valid", |
---|
206 | "TooSmall", |
---|
207 | "Askew", |
---|
208 | "NA" |
---|
209 | }; |
---|
210 | |
---|
211 | static const char * const RtemsIntrReqGetAffinity_PreDesc_CPUSet[] = { |
---|
212 | "Valid", |
---|
213 | "Null", |
---|
214 | "NA" |
---|
215 | }; |
---|
216 | |
---|
217 | static const char * const RtemsIntrReqGetAffinity_PreDesc_CanGetAffinity[] = { |
---|
218 | "Yes", |
---|
219 | "No", |
---|
220 | "NA" |
---|
221 | }; |
---|
222 | |
---|
223 | static const char * const * const RtemsIntrReqGetAffinity_PreDesc[] = { |
---|
224 | RtemsIntrReqGetAffinity_PreDesc_Vector, |
---|
225 | RtemsIntrReqGetAffinity_PreDesc_CPUSetSize, |
---|
226 | RtemsIntrReqGetAffinity_PreDesc_CPUSet, |
---|
227 | RtemsIntrReqGetAffinity_PreDesc_CanGetAffinity, |
---|
228 | NULL |
---|
229 | }; |
---|
230 | |
---|
231 | typedef RtemsIntrReqGetAffinity_Context Context; |
---|
232 | |
---|
233 | static void CheckGetAffinity( |
---|
234 | Context *ctx, |
---|
235 | const rtems_interrupt_attributes *attr |
---|
236 | ) |
---|
237 | { |
---|
238 | rtems_status_code sc; |
---|
239 | cpu_set_t set; |
---|
240 | |
---|
241 | if ( attr->can_get_affinity ) { |
---|
242 | CPU_ZERO( &ctx->cpuset_obj ); |
---|
243 | } else { |
---|
244 | CPU_FILL( &ctx->cpuset_obj ); |
---|
245 | } |
---|
246 | |
---|
247 | sc = rtems_interrupt_get_affinity( |
---|
248 | ctx->vector, |
---|
249 | ctx->cpusetsize, |
---|
250 | ctx->cpuset |
---|
251 | ); |
---|
252 | |
---|
253 | CPU_ZERO( &set ); |
---|
254 | |
---|
255 | if ( attr->can_get_affinity ) { |
---|
256 | T_rsc_success( sc ); |
---|
257 | T_ne_int( CPU_CMP( &ctx->cpuset_obj, &set ), 0 ); |
---|
258 | } else { |
---|
259 | T_rsc( sc, RTEMS_UNSATISFIED ); |
---|
260 | T_eq_int( CPU_CMP( &ctx->cpuset_obj, &set ), 0 ); |
---|
261 | } |
---|
262 | } |
---|
263 | |
---|
264 | static void RtemsIntrReqGetAffinity_Pre_Vector_Prepare( |
---|
265 | RtemsIntrReqGetAffinity_Context *ctx, |
---|
266 | RtemsIntrReqGetAffinity_Pre_Vector state |
---|
267 | ) |
---|
268 | { |
---|
269 | switch ( state ) { |
---|
270 | case RtemsIntrReqGetAffinity_Pre_Vector_Valid: { |
---|
271 | /* |
---|
272 | * While the ``vector`` parameter is associated with an interrupt vector. |
---|
273 | */ |
---|
274 | ctx->valid_vector = true; |
---|
275 | break; |
---|
276 | } |
---|
277 | |
---|
278 | case RtemsIntrReqGetAffinity_Pre_Vector_Invalid: { |
---|
279 | /* |
---|
280 | * While the ``vector`` parameter is not associated with an interrupt |
---|
281 | * vector. |
---|
282 | */ |
---|
283 | ctx->valid_vector = false; |
---|
284 | break; |
---|
285 | } |
---|
286 | |
---|
287 | case RtemsIntrReqGetAffinity_Pre_Vector_NA: |
---|
288 | break; |
---|
289 | } |
---|
290 | } |
---|
291 | |
---|
292 | static void RtemsIntrReqGetAffinity_Pre_CPUSetSize_Prepare( |
---|
293 | RtemsIntrReqGetAffinity_Context *ctx, |
---|
294 | RtemsIntrReqGetAffinity_Pre_CPUSetSize state |
---|
295 | ) |
---|
296 | { |
---|
297 | switch ( state ) { |
---|
298 | case RtemsIntrReqGetAffinity_Pre_CPUSetSize_Valid: { |
---|
299 | /* |
---|
300 | * While the ``affinity_size`` parameter is an integral multiple of the |
---|
301 | * size of long, while the ``affinity_size`` parameter specifies a |
---|
302 | * processor set which is large enough to contain the processor affinity |
---|
303 | * set of the interrupt specified by ``vector``. |
---|
304 | */ |
---|
305 | ctx->cpusetsize = sizeof( ctx->cpuset_obj ); |
---|
306 | break; |
---|
307 | } |
---|
308 | |
---|
309 | case RtemsIntrReqGetAffinity_Pre_CPUSetSize_TooSmall: { |
---|
310 | /* |
---|
311 | * While the ``affinity_size`` parameter is an integral multiple of the |
---|
312 | * size of long, while the ``affinity_size`` parameter specifies a |
---|
313 | * processor set which is not large enough to contain the processor |
---|
314 | * affinity set of the interrupt specified by ``vector``. |
---|
315 | */ |
---|
316 | ctx->cpusetsize = 0; |
---|
317 | break; |
---|
318 | } |
---|
319 | |
---|
320 | case RtemsIntrReqGetAffinity_Pre_CPUSetSize_Askew: { |
---|
321 | /* |
---|
322 | * While the ``affinity_size`` parameter is not an integral multiple of |
---|
323 | * the size of long. |
---|
324 | */ |
---|
325 | ctx->cpusetsize = SIZE_MAX; |
---|
326 | break; |
---|
327 | } |
---|
328 | |
---|
329 | case RtemsIntrReqGetAffinity_Pre_CPUSetSize_NA: |
---|
330 | break; |
---|
331 | } |
---|
332 | } |
---|
333 | |
---|
334 | static void RtemsIntrReqGetAffinity_Pre_CPUSet_Prepare( |
---|
335 | RtemsIntrReqGetAffinity_Context *ctx, |
---|
336 | RtemsIntrReqGetAffinity_Pre_CPUSet state |
---|
337 | ) |
---|
338 | { |
---|
339 | switch ( state ) { |
---|
340 | case RtemsIntrReqGetAffinity_Pre_CPUSet_Valid: { |
---|
341 | /* |
---|
342 | * While the ``affinity`` parameter references an object of type |
---|
343 | * cpu_set_t. |
---|
344 | */ |
---|
345 | ctx->cpuset = &ctx->cpuset_obj; |
---|
346 | break; |
---|
347 | } |
---|
348 | |
---|
349 | case RtemsIntrReqGetAffinity_Pre_CPUSet_Null: { |
---|
350 | /* |
---|
351 | * While the ``affinity`` parameter is equal to NULL. |
---|
352 | */ |
---|
353 | ctx->cpuset = NULL; |
---|
354 | break; |
---|
355 | } |
---|
356 | |
---|
357 | case RtemsIntrReqGetAffinity_Pre_CPUSet_NA: |
---|
358 | break; |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | static void RtemsIntrReqGetAffinity_Pre_CanGetAffinity_Prepare( |
---|
363 | RtemsIntrReqGetAffinity_Context *ctx, |
---|
364 | RtemsIntrReqGetAffinity_Pre_CanGetAffinity state |
---|
365 | ) |
---|
366 | { |
---|
367 | switch ( state ) { |
---|
368 | case RtemsIntrReqGetAffinity_Pre_CanGetAffinity_Yes: { |
---|
369 | /* |
---|
370 | * While getting the affinity for the interrupt vector specified by |
---|
371 | * ``vector`` parameter is supported. |
---|
372 | */ |
---|
373 | /* Validation done by CheckGetAffinity() for each interrupt vector */ |
---|
374 | break; |
---|
375 | } |
---|
376 | |
---|
377 | case RtemsIntrReqGetAffinity_Pre_CanGetAffinity_No: { |
---|
378 | /* |
---|
379 | * While getting the affinity for the interrupt vector specified by |
---|
380 | * ``vector`` parameter is not supported. |
---|
381 | */ |
---|
382 | /* Validation done by CheckGetAffinity() for each interrupt vector */ |
---|
383 | break; |
---|
384 | } |
---|
385 | |
---|
386 | case RtemsIntrReqGetAffinity_Pre_CanGetAffinity_NA: |
---|
387 | break; |
---|
388 | } |
---|
389 | } |
---|
390 | |
---|
391 | static void RtemsIntrReqGetAffinity_Post_Status_Check( |
---|
392 | RtemsIntrReqGetAffinity_Context *ctx, |
---|
393 | RtemsIntrReqGetAffinity_Post_Status state |
---|
394 | ) |
---|
395 | { |
---|
396 | switch ( state ) { |
---|
397 | case RtemsIntrReqGetAffinity_Post_Status_Ok: { |
---|
398 | /* |
---|
399 | * The return status of rtems_interrupt_get_affinity() shall be |
---|
400 | * RTEMS_SUCCESSFUL. |
---|
401 | */ |
---|
402 | /* Validation done by CheckGetAffinity() for each interrupt vector */ |
---|
403 | break; |
---|
404 | } |
---|
405 | |
---|
406 | case RtemsIntrReqGetAffinity_Post_Status_InvAddr: { |
---|
407 | /* |
---|
408 | * The return status of rtems_interrupt_get_affinity() shall be |
---|
409 | * RTEMS_INVALID_ADDRESS. |
---|
410 | */ |
---|
411 | T_rsc( ctx->status, RTEMS_INVALID_ADDRESS ); |
---|
412 | break; |
---|
413 | } |
---|
414 | |
---|
415 | case RtemsIntrReqGetAffinity_Post_Status_InvId: { |
---|
416 | /* |
---|
417 | * The return status of rtems_interrupt_get_affinity() shall be |
---|
418 | * RTEMS_INVALID_ID. |
---|
419 | */ |
---|
420 | T_rsc( ctx->status, RTEMS_INVALID_ID ); |
---|
421 | break; |
---|
422 | } |
---|
423 | |
---|
424 | case RtemsIntrReqGetAffinity_Post_Status_InvSize: { |
---|
425 | /* |
---|
426 | * The return status of rtems_interrupt_get_affinity() shall be |
---|
427 | * RTEMS_INVALID_SIZE. |
---|
428 | */ |
---|
429 | T_rsc( ctx->status, RTEMS_INVALID_SIZE ); |
---|
430 | break; |
---|
431 | } |
---|
432 | |
---|
433 | case RtemsIntrReqGetAffinity_Post_Status_Unsat: { |
---|
434 | /* |
---|
435 | * The return status of rtems_interrupt_get_affinity() shall be |
---|
436 | * RTEMS_UNSATISFIED. |
---|
437 | */ |
---|
438 | /* Validation done by CheckGetAffinity() for each interrupt vector */ |
---|
439 | break; |
---|
440 | } |
---|
441 | |
---|
442 | case RtemsIntrReqGetAffinity_Post_Status_NA: |
---|
443 | break; |
---|
444 | } |
---|
445 | } |
---|
446 | |
---|
447 | static void RtemsIntrReqGetAffinity_Post_CPUSetObj_Check( |
---|
448 | RtemsIntrReqGetAffinity_Context *ctx, |
---|
449 | RtemsIntrReqGetAffinity_Post_CPUSetObj state |
---|
450 | ) |
---|
451 | { |
---|
452 | switch ( state ) { |
---|
453 | case RtemsIntrReqGetAffinity_Post_CPUSetObj_Set: { |
---|
454 | /* |
---|
455 | * The value of the object referenced by the ``affinity`` parameter shall |
---|
456 | * be set to the processor affinity set of the interrupt specified by the |
---|
457 | * ``vector`` parameter at some point during the call after the return of |
---|
458 | * the rtems_interrupt_get_affinity() call. |
---|
459 | */ |
---|
460 | /* Validation done by CheckGetAffinity() for each interrupt vector */ |
---|
461 | break; |
---|
462 | } |
---|
463 | |
---|
464 | case RtemsIntrReqGetAffinity_Post_CPUSetObj_Partial: { |
---|
465 | /* |
---|
466 | * The value of the object referenced by the ``affinity`` parameter shall |
---|
467 | * be set to the subset of the processor affinity set which fits into the |
---|
468 | * object of the interrupt specified by the ``vector`` parameter at some |
---|
469 | * point during the call after the return of the |
---|
470 | * rtems_interrupt_get_affinity() call. |
---|
471 | */ |
---|
472 | /* Validation done by CheckGetAffinity() for each interrupt vector */ |
---|
473 | break; |
---|
474 | } |
---|
475 | |
---|
476 | case RtemsIntrReqGetAffinity_Post_CPUSetObj_Zero: { |
---|
477 | /* |
---|
478 | * The value of the object referenced by the ``affinity`` parameter shall |
---|
479 | * be set to zero. |
---|
480 | */ |
---|
481 | /* |
---|
482 | * Validation done by CheckGetAffinity() for each interrupt vector and in |
---|
483 | * the action code. |
---|
484 | */ |
---|
485 | break; |
---|
486 | } |
---|
487 | |
---|
488 | case RtemsIntrReqGetAffinity_Post_CPUSetObj_Nop: { |
---|
489 | /* |
---|
490 | * Objects referenced by the ``affinity`` parameter in past calls to |
---|
491 | * rtems_interrupt_get_affinity() shall not be accessed by the |
---|
492 | * rtems_interrupt_get_affinity() call. |
---|
493 | */ |
---|
494 | /* |
---|
495 | * Validation done by CheckGetAffinity() for each interrupt vector and in |
---|
496 | * the action code. |
---|
497 | */ |
---|
498 | break; |
---|
499 | } |
---|
500 | |
---|
501 | case RtemsIntrReqGetAffinity_Post_CPUSetObj_NA: |
---|
502 | break; |
---|
503 | } |
---|
504 | } |
---|
505 | |
---|
506 | static void RtemsIntrReqGetAffinity_Setup( |
---|
507 | RtemsIntrReqGetAffinity_Context *ctx |
---|
508 | ) |
---|
509 | { |
---|
510 | rtems_interrupt_attributes required; |
---|
511 | |
---|
512 | memset( &required, 0, sizeof( required ) ); |
---|
513 | required.can_get_affinity = true; |
---|
514 | ctx->some_vector = GetValidInterruptVectorNumber( &required ); |
---|
515 | } |
---|
516 | |
---|
517 | static void RtemsIntrReqGetAffinity_Setup_Wrap( void *arg ) |
---|
518 | { |
---|
519 | RtemsIntrReqGetAffinity_Context *ctx; |
---|
520 | |
---|
521 | ctx = arg; |
---|
522 | ctx->Map.in_action_loop = false; |
---|
523 | RtemsIntrReqGetAffinity_Setup( ctx ); |
---|
524 | } |
---|
525 | |
---|
526 | static void RtemsIntrReqGetAffinity_Action( |
---|
527 | RtemsIntrReqGetAffinity_Context *ctx |
---|
528 | ) |
---|
529 | { |
---|
530 | if ( |
---|
531 | ctx->valid_vector && ctx->cpusetsize == sizeof( ctx->cpuset_obj ) && |
---|
532 | ctx->cpuset == &ctx->cpuset_obj |
---|
533 | ) { |
---|
534 | for ( |
---|
535 | ctx->vector = 0; |
---|
536 | ctx->vector < BSP_INTERRUPT_VECTOR_COUNT; |
---|
537 | ++ctx->vector |
---|
538 | ) { |
---|
539 | rtems_status_code sc; |
---|
540 | rtems_interrupt_attributes attr; |
---|
541 | |
---|
542 | memset( &attr, 0, sizeof( attr ) ); |
---|
543 | sc = rtems_interrupt_get_attributes( ctx->vector, &attr ); |
---|
544 | |
---|
545 | if ( sc == RTEMS_INVALID_ID ) { |
---|
546 | continue; |
---|
547 | } |
---|
548 | |
---|
549 | T_rsc_success( sc ); |
---|
550 | |
---|
551 | CheckGetAffinity( ctx, &attr ); |
---|
552 | } |
---|
553 | } else { |
---|
554 | cpu_set_t set; |
---|
555 | |
---|
556 | if ( ctx->valid_vector ) { |
---|
557 | ctx->vector = ctx->some_vector; |
---|
558 | } else { |
---|
559 | ctx->vector = BSP_INTERRUPT_VECTOR_COUNT; |
---|
560 | } |
---|
561 | |
---|
562 | CPU_FILL( &ctx->cpuset_obj ); |
---|
563 | |
---|
564 | ctx->status = rtems_interrupt_get_affinity( |
---|
565 | ctx->vector, |
---|
566 | ctx->cpusetsize, |
---|
567 | ctx->cpuset |
---|
568 | ); |
---|
569 | |
---|
570 | if ( ctx->cpuset == NULL || ctx->cpusetsize != sizeof( ctx->cpuset ) ) { |
---|
571 | CPU_FILL( &set ); |
---|
572 | } else { |
---|
573 | CPU_ZERO( &set ); |
---|
574 | } |
---|
575 | |
---|
576 | T_eq_int( CPU_CMP( &ctx->cpuset_obj, &set ), 0 ); |
---|
577 | } |
---|
578 | } |
---|
579 | |
---|
580 | static const RtemsIntrReqGetAffinity_Entry |
---|
581 | RtemsIntrReqGetAffinity_Entries[] = { |
---|
582 | { 0, 0, 0, 0, 0, RtemsIntrReqGetAffinity_Post_Status_InvAddr, |
---|
583 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Nop }, |
---|
584 | { 0, 0, 0, 0, 1, RtemsIntrReqGetAffinity_Post_Status_InvId, |
---|
585 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Zero }, |
---|
586 | { 0, 0, 0, 0, 1, RtemsIntrReqGetAffinity_Post_Status_InvAddr, |
---|
587 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Nop }, |
---|
588 | { 0, 0, 0, 0, 0, RtemsIntrReqGetAffinity_Post_Status_Unsat, |
---|
589 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Zero }, |
---|
590 | { 0, 0, 0, 0, 0, RtemsIntrReqGetAffinity_Post_Status_InvSize, |
---|
591 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Nop }, |
---|
592 | { 0, 0, 0, 0, 0, RtemsIntrReqGetAffinity_Post_Status_Ok, |
---|
593 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Set }, |
---|
594 | { 0, 0, 0, 0, 0, RtemsIntrReqGetAffinity_Post_Status_InvSize, |
---|
595 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Partial } |
---|
596 | }; |
---|
597 | |
---|
598 | static const uint8_t |
---|
599 | RtemsIntrReqGetAffinity_Map[] = { |
---|
600 | 5, 3, 0, 0, 6, 3, 0, 0, 4, 4, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2 |
---|
601 | }; |
---|
602 | |
---|
603 | static size_t RtemsIntrReqGetAffinity_Scope( void *arg, char *buf, size_t n ) |
---|
604 | { |
---|
605 | RtemsIntrReqGetAffinity_Context *ctx; |
---|
606 | |
---|
607 | ctx = arg; |
---|
608 | |
---|
609 | if ( ctx->Map.in_action_loop ) { |
---|
610 | return T_get_scope( |
---|
611 | RtemsIntrReqGetAffinity_PreDesc, |
---|
612 | buf, |
---|
613 | n, |
---|
614 | ctx->Map.pcs |
---|
615 | ); |
---|
616 | } |
---|
617 | |
---|
618 | return 0; |
---|
619 | } |
---|
620 | |
---|
621 | static T_fixture RtemsIntrReqGetAffinity_Fixture = { |
---|
622 | .setup = RtemsIntrReqGetAffinity_Setup_Wrap, |
---|
623 | .stop = NULL, |
---|
624 | .teardown = NULL, |
---|
625 | .scope = RtemsIntrReqGetAffinity_Scope, |
---|
626 | .initial_context = &RtemsIntrReqGetAffinity_Instance |
---|
627 | }; |
---|
628 | |
---|
629 | static inline RtemsIntrReqGetAffinity_Entry RtemsIntrReqGetAffinity_PopEntry( |
---|
630 | RtemsIntrReqGetAffinity_Context *ctx |
---|
631 | ) |
---|
632 | { |
---|
633 | size_t index; |
---|
634 | |
---|
635 | index = ctx->Map.index; |
---|
636 | ctx->Map.index = index + 1; |
---|
637 | return RtemsIntrReqGetAffinity_Entries[ |
---|
638 | RtemsIntrReqGetAffinity_Map[ index ] |
---|
639 | ]; |
---|
640 | } |
---|
641 | |
---|
642 | static void RtemsIntrReqGetAffinity_TestVariant( |
---|
643 | RtemsIntrReqGetAffinity_Context *ctx |
---|
644 | ) |
---|
645 | { |
---|
646 | RtemsIntrReqGetAffinity_Pre_Vector_Prepare( ctx, ctx->Map.pcs[ 0 ] ); |
---|
647 | RtemsIntrReqGetAffinity_Pre_CPUSetSize_Prepare( ctx, ctx->Map.pcs[ 1 ] ); |
---|
648 | RtemsIntrReqGetAffinity_Pre_CPUSet_Prepare( ctx, ctx->Map.pcs[ 2 ] ); |
---|
649 | RtemsIntrReqGetAffinity_Pre_CanGetAffinity_Prepare( |
---|
650 | ctx, |
---|
651 | ctx->Map.entry.Pre_CanGetAffinity_NA ? RtemsIntrReqGetAffinity_Pre_CanGetAffinity_NA : ctx->Map.pcs[ 3 ] |
---|
652 | ); |
---|
653 | RtemsIntrReqGetAffinity_Action( ctx ); |
---|
654 | RtemsIntrReqGetAffinity_Post_Status_Check( ctx, ctx->Map.entry.Post_Status ); |
---|
655 | RtemsIntrReqGetAffinity_Post_CPUSetObj_Check( |
---|
656 | ctx, |
---|
657 | ctx->Map.entry.Post_CPUSetObj |
---|
658 | ); |
---|
659 | } |
---|
660 | |
---|
661 | /** |
---|
662 | * @fn void T_case_body_RtemsIntrReqGetAffinity( void ) |
---|
663 | */ |
---|
664 | T_TEST_CASE_FIXTURE( |
---|
665 | RtemsIntrReqGetAffinity, |
---|
666 | &RtemsIntrReqGetAffinity_Fixture |
---|
667 | ) |
---|
668 | { |
---|
669 | RtemsIntrReqGetAffinity_Context *ctx; |
---|
670 | |
---|
671 | ctx = T_fixture_context(); |
---|
672 | ctx->Map.in_action_loop = true; |
---|
673 | ctx->Map.index = 0; |
---|
674 | |
---|
675 | for ( |
---|
676 | ctx->Map.pcs[ 0 ] = RtemsIntrReqGetAffinity_Pre_Vector_Valid; |
---|
677 | ctx->Map.pcs[ 0 ] < RtemsIntrReqGetAffinity_Pre_Vector_NA; |
---|
678 | ++ctx->Map.pcs[ 0 ] |
---|
679 | ) { |
---|
680 | for ( |
---|
681 | ctx->Map.pcs[ 1 ] = RtemsIntrReqGetAffinity_Pre_CPUSetSize_Valid; |
---|
682 | ctx->Map.pcs[ 1 ] < RtemsIntrReqGetAffinity_Pre_CPUSetSize_NA; |
---|
683 | ++ctx->Map.pcs[ 1 ] |
---|
684 | ) { |
---|
685 | for ( |
---|
686 | ctx->Map.pcs[ 2 ] = RtemsIntrReqGetAffinity_Pre_CPUSet_Valid; |
---|
687 | ctx->Map.pcs[ 2 ] < RtemsIntrReqGetAffinity_Pre_CPUSet_NA; |
---|
688 | ++ctx->Map.pcs[ 2 ] |
---|
689 | ) { |
---|
690 | for ( |
---|
691 | ctx->Map.pcs[ 3 ] = RtemsIntrReqGetAffinity_Pre_CanGetAffinity_Yes; |
---|
692 | ctx->Map.pcs[ 3 ] < RtemsIntrReqGetAffinity_Pre_CanGetAffinity_NA; |
---|
693 | ++ctx->Map.pcs[ 3 ] |
---|
694 | ) { |
---|
695 | ctx->Map.entry = RtemsIntrReqGetAffinity_PopEntry( ctx ); |
---|
696 | RtemsIntrReqGetAffinity_TestVariant( ctx ); |
---|
697 | } |
---|
698 | } |
---|
699 | } |
---|
700 | } |
---|
701 | } |
---|
702 | |
---|
703 | /** @} */ |
---|