source: rtems/testsuites/validation/tc-signal-catch.c @ 54c9630

Last change on this file since 54c9630 was 54c9630, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 1, 2021 at 9:00:26 AM

validation: Add comments to signal tests

  • Property mode set to 100644
File size: 32.2 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSTestCaseRtemsSignalReqCatch
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 <rtems.h>
56
57#include <rtems/test.h>
58
59/**
60 * @defgroup RTEMSTestCaseRtemsSignalReqCatch spec:/rtems/signal/req/catch
61 *
62 * @ingroup RTEMSTestSuiteTestsuitesValidation0
63 * @ingroup RTEMSTestSuiteTestsuitesValidation1
64 *
65 * @{
66 */
67
68typedef enum {
69  RtemsSignalReqCatch_Pre_Handler_Invalid,
70  RtemsSignalReqCatch_Pre_Handler_Valid,
71  RtemsSignalReqCatch_Pre_Handler_NA
72} RtemsSignalReqCatch_Pre_Handler;
73
74typedef enum {
75  RtemsSignalReqCatch_Pre_Preempt_Yes,
76  RtemsSignalReqCatch_Pre_Preempt_No,
77  RtemsSignalReqCatch_Pre_Preempt_NA
78} RtemsSignalReqCatch_Pre_Preempt;
79
80typedef enum {
81  RtemsSignalReqCatch_Pre_Timeslice_Yes,
82  RtemsSignalReqCatch_Pre_Timeslice_No,
83  RtemsSignalReqCatch_Pre_Timeslice_NA
84} RtemsSignalReqCatch_Pre_Timeslice;
85
86typedef enum {
87  RtemsSignalReqCatch_Pre_ASR_Yes,
88  RtemsSignalReqCatch_Pre_ASR_No,
89  RtemsSignalReqCatch_Pre_ASR_NA
90} RtemsSignalReqCatch_Pre_ASR;
91
92typedef enum {
93  RtemsSignalReqCatch_Pre_IntLvl_Zero,
94  RtemsSignalReqCatch_Pre_IntLvl_Positive,
95  RtemsSignalReqCatch_Pre_IntLvl_NA
96} RtemsSignalReqCatch_Pre_IntLvl;
97
98typedef enum {
99  RtemsSignalReqCatch_Post_Status_Ok,
100  RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
101  RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
102  RtemsSignalReqCatch_Post_Status_NA
103} RtemsSignalReqCatch_Post_Status;
104
105typedef enum {
106  RtemsSignalReqCatch_Post_Send_New,
107  RtemsSignalReqCatch_Post_Send_NotDef,
108  RtemsSignalReqCatch_Post_Send_NA
109} RtemsSignalReqCatch_Post_Send;
110
111typedef enum {
112  RtemsSignalReqCatch_Post_Preempt_Yes,
113  RtemsSignalReqCatch_Post_Preempt_No,
114  RtemsSignalReqCatch_Post_Preempt_NA
115} RtemsSignalReqCatch_Post_Preempt;
116
117typedef enum {
118  RtemsSignalReqCatch_Post_Timeslice_Yes,
119  RtemsSignalReqCatch_Post_Timeslice_No,
120  RtemsSignalReqCatch_Post_Timeslice_NA
121} RtemsSignalReqCatch_Post_Timeslice;
122
123typedef enum {
124  RtemsSignalReqCatch_Post_ASR_Yes,
125  RtemsSignalReqCatch_Post_ASR_No,
126  RtemsSignalReqCatch_Post_ASR_NA
127} RtemsSignalReqCatch_Post_ASR;
128
129typedef enum {
130  RtemsSignalReqCatch_Post_IntLvl_Zero,
131  RtemsSignalReqCatch_Post_IntLvl_Positive,
132  RtemsSignalReqCatch_Post_IntLvl_NA
133} RtemsSignalReqCatch_Post_IntLvl;
134
135/**
136 * @brief Test context for spec:/rtems/signal/req/catch test case.
137 */
138typedef struct {
139  uint32_t default_handler_calls;
140
141  uint32_t handler_calls;
142
143  rtems_mode handler_mode;
144
145  rtems_mode normal_mode;
146
147  rtems_asr_entry handler;
148
149  rtems_mode mode;
150
151  rtems_status_code catch_status;
152
153  rtems_status_code send_status;
154
155  /**
156   * @brief This member defines the pre-condition states for the next action.
157   */
158  size_t pcs[ 5 ];
159
160  /**
161   * @brief This member indicates if the test action loop is currently
162   *   executed.
163   */
164  bool in_action_loop;
165} RtemsSignalReqCatch_Context;
166
167static RtemsSignalReqCatch_Context
168  RtemsSignalReqCatch_Instance;
169
170static const char * const RtemsSignalReqCatch_PreDesc_Handler[] = {
171  "Invalid",
172  "Valid",
173  "NA"
174};
175
176static const char * const RtemsSignalReqCatch_PreDesc_Preempt[] = {
177  "Yes",
178  "No",
179  "NA"
180};
181
182static const char * const RtemsSignalReqCatch_PreDesc_Timeslice[] = {
183  "Yes",
184  "No",
185  "NA"
186};
187
188static const char * const RtemsSignalReqCatch_PreDesc_ASR[] = {
189  "Yes",
190  "No",
191  "NA"
192};
193
194static const char * const RtemsSignalReqCatch_PreDesc_IntLvl[] = {
195  "Zero",
196  "Positive",
197  "NA"
198};
199
200static const char * const * const RtemsSignalReqCatch_PreDesc[] = {
201  RtemsSignalReqCatch_PreDesc_Handler,
202  RtemsSignalReqCatch_PreDesc_Preempt,
203  RtemsSignalReqCatch_PreDesc_Timeslice,
204  RtemsSignalReqCatch_PreDesc_ASR,
205  RtemsSignalReqCatch_PreDesc_IntLvl,
206  NULL
207};
208
209typedef RtemsSignalReqCatch_Context Context;
210
211static void DefaultHandler( rtems_signal_set signal_set )
212{
213  Context *ctx;
214
215  ctx = T_fixture_context();
216  ++ctx->default_handler_calls;
217
218  T_eq_u32( signal_set, 0xdeadbeef );
219}
220
221static void SignalHandler( rtems_signal_set signal_set )
222{
223  Context          *ctx;
224  rtems_status_code sc;
225
226  ctx = T_fixture_context();
227  ++ctx->handler_calls;
228
229  sc = rtems_task_mode(
230    RTEMS_DEFAULT_MODES,
231    RTEMS_CURRENT_MODE,
232    &ctx->handler_mode
233  );
234  T_rsc_success( sc );
235
236  T_eq_u32( signal_set, 0xdeadbeef );
237}
238
239static void CheckHandlerMode( Context *ctx, rtems_mode mask, rtems_mode mode )
240{
241  if ( ctx->catch_status == RTEMS_SUCCESSFUL && ctx->handler != NULL ) {
242    T_ne_u32( ctx->handler_mode, 0xffffffff );
243    T_eq_u32( ctx->handler_mode & mask, mode );
244  }
245}
246
247static void RtemsSignalReqCatch_Pre_Handler_Prepare(
248  RtemsSignalReqCatch_Context    *ctx,
249  RtemsSignalReqCatch_Pre_Handler state
250)
251{
252  switch ( state ) {
253    case RtemsSignalReqCatch_Pre_Handler_Invalid: {
254      /*
255       * The ``asr_handler`` parameter shall be NULL.
256       */
257      ctx->handler = NULL;
258      break;
259    }
260
261    case RtemsSignalReqCatch_Pre_Handler_Valid: {
262      /*
263       * The ``asr_handler`` parameter shall be a valid ASR handler.
264       */
265      ctx->handler = SignalHandler;
266      break;
267    }
268
269    case RtemsSignalReqCatch_Pre_Handler_NA:
270      break;
271  }
272}
273
274static void RtemsSignalReqCatch_Pre_Preempt_Prepare(
275  RtemsSignalReqCatch_Context    *ctx,
276  RtemsSignalReqCatch_Pre_Preempt state
277)
278{
279  switch ( state ) {
280    case RtemsSignalReqCatch_Pre_Preempt_Yes: {
281      /*
282       * The ``mode_set`` parameter shall specify that
283       * preemption is enabled.
284       */
285      #if defined(RTEMS_SMP)
286      if ( rtems_configuration_get_maximum_processors() == 1 ) {
287        ctx->normal_mode |= RTEMS_NO_PREEMPT;
288      }
289      #else
290      ctx->normal_mode |= RTEMS_NO_PREEMPT;
291      #endif
292      break;
293    }
294
295    case RtemsSignalReqCatch_Pre_Preempt_No: {
296      /*
297       * The ``mode_set`` parameter shall specify that
298       * preemption is disabled.
299       */
300      ctx->mode |= RTEMS_NO_PREEMPT;
301      break;
302    }
303
304    case RtemsSignalReqCatch_Pre_Preempt_NA:
305      break;
306  }
307}
308
309static void RtemsSignalReqCatch_Pre_Timeslice_Prepare(
310  RtemsSignalReqCatch_Context      *ctx,
311  RtemsSignalReqCatch_Pre_Timeslice state
312)
313{
314  switch ( state ) {
315    case RtemsSignalReqCatch_Pre_Timeslice_Yes: {
316      /*
317       * The ``mode_set`` parameter shall specify that
318       * timeslicing is enabled.
319       */
320      ctx->mode |= RTEMS_TIMESLICE;
321      break;
322    }
323
324    case RtemsSignalReqCatch_Pre_Timeslice_No: {
325      /*
326       * The ``mode_set`` parameter shall specify that
327       * timeslicing is disabled.
328       */
329      ctx->normal_mode |= RTEMS_TIMESLICE;
330      break;
331    }
332
333    case RtemsSignalReqCatch_Pre_Timeslice_NA:
334      break;
335  }
336}
337
338static void RtemsSignalReqCatch_Pre_ASR_Prepare(
339  RtemsSignalReqCatch_Context *ctx,
340  RtemsSignalReqCatch_Pre_ASR  state
341)
342{
343  switch ( state ) {
344    case RtemsSignalReqCatch_Pre_ASR_Yes: {
345      /*
346       * The ``mode_set`` parameter shall specify that
347       * ASR processing is enabled.
348       */
349      /* We cannot disable ASR processing at normal task level for this test */
350      break;
351    }
352
353    case RtemsSignalReqCatch_Pre_ASR_No: {
354      /*
355       * The ``mode_set`` parameter shall specify that
356       * ASR processing is disabled.
357       */
358      ctx->mode |= RTEMS_NO_ASR;
359      break;
360    }
361
362    case RtemsSignalReqCatch_Pre_ASR_NA:
363      break;
364  }
365}
366
367static void RtemsSignalReqCatch_Pre_IntLvl_Prepare(
368  RtemsSignalReqCatch_Context   *ctx,
369  RtemsSignalReqCatch_Pre_IntLvl state
370)
371{
372  switch ( state ) {
373    case RtemsSignalReqCatch_Pre_IntLvl_Zero: {
374      /*
375       * The ``mode_set`` parameter shall specify an interrupt
376       * level of zero.
377       */
378      #if !defined(RTEMS_SMP) && CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
379      ctx->normal_mode |= RTEMS_INTERRUPT_LEVEL( 1 );
380      #endif
381      break;
382    }
383
384    case RtemsSignalReqCatch_Pre_IntLvl_Positive: {
385      /*
386       * The ``mode_set`` parameter shall specify a positive
387       * interrupt level.
388       */
389      ctx->mode |= RTEMS_INTERRUPT_LEVEL( 1 );
390      break;
391    }
392
393    case RtemsSignalReqCatch_Pre_IntLvl_NA:
394      break;
395  }
396}
397
398static void RtemsSignalReqCatch_Post_Status_Check(
399  RtemsSignalReqCatch_Context    *ctx,
400  RtemsSignalReqCatch_Post_Status state
401)
402{
403  switch ( state ) {
404    case RtemsSignalReqCatch_Post_Status_Ok: {
405      /*
406       * The return status of rtems_signal_catch() shall be
407       * RTEMS_SUCCESSFUL.
408       */
409      T_rsc_success( ctx->catch_status );
410      break;
411    }
412
413    case RtemsSignalReqCatch_Post_Status_NotImplNoPreempt: {
414      /*
415       * Where the system is configured with SMP support, if the scheduler does
416       * not support the no-preempt mode, then the return status of
417       * rtems_signal_catch() shall be RTEMS_NOT_IMPLEMENTED,
418       * otherwise the return status shall be RTEMS_SUCCESSFUL.
419       */
420      #if defined(RTEMS_SMP)
421      if ( rtems_configuration_get_maximum_processors() > 1 ) {
422        T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
423      } else {
424        T_rsc_success( ctx->catch_status );
425      }
426      #else
427      T_rsc_success( ctx->catch_status );
428      #endif
429      break;
430    }
431
432    case RtemsSignalReqCatch_Post_Status_NotImplIntLvl: {
433      /*
434       * Where the system is configured with SMP support and the configured
435       * processor maximum is greater than one, or the CPU port enabled robust
436       * thread dispatching, the return status of rtems_signal_catch() shall be
437       * RTEMS_NOT_IMPLEMENTED, otherwise the return status
438       * shall be RTEMS_SUCCESSFUL.
439       */
440      #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
441      T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
442      #elif defined(RTEMS_SMP)
443      if ( rtems_configuration_get_maximum_processors() > 1 ) {
444        T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
445      } else {
446        T_rsc_success( ctx->catch_status );
447      }
448      #else
449      T_rsc_success( ctx->catch_status );
450      #endif
451      break;
452    }
453
454    case RtemsSignalReqCatch_Post_Status_NA:
455      break;
456  }
457}
458
459static void RtemsSignalReqCatch_Post_Send_Check(
460  RtemsSignalReqCatch_Context  *ctx,
461  RtemsSignalReqCatch_Post_Send state
462)
463{
464  switch ( state ) {
465    case RtemsSignalReqCatch_Post_Send_New: {
466      /*
467       * When a signal set is sent to the caller of rtems_signal_catch() and the
468       * call was successful, the ASR processing shall be done with the specified
469       * handler, otherwise the ASR information of the caller shall be unchanged.
470       */
471      T_rsc_success( ctx->send_status );
472
473      if ( ctx->catch_status == RTEMS_SUCCESSFUL ) {
474        T_eq_u32( ctx->default_handler_calls, 0 );
475        T_eq_u32( ctx->handler_calls, 1 );
476        T_ne_u32( ctx->handler_mode, 0xffffffff );
477      } else {
478        T_eq_u32( ctx->default_handler_calls, 1 );
479        T_eq_u32( ctx->handler_calls, 0 );
480        T_eq_u32( ctx->handler_mode, 0xffffffff );
481      }
482      break;
483    }
484
485    case RtemsSignalReqCatch_Post_Send_NotDef: {
486      /*
487       * When a signal set is sent to the caller of rtems_signal_catch() and the
488       * call was successful, the ASR processing shall be deactivated and all
489       * pending signals shall be cleared, otherwise the ASR information of the
490       * caller shall be unchanged.
491       */
492      if ( ctx->catch_status == RTEMS_SUCCESSFUL ) {
493        T_rsc( ctx->send_status, RTEMS_NOT_DEFINED );
494        T_eq_u32( ctx->default_handler_calls, 0 );
495        T_eq_u32( ctx->handler_calls, 0 );
496        T_eq_u32( ctx->handler_mode, 0xffffffff );
497      } else {
498        T_rsc_success( ctx->send_status );
499        T_eq_u32( ctx->default_handler_calls, 1 );
500        T_eq_u32( ctx->handler_calls, 0 );
501        T_eq_u32( ctx->handler_mode, 0xffffffff );
502      }
503      break;
504    }
505
506    case RtemsSignalReqCatch_Post_Send_NA:
507      break;
508  }
509}
510
511static void RtemsSignalReqCatch_Post_Preempt_Check(
512  RtemsSignalReqCatch_Context     *ctx,
513  RtemsSignalReqCatch_Post_Preempt state
514)
515{
516  switch ( state ) {
517    case RtemsSignalReqCatch_Post_Preempt_Yes: {
518      /*
519       * When a signal set is sent to the caller of rtems_signal_catch() and the
520       * call with a valid handler was successful, the ASR processing shall be
521       * done with preemption enabled.
522       */
523      CheckHandlerMode( ctx, RTEMS_PREEMPT_MASK, RTEMS_PREEMPT );
524      break;
525    }
526
527    case RtemsSignalReqCatch_Post_Preempt_No: {
528      /*
529       * When a signal set is sent to the caller of rtems_signal_catch() and the
530       * call with a valid handler was successful, the ASR processing shall be
531       * done with preemption disabled.
532       */
533      CheckHandlerMode( ctx, RTEMS_PREEMPT_MASK, RTEMS_NO_PREEMPT );
534      break;
535    }
536
537    case RtemsSignalReqCatch_Post_Preempt_NA:
538      break;
539  }
540}
541
542static void RtemsSignalReqCatch_Post_Timeslice_Check(
543  RtemsSignalReqCatch_Context       *ctx,
544  RtemsSignalReqCatch_Post_Timeslice state
545)
546{
547  switch ( state ) {
548    case RtemsSignalReqCatch_Post_Timeslice_Yes: {
549      /*
550       * When a signal set is sent to the caller of rtems_signal_catch() and the
551       * call with a valid handler was successful, the ASR processing shall be
552       * done with timeslicing enabled.
553       */
554      CheckHandlerMode( ctx, RTEMS_TIMESLICE_MASK, RTEMS_TIMESLICE );
555      break;
556    }
557
558    case RtemsSignalReqCatch_Post_Timeslice_No: {
559      /*
560       * When a signal set is sent to the caller of rtems_signal_catch() and the
561       * call with a valid handler was successful, the ASR processing shall be
562       * done with timeslicing disabled.
563       */
564      CheckHandlerMode( ctx, RTEMS_TIMESLICE_MASK, RTEMS_NO_TIMESLICE );
565      break;
566    }
567
568    case RtemsSignalReqCatch_Post_Timeslice_NA:
569      break;
570  }
571}
572
573static void RtemsSignalReqCatch_Post_ASR_Check(
574  RtemsSignalReqCatch_Context *ctx,
575  RtemsSignalReqCatch_Post_ASR state
576)
577{
578  switch ( state ) {
579    case RtemsSignalReqCatch_Post_ASR_Yes: {
580      /*
581       * When a signal set is sent to the caller of rtems_signal_catch() and the
582       * call with a valid handler was successful, the ASR processing shall be
583       * done with ASR processing enabled.
584       */
585      CheckHandlerMode( ctx, RTEMS_ASR_MASK, RTEMS_ASR );
586      break;
587    }
588
589    case RtemsSignalReqCatch_Post_ASR_No: {
590      /*
591       * When a signal set is sent to the caller of rtems_signal_catch() and the
592       * call with a valid handler was successful, the ASR processing shall be
593       * done with ASR processing disabled.
594       */
595      CheckHandlerMode( ctx, RTEMS_ASR_MASK, RTEMS_NO_ASR );
596      break;
597    }
598
599    case RtemsSignalReqCatch_Post_ASR_NA:
600      break;
601  }
602}
603
604static void RtemsSignalReqCatch_Post_IntLvl_Check(
605  RtemsSignalReqCatch_Context    *ctx,
606  RtemsSignalReqCatch_Post_IntLvl state
607)
608{
609  switch ( state ) {
610    case RtemsSignalReqCatch_Post_IntLvl_Zero: {
611      /*
612       * When a signal set is sent to the caller of rtems_signal_catch() and the
613       * call with a valid handler was successful, the ASR processing shall be
614       * done with interrupts enabled.
615       */
616      CheckHandlerMode( ctx, RTEMS_INTERRUPT_MASK, RTEMS_INTERRUPT_LEVEL( 0 ) );
617      break;
618    }
619
620    case RtemsSignalReqCatch_Post_IntLvl_Positive: {
621      /*
622       * When a signal set is sent to the caller of rtems_signal_catch() and the
623       * call with a valid handler was successful, the ASR processing shall be
624       * done with interrupts disabled according to the specified interrupt level.
625       */
626      CheckHandlerMode( ctx, RTEMS_INTERRUPT_MASK, RTEMS_INTERRUPT_LEVEL( 1 ) );
627      break;
628    }
629
630    case RtemsSignalReqCatch_Post_IntLvl_NA:
631      break;
632  }
633}
634
635static void RtemsSignalReqCatch_Teardown( RtemsSignalReqCatch_Context *ctx )
636{
637  rtems_status_code sc;
638
639  sc = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
640  T_rsc_success( sc );
641}
642
643static void RtemsSignalReqCatch_Teardown_Wrap( void *arg )
644{
645  RtemsSignalReqCatch_Context *ctx;
646
647  ctx = arg;
648  ctx->in_action_loop = false;
649  RtemsSignalReqCatch_Teardown( ctx );
650}
651
652static size_t RtemsSignalReqCatch_Scope( void *arg, char *buf, size_t n )
653{
654  RtemsSignalReqCatch_Context *ctx;
655
656  ctx = arg;
657
658  if ( ctx->in_action_loop ) {
659    return T_get_scope( RtemsSignalReqCatch_PreDesc, buf, n, ctx->pcs );
660  }
661
662  return 0;
663}
664
665static T_fixture RtemsSignalReqCatch_Fixture = {
666  .setup = NULL,
667  .stop = NULL,
668  .teardown = RtemsSignalReqCatch_Teardown_Wrap,
669  .scope = RtemsSignalReqCatch_Scope,
670  .initial_context = &RtemsSignalReqCatch_Instance
671};
672
673static const uint8_t RtemsSignalReqCatch_TransitionMap[][ 6 ] = {
674  {
675    RtemsSignalReqCatch_Post_Status_Ok,
676    RtemsSignalReqCatch_Post_Send_NotDef,
677    RtemsSignalReqCatch_Post_Preempt_Yes,
678    RtemsSignalReqCatch_Post_Timeslice_Yes,
679    RtemsSignalReqCatch_Post_ASR_Yes,
680    RtemsSignalReqCatch_Post_IntLvl_Zero
681  }, {
682    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
683    RtemsSignalReqCatch_Post_Send_NotDef,
684    RtemsSignalReqCatch_Post_Preempt_Yes,
685    RtemsSignalReqCatch_Post_Timeslice_Yes,
686    RtemsSignalReqCatch_Post_ASR_Yes,
687    RtemsSignalReqCatch_Post_IntLvl_Positive
688  }, {
689    RtemsSignalReqCatch_Post_Status_Ok,
690    RtemsSignalReqCatch_Post_Send_NotDef,
691    RtemsSignalReqCatch_Post_Preempt_Yes,
692    RtemsSignalReqCatch_Post_Timeslice_Yes,
693    RtemsSignalReqCatch_Post_ASR_No,
694    RtemsSignalReqCatch_Post_IntLvl_Zero
695  }, {
696    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
697    RtemsSignalReqCatch_Post_Send_NotDef,
698    RtemsSignalReqCatch_Post_Preempt_Yes,
699    RtemsSignalReqCatch_Post_Timeslice_Yes,
700    RtemsSignalReqCatch_Post_ASR_No,
701    RtemsSignalReqCatch_Post_IntLvl_Positive
702  }, {
703    RtemsSignalReqCatch_Post_Status_Ok,
704    RtemsSignalReqCatch_Post_Send_NotDef,
705    RtemsSignalReqCatch_Post_Preempt_Yes,
706    RtemsSignalReqCatch_Post_Timeslice_No,
707    RtemsSignalReqCatch_Post_ASR_Yes,
708    RtemsSignalReqCatch_Post_IntLvl_Zero
709  }, {
710    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
711    RtemsSignalReqCatch_Post_Send_NotDef,
712    RtemsSignalReqCatch_Post_Preempt_Yes,
713    RtemsSignalReqCatch_Post_Timeslice_No,
714    RtemsSignalReqCatch_Post_ASR_Yes,
715    RtemsSignalReqCatch_Post_IntLvl_Positive
716  }, {
717    RtemsSignalReqCatch_Post_Status_Ok,
718    RtemsSignalReqCatch_Post_Send_NotDef,
719    RtemsSignalReqCatch_Post_Preempt_Yes,
720    RtemsSignalReqCatch_Post_Timeslice_No,
721    RtemsSignalReqCatch_Post_ASR_No,
722    RtemsSignalReqCatch_Post_IntLvl_Zero
723  }, {
724    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
725    RtemsSignalReqCatch_Post_Send_NotDef,
726    RtemsSignalReqCatch_Post_Preempt_Yes,
727    RtemsSignalReqCatch_Post_Timeslice_No,
728    RtemsSignalReqCatch_Post_ASR_No,
729    RtemsSignalReqCatch_Post_IntLvl_Positive
730  }, {
731    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
732    RtemsSignalReqCatch_Post_Send_NotDef,
733    RtemsSignalReqCatch_Post_Preempt_No,
734    RtemsSignalReqCatch_Post_Timeslice_Yes,
735    RtemsSignalReqCatch_Post_ASR_Yes,
736    RtemsSignalReqCatch_Post_IntLvl_Zero
737  }, {
738    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
739    RtemsSignalReqCatch_Post_Send_NotDef,
740    RtemsSignalReqCatch_Post_Preempt_No,
741    RtemsSignalReqCatch_Post_Timeslice_Yes,
742    RtemsSignalReqCatch_Post_ASR_Yes,
743    RtemsSignalReqCatch_Post_IntLvl_Positive
744  }, {
745    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
746    RtemsSignalReqCatch_Post_Send_NotDef,
747    RtemsSignalReqCatch_Post_Preempt_No,
748    RtemsSignalReqCatch_Post_Timeslice_Yes,
749    RtemsSignalReqCatch_Post_ASR_No,
750    RtemsSignalReqCatch_Post_IntLvl_Zero
751  }, {
752    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
753    RtemsSignalReqCatch_Post_Send_NotDef,
754    RtemsSignalReqCatch_Post_Preempt_No,
755    RtemsSignalReqCatch_Post_Timeslice_Yes,
756    RtemsSignalReqCatch_Post_ASR_No,
757    RtemsSignalReqCatch_Post_IntLvl_Positive
758  }, {
759    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
760    RtemsSignalReqCatch_Post_Send_NotDef,
761    RtemsSignalReqCatch_Post_Preempt_No,
762    RtemsSignalReqCatch_Post_Timeslice_No,
763    RtemsSignalReqCatch_Post_ASR_Yes,
764    RtemsSignalReqCatch_Post_IntLvl_Zero
765  }, {
766    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
767    RtemsSignalReqCatch_Post_Send_NotDef,
768    RtemsSignalReqCatch_Post_Preempt_No,
769    RtemsSignalReqCatch_Post_Timeslice_No,
770    RtemsSignalReqCatch_Post_ASR_Yes,
771    RtemsSignalReqCatch_Post_IntLvl_Positive
772  }, {
773    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
774    RtemsSignalReqCatch_Post_Send_NotDef,
775    RtemsSignalReqCatch_Post_Preempt_No,
776    RtemsSignalReqCatch_Post_Timeslice_No,
777    RtemsSignalReqCatch_Post_ASR_No,
778    RtemsSignalReqCatch_Post_IntLvl_Zero
779  }, {
780    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
781    RtemsSignalReqCatch_Post_Send_NotDef,
782    RtemsSignalReqCatch_Post_Preempt_No,
783    RtemsSignalReqCatch_Post_Timeslice_No,
784    RtemsSignalReqCatch_Post_ASR_No,
785    RtemsSignalReqCatch_Post_IntLvl_Positive
786  }, {
787    RtemsSignalReqCatch_Post_Status_Ok,
788    RtemsSignalReqCatch_Post_Send_New,
789    RtemsSignalReqCatch_Post_Preempt_Yes,
790    RtemsSignalReqCatch_Post_Timeslice_Yes,
791    RtemsSignalReqCatch_Post_ASR_Yes,
792    RtemsSignalReqCatch_Post_IntLvl_Zero
793  }, {
794    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
795    RtemsSignalReqCatch_Post_Send_New,
796    RtemsSignalReqCatch_Post_Preempt_Yes,
797    RtemsSignalReqCatch_Post_Timeslice_Yes,
798    RtemsSignalReqCatch_Post_ASR_Yes,
799    RtemsSignalReqCatch_Post_IntLvl_Positive
800  }, {
801    RtemsSignalReqCatch_Post_Status_Ok,
802    RtemsSignalReqCatch_Post_Send_New,
803    RtemsSignalReqCatch_Post_Preempt_Yes,
804    RtemsSignalReqCatch_Post_Timeslice_Yes,
805    RtemsSignalReqCatch_Post_ASR_No,
806    RtemsSignalReqCatch_Post_IntLvl_Zero
807  }, {
808    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
809    RtemsSignalReqCatch_Post_Send_New,
810    RtemsSignalReqCatch_Post_Preempt_Yes,
811    RtemsSignalReqCatch_Post_Timeslice_Yes,
812    RtemsSignalReqCatch_Post_ASR_No,
813    RtemsSignalReqCatch_Post_IntLvl_Positive
814  }, {
815    RtemsSignalReqCatch_Post_Status_Ok,
816    RtemsSignalReqCatch_Post_Send_New,
817    RtemsSignalReqCatch_Post_Preempt_Yes,
818    RtemsSignalReqCatch_Post_Timeslice_No,
819    RtemsSignalReqCatch_Post_ASR_Yes,
820    RtemsSignalReqCatch_Post_IntLvl_Zero
821  }, {
822    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
823    RtemsSignalReqCatch_Post_Send_New,
824    RtemsSignalReqCatch_Post_Preempt_Yes,
825    RtemsSignalReqCatch_Post_Timeslice_No,
826    RtemsSignalReqCatch_Post_ASR_Yes,
827    RtemsSignalReqCatch_Post_IntLvl_Positive
828  }, {
829    RtemsSignalReqCatch_Post_Status_Ok,
830    RtemsSignalReqCatch_Post_Send_New,
831    RtemsSignalReqCatch_Post_Preempt_Yes,
832    RtemsSignalReqCatch_Post_Timeslice_No,
833    RtemsSignalReqCatch_Post_ASR_No,
834    RtemsSignalReqCatch_Post_IntLvl_Zero
835  }, {
836    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
837    RtemsSignalReqCatch_Post_Send_New,
838    RtemsSignalReqCatch_Post_Preempt_Yes,
839    RtemsSignalReqCatch_Post_Timeslice_No,
840    RtemsSignalReqCatch_Post_ASR_No,
841    RtemsSignalReqCatch_Post_IntLvl_Positive
842  }, {
843    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
844    RtemsSignalReqCatch_Post_Send_New,
845    RtemsSignalReqCatch_Post_Preempt_No,
846    RtemsSignalReqCatch_Post_Timeslice_Yes,
847    RtemsSignalReqCatch_Post_ASR_Yes,
848    RtemsSignalReqCatch_Post_IntLvl_Zero
849  }, {
850    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
851    RtemsSignalReqCatch_Post_Send_New,
852    RtemsSignalReqCatch_Post_Preempt_No,
853    RtemsSignalReqCatch_Post_Timeslice_Yes,
854    RtemsSignalReqCatch_Post_ASR_Yes,
855    RtemsSignalReqCatch_Post_IntLvl_Positive
856  }, {
857    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
858    RtemsSignalReqCatch_Post_Send_New,
859    RtemsSignalReqCatch_Post_Preempt_No,
860    RtemsSignalReqCatch_Post_Timeslice_Yes,
861    RtemsSignalReqCatch_Post_ASR_No,
862    RtemsSignalReqCatch_Post_IntLvl_Zero
863  }, {
864    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
865    RtemsSignalReqCatch_Post_Send_New,
866    RtemsSignalReqCatch_Post_Preempt_No,
867    RtemsSignalReqCatch_Post_Timeslice_Yes,
868    RtemsSignalReqCatch_Post_ASR_No,
869    RtemsSignalReqCatch_Post_IntLvl_Positive
870  }, {
871    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
872    RtemsSignalReqCatch_Post_Send_New,
873    RtemsSignalReqCatch_Post_Preempt_No,
874    RtemsSignalReqCatch_Post_Timeslice_No,
875    RtemsSignalReqCatch_Post_ASR_Yes,
876    RtemsSignalReqCatch_Post_IntLvl_Zero
877  }, {
878    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
879    RtemsSignalReqCatch_Post_Send_New,
880    RtemsSignalReqCatch_Post_Preempt_No,
881    RtemsSignalReqCatch_Post_Timeslice_No,
882    RtemsSignalReqCatch_Post_ASR_Yes,
883    RtemsSignalReqCatch_Post_IntLvl_Positive
884  }, {
885    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
886    RtemsSignalReqCatch_Post_Send_New,
887    RtemsSignalReqCatch_Post_Preempt_No,
888    RtemsSignalReqCatch_Post_Timeslice_No,
889    RtemsSignalReqCatch_Post_ASR_No,
890    RtemsSignalReqCatch_Post_IntLvl_Zero
891  }, {
892    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
893    RtemsSignalReqCatch_Post_Send_New,
894    RtemsSignalReqCatch_Post_Preempt_No,
895    RtemsSignalReqCatch_Post_Timeslice_No,
896    RtemsSignalReqCatch_Post_ASR_No,
897    RtemsSignalReqCatch_Post_IntLvl_Positive
898  }
899};
900
901static const struct {
902  uint8_t Skip : 1;
903  uint8_t Pre_Handler_NA : 1;
904  uint8_t Pre_Preempt_NA : 1;
905  uint8_t Pre_Timeslice_NA : 1;
906  uint8_t Pre_ASR_NA : 1;
907  uint8_t Pre_IntLvl_NA : 1;
908} RtemsSignalReqCatch_TransitionInfo[] = {
909  {
910    0, 0, 0, 0, 0, 0
911  }, {
912    0, 0, 0, 0, 0, 0
913  }, {
914    0, 0, 0, 0, 0, 0
915  }, {
916    0, 0, 0, 0, 0, 0
917  }, {
918    0, 0, 0, 0, 0, 0
919  }, {
920    0, 0, 0, 0, 0, 0
921  }, {
922    0, 0, 0, 0, 0, 0
923  }, {
924    0, 0, 0, 0, 0, 0
925  }, {
926    0, 0, 0, 0, 0, 0
927  }, {
928    0, 0, 0, 0, 0, 0
929  }, {
930    0, 0, 0, 0, 0, 0
931  }, {
932    0, 0, 0, 0, 0, 0
933  }, {
934    0, 0, 0, 0, 0, 0
935  }, {
936    0, 0, 0, 0, 0, 0
937  }, {
938    0, 0, 0, 0, 0, 0
939  }, {
940    0, 0, 0, 0, 0, 0
941  }, {
942    0, 0, 0, 0, 0, 0
943  }, {
944    0, 0, 0, 0, 0, 0
945  }, {
946    0, 0, 0, 0, 0, 0
947  }, {
948    0, 0, 0, 0, 0, 0
949  }, {
950    0, 0, 0, 0, 0, 0
951  }, {
952    0, 0, 0, 0, 0, 0
953  }, {
954    0, 0, 0, 0, 0, 0
955  }, {
956    0, 0, 0, 0, 0, 0
957  }, {
958    0, 0, 0, 0, 0, 0
959  }, {
960    0, 0, 0, 0, 0, 0
961  }, {
962    0, 0, 0, 0, 0, 0
963  }, {
964    0, 0, 0, 0, 0, 0
965  }, {
966    0, 0, 0, 0, 0, 0
967  }, {
968    0, 0, 0, 0, 0, 0
969  }, {
970    0, 0, 0, 0, 0, 0
971  }, {
972    0, 0, 0, 0, 0, 0
973  }
974};
975
976static void RtemsSignalReqCatch_Prepare( RtemsSignalReqCatch_Context *ctx )
977{
978  rtems_status_code sc;
979
980  ctx->default_handler_calls = 0;
981  ctx->handler_calls = 0;
982  ctx->handler_mode = 0xffffffff;
983  ctx->normal_mode = RTEMS_DEFAULT_MODES;
984  ctx->handler = NULL;
985  ctx->mode = RTEMS_DEFAULT_MODES;
986
987  sc = rtems_signal_catch( DefaultHandler, RTEMS_NO_ASR );
988  T_rsc_success( sc );
989}
990
991static void RtemsSignalReqCatch_Action( RtemsSignalReqCatch_Context *ctx )
992{
993  rtems_status_code sc;
994  rtems_mode        mode;
995
996  ctx->catch_status = rtems_signal_catch( ctx->handler, ctx->mode );
997
998  sc = rtems_task_mode( ctx->normal_mode, RTEMS_ALL_MODE_MASKS, &mode );
999  T_rsc_success( sc );
1000
1001  ctx->send_status = rtems_signal_send( RTEMS_SELF, 0xdeadbeef );
1002
1003  sc = rtems_task_mode( mode, RTEMS_ALL_MODE_MASKS, &mode );
1004  T_rsc_success( sc );
1005}
1006
1007/**
1008 * @fn void T_case_body_RtemsSignalReqCatch( void )
1009 */
1010T_TEST_CASE_FIXTURE( RtemsSignalReqCatch, &RtemsSignalReqCatch_Fixture )
1011{
1012  RtemsSignalReqCatch_Context *ctx;
1013  size_t index;
1014
1015  ctx = T_fixture_context();
1016  ctx->in_action_loop = true;
1017  index = 0;
1018
1019  for (
1020    ctx->pcs[ 0 ] = RtemsSignalReqCatch_Pre_Handler_Invalid;
1021    ctx->pcs[ 0 ] < RtemsSignalReqCatch_Pre_Handler_NA;
1022    ++ctx->pcs[ 0 ]
1023  ) {
1024    if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Handler_NA ) {
1025      ctx->pcs[ 0 ] = RtemsSignalReqCatch_Pre_Handler_NA;
1026      index += ( RtemsSignalReqCatch_Pre_Handler_NA - 1 )
1027        * RtemsSignalReqCatch_Pre_Preempt_NA
1028        * RtemsSignalReqCatch_Pre_Timeslice_NA
1029        * RtemsSignalReqCatch_Pre_ASR_NA
1030        * RtemsSignalReqCatch_Pre_IntLvl_NA;
1031    }
1032
1033    for (
1034      ctx->pcs[ 1 ] = RtemsSignalReqCatch_Pre_Preempt_Yes;
1035      ctx->pcs[ 1 ] < RtemsSignalReqCatch_Pre_Preempt_NA;
1036      ++ctx->pcs[ 1 ]
1037    ) {
1038      if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Preempt_NA ) {
1039        ctx->pcs[ 1 ] = RtemsSignalReqCatch_Pre_Preempt_NA;
1040        index += ( RtemsSignalReqCatch_Pre_Preempt_NA - 1 )
1041          * RtemsSignalReqCatch_Pre_Timeslice_NA
1042          * RtemsSignalReqCatch_Pre_ASR_NA
1043          * RtemsSignalReqCatch_Pre_IntLvl_NA;
1044      }
1045
1046      for (
1047        ctx->pcs[ 2 ] = RtemsSignalReqCatch_Pre_Timeslice_Yes;
1048        ctx->pcs[ 2 ] < RtemsSignalReqCatch_Pre_Timeslice_NA;
1049        ++ctx->pcs[ 2 ]
1050      ) {
1051        if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Timeslice_NA ) {
1052          ctx->pcs[ 2 ] = RtemsSignalReqCatch_Pre_Timeslice_NA;
1053          index += ( RtemsSignalReqCatch_Pre_Timeslice_NA - 1 )
1054            * RtemsSignalReqCatch_Pre_ASR_NA
1055            * RtemsSignalReqCatch_Pre_IntLvl_NA;
1056        }
1057
1058        for (
1059          ctx->pcs[ 3 ] = RtemsSignalReqCatch_Pre_ASR_Yes;
1060          ctx->pcs[ 3 ] < RtemsSignalReqCatch_Pre_ASR_NA;
1061          ++ctx->pcs[ 3 ]
1062        ) {
1063          if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_ASR_NA ) {
1064            ctx->pcs[ 3 ] = RtemsSignalReqCatch_Pre_ASR_NA;
1065            index += ( RtemsSignalReqCatch_Pre_ASR_NA - 1 )
1066              * RtemsSignalReqCatch_Pre_IntLvl_NA;
1067          }
1068
1069          for (
1070            ctx->pcs[ 4 ] = RtemsSignalReqCatch_Pre_IntLvl_Zero;
1071            ctx->pcs[ 4 ] < RtemsSignalReqCatch_Pre_IntLvl_NA;
1072            ++ctx->pcs[ 4 ]
1073          ) {
1074            if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_IntLvl_NA ) {
1075              ctx->pcs[ 4 ] = RtemsSignalReqCatch_Pre_IntLvl_NA;
1076              index += ( RtemsSignalReqCatch_Pre_IntLvl_NA - 1 );
1077            }
1078
1079            if ( RtemsSignalReqCatch_TransitionInfo[ index ].Skip ) {
1080              ++index;
1081              continue;
1082            }
1083
1084            RtemsSignalReqCatch_Prepare( ctx );
1085            RtemsSignalReqCatch_Pre_Handler_Prepare( ctx, ctx->pcs[ 0 ] );
1086            RtemsSignalReqCatch_Pre_Preempt_Prepare( ctx, ctx->pcs[ 1 ] );
1087            RtemsSignalReqCatch_Pre_Timeslice_Prepare( ctx, ctx->pcs[ 2 ] );
1088            RtemsSignalReqCatch_Pre_ASR_Prepare( ctx, ctx->pcs[ 3 ] );
1089            RtemsSignalReqCatch_Pre_IntLvl_Prepare( ctx, ctx->pcs[ 4 ] );
1090            RtemsSignalReqCatch_Action( ctx );
1091            RtemsSignalReqCatch_Post_Status_Check(
1092              ctx,
1093              RtemsSignalReqCatch_TransitionMap[ index ][ 0 ]
1094            );
1095            RtemsSignalReqCatch_Post_Send_Check(
1096              ctx,
1097              RtemsSignalReqCatch_TransitionMap[ index ][ 1 ]
1098            );
1099            RtemsSignalReqCatch_Post_Preempt_Check(
1100              ctx,
1101              RtemsSignalReqCatch_TransitionMap[ index ][ 2 ]
1102            );
1103            RtemsSignalReqCatch_Post_Timeslice_Check(
1104              ctx,
1105              RtemsSignalReqCatch_TransitionMap[ index ][ 3 ]
1106            );
1107            RtemsSignalReqCatch_Post_ASR_Check(
1108              ctx,
1109              RtemsSignalReqCatch_TransitionMap[ index ][ 4 ]
1110            );
1111            RtemsSignalReqCatch_Post_IntLvl_Check(
1112              ctx,
1113              RtemsSignalReqCatch_TransitionMap[ index ][ 5 ]
1114            );
1115            ++index;
1116          }
1117        }
1118      }
1119    }
1120  }
1121}
1122
1123/** @} */
Note: See TracBrowser for help on using the repository browser.