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

Last change on this file since c0c4b8b was c0c4b8b, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 2, 2021 at 6:54:17 AM

validation: Format comment blocks

  • Property mode set to 100644
File size: 32.1 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 preemption is enabled.
283       */
284      #if defined(RTEMS_SMP)
285      if ( rtems_configuration_get_maximum_processors() == 1 ) {
286        ctx->normal_mode |= RTEMS_NO_PREEMPT;
287      }
288      #else
289      ctx->normal_mode |= RTEMS_NO_PREEMPT;
290      #endif
291      break;
292    }
293
294    case RtemsSignalReqCatch_Pre_Preempt_No: {
295      /*
296       * The ``mode_set`` parameter shall specify that preemption is disabled.
297       */
298      ctx->mode |= RTEMS_NO_PREEMPT;
299      break;
300    }
301
302    case RtemsSignalReqCatch_Pre_Preempt_NA:
303      break;
304  }
305}
306
307static void RtemsSignalReqCatch_Pre_Timeslice_Prepare(
308  RtemsSignalReqCatch_Context      *ctx,
309  RtemsSignalReqCatch_Pre_Timeslice state
310)
311{
312  switch ( state ) {
313    case RtemsSignalReqCatch_Pre_Timeslice_Yes: {
314      /*
315       * The ``mode_set`` parameter shall specify that timeslicing is enabled.
316       */
317      ctx->mode |= RTEMS_TIMESLICE;
318      break;
319    }
320
321    case RtemsSignalReqCatch_Pre_Timeslice_No: {
322      /*
323       * The ``mode_set`` parameter shall specify that timeslicing is disabled.
324       */
325      ctx->normal_mode |= RTEMS_TIMESLICE;
326      break;
327    }
328
329    case RtemsSignalReqCatch_Pre_Timeslice_NA:
330      break;
331  }
332}
333
334static void RtemsSignalReqCatch_Pre_ASR_Prepare(
335  RtemsSignalReqCatch_Context *ctx,
336  RtemsSignalReqCatch_Pre_ASR  state
337)
338{
339  switch ( state ) {
340    case RtemsSignalReqCatch_Pre_ASR_Yes: {
341      /*
342       * The ``mode_set`` parameter shall specify that ASR processing is
343       * enabled.
344       */
345      /* We cannot disable ASR processing at normal task level for this test */
346      break;
347    }
348
349    case RtemsSignalReqCatch_Pre_ASR_No: {
350      /*
351       * The ``mode_set`` parameter shall specify that ASR processing is
352       * disabled.
353       */
354      ctx->mode |= RTEMS_NO_ASR;
355      break;
356    }
357
358    case RtemsSignalReqCatch_Pre_ASR_NA:
359      break;
360  }
361}
362
363static void RtemsSignalReqCatch_Pre_IntLvl_Prepare(
364  RtemsSignalReqCatch_Context   *ctx,
365  RtemsSignalReqCatch_Pre_IntLvl state
366)
367{
368  switch ( state ) {
369    case RtemsSignalReqCatch_Pre_IntLvl_Zero: {
370      /*
371       * The ``mode_set`` parameter shall specify an interrupt level of zero.
372       */
373      #if !defined(RTEMS_SMP) && CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
374      ctx->normal_mode |= RTEMS_INTERRUPT_LEVEL( 1 );
375      #endif
376      break;
377    }
378
379    case RtemsSignalReqCatch_Pre_IntLvl_Positive: {
380      /*
381       * The ``mode_set`` parameter shall specify a positive interrupt level.
382       */
383      ctx->mode |= RTEMS_INTERRUPT_LEVEL( 1 );
384      break;
385    }
386
387    case RtemsSignalReqCatch_Pre_IntLvl_NA:
388      break;
389  }
390}
391
392static void RtemsSignalReqCatch_Post_Status_Check(
393  RtemsSignalReqCatch_Context    *ctx,
394  RtemsSignalReqCatch_Post_Status state
395)
396{
397  switch ( state ) {
398    case RtemsSignalReqCatch_Post_Status_Ok: {
399      /*
400       * The return status of rtems_signal_catch() shall be RTEMS_SUCCESSFUL.
401       */
402      T_rsc_success( ctx->catch_status );
403      break;
404    }
405
406    case RtemsSignalReqCatch_Post_Status_NotImplNoPreempt: {
407      /*
408       * Where the system is configured with SMP support, if the scheduler does
409       * not support the no-preempt mode, then the return status of
410       * rtems_signal_catch() shall be RTEMS_NOT_IMPLEMENTED, otherwise the
411       * return status shall be RTEMS_SUCCESSFUL.
412       */
413      #if defined(RTEMS_SMP)
414      if ( rtems_configuration_get_maximum_processors() > 1 ) {
415        T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
416      } else {
417        T_rsc_success( ctx->catch_status );
418      }
419      #else
420      T_rsc_success( ctx->catch_status );
421      #endif
422      break;
423    }
424
425    case RtemsSignalReqCatch_Post_Status_NotImplIntLvl: {
426      /*
427       * Where the system is configured with SMP support and the configured
428       * processor maximum is greater than one, or the CPU port enabled robust
429       * thread dispatching, the return status of rtems_signal_catch() shall be
430       * RTEMS_NOT_IMPLEMENTED, otherwise the return status shall be
431       * RTEMS_SUCCESSFUL.
432       */
433      #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
434      T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
435      #elif defined(RTEMS_SMP)
436      if ( rtems_configuration_get_maximum_processors() > 1 ) {
437        T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
438      } else {
439        T_rsc_success( ctx->catch_status );
440      }
441      #else
442      T_rsc_success( ctx->catch_status );
443      #endif
444      break;
445    }
446
447    case RtemsSignalReqCatch_Post_Status_NA:
448      break;
449  }
450}
451
452static void RtemsSignalReqCatch_Post_Send_Check(
453  RtemsSignalReqCatch_Context  *ctx,
454  RtemsSignalReqCatch_Post_Send state
455)
456{
457  switch ( state ) {
458    case RtemsSignalReqCatch_Post_Send_New: {
459      /*
460       * When a signal set is sent to the caller of rtems_signal_catch() and
461       * the call was successful, the ASR processing shall be done with the
462       * specified handler, otherwise the ASR information of the caller shall
463       * be unchanged.
464       */
465      T_rsc_success( ctx->send_status );
466
467      if ( ctx->catch_status == RTEMS_SUCCESSFUL ) {
468        T_eq_u32( ctx->default_handler_calls, 0 );
469        T_eq_u32( ctx->handler_calls, 1 );
470        T_ne_u32( ctx->handler_mode, 0xffffffff );
471      } else {
472        T_eq_u32( ctx->default_handler_calls, 1 );
473        T_eq_u32( ctx->handler_calls, 0 );
474        T_eq_u32( ctx->handler_mode, 0xffffffff );
475      }
476      break;
477    }
478
479    case RtemsSignalReqCatch_Post_Send_NotDef: {
480      /*
481       * When a signal set is sent to the caller of rtems_signal_catch() and
482       * the call was successful, the ASR processing shall be deactivated and
483       * all pending signals shall be cleared, otherwise the ASR information of
484       * the caller shall be unchanged.
485       */
486      if ( ctx->catch_status == RTEMS_SUCCESSFUL ) {
487        T_rsc( ctx->send_status, RTEMS_NOT_DEFINED );
488        T_eq_u32( ctx->default_handler_calls, 0 );
489        T_eq_u32( ctx->handler_calls, 0 );
490        T_eq_u32( ctx->handler_mode, 0xffffffff );
491      } else {
492        T_rsc_success( ctx->send_status );
493        T_eq_u32( ctx->default_handler_calls, 1 );
494        T_eq_u32( ctx->handler_calls, 0 );
495        T_eq_u32( ctx->handler_mode, 0xffffffff );
496      }
497      break;
498    }
499
500    case RtemsSignalReqCatch_Post_Send_NA:
501      break;
502  }
503}
504
505static void RtemsSignalReqCatch_Post_Preempt_Check(
506  RtemsSignalReqCatch_Context     *ctx,
507  RtemsSignalReqCatch_Post_Preempt state
508)
509{
510  switch ( state ) {
511    case RtemsSignalReqCatch_Post_Preempt_Yes: {
512      /*
513       * When a signal set is sent to the caller of rtems_signal_catch() and
514       * the call with a valid handler was successful, the ASR processing shall
515       * be done with preemption enabled.
516       */
517      CheckHandlerMode( ctx, RTEMS_PREEMPT_MASK, RTEMS_PREEMPT );
518      break;
519    }
520
521    case RtemsSignalReqCatch_Post_Preempt_No: {
522      /*
523       * When a signal set is sent to the caller of rtems_signal_catch() and
524       * the call with a valid handler was successful, the ASR processing shall
525       * be done with preemption disabled.
526       */
527      CheckHandlerMode( ctx, RTEMS_PREEMPT_MASK, RTEMS_NO_PREEMPT );
528      break;
529    }
530
531    case RtemsSignalReqCatch_Post_Preempt_NA:
532      break;
533  }
534}
535
536static void RtemsSignalReqCatch_Post_Timeslice_Check(
537  RtemsSignalReqCatch_Context       *ctx,
538  RtemsSignalReqCatch_Post_Timeslice state
539)
540{
541  switch ( state ) {
542    case RtemsSignalReqCatch_Post_Timeslice_Yes: {
543      /*
544       * When a signal set is sent to the caller of rtems_signal_catch() and
545       * the call with a valid handler was successful, the ASR processing shall
546       * be done with timeslicing enabled.
547       */
548      CheckHandlerMode( ctx, RTEMS_TIMESLICE_MASK, RTEMS_TIMESLICE );
549      break;
550    }
551
552    case RtemsSignalReqCatch_Post_Timeslice_No: {
553      /*
554       * When a signal set is sent to the caller of rtems_signal_catch() and
555       * the call with a valid handler was successful, the ASR processing shall
556       * be done with timeslicing disabled.
557       */
558      CheckHandlerMode( ctx, RTEMS_TIMESLICE_MASK, RTEMS_NO_TIMESLICE );
559      break;
560    }
561
562    case RtemsSignalReqCatch_Post_Timeslice_NA:
563      break;
564  }
565}
566
567static void RtemsSignalReqCatch_Post_ASR_Check(
568  RtemsSignalReqCatch_Context *ctx,
569  RtemsSignalReqCatch_Post_ASR state
570)
571{
572  switch ( state ) {
573    case RtemsSignalReqCatch_Post_ASR_Yes: {
574      /*
575       * When a signal set is sent to the caller of rtems_signal_catch() and
576       * the call with a valid handler was successful, the ASR processing shall
577       * be done with ASR processing enabled.
578       */
579      CheckHandlerMode( ctx, RTEMS_ASR_MASK, RTEMS_ASR );
580      break;
581    }
582
583    case RtemsSignalReqCatch_Post_ASR_No: {
584      /*
585       * When a signal set is sent to the caller of rtems_signal_catch() and
586       * the call with a valid handler was successful, the ASR processing shall
587       * be done with ASR processing disabled.
588       */
589      CheckHandlerMode( ctx, RTEMS_ASR_MASK, RTEMS_NO_ASR );
590      break;
591    }
592
593    case RtemsSignalReqCatch_Post_ASR_NA:
594      break;
595  }
596}
597
598static void RtemsSignalReqCatch_Post_IntLvl_Check(
599  RtemsSignalReqCatch_Context    *ctx,
600  RtemsSignalReqCatch_Post_IntLvl state
601)
602{
603  switch ( state ) {
604    case RtemsSignalReqCatch_Post_IntLvl_Zero: {
605      /*
606       * When a signal set is sent to the caller of rtems_signal_catch() and
607       * the call with a valid handler was successful, the ASR processing shall
608       * be done with interrupts enabled.
609       */
610      CheckHandlerMode( ctx, RTEMS_INTERRUPT_MASK, RTEMS_INTERRUPT_LEVEL( 0 ) );
611      break;
612    }
613
614    case RtemsSignalReqCatch_Post_IntLvl_Positive: {
615      /*
616       * When a signal set is sent to the caller of rtems_signal_catch() and
617       * the call with a valid handler was successful, the ASR processing shall
618       * be done with interrupts disabled according to the specified interrupt
619       * level.
620       */
621      CheckHandlerMode( ctx, RTEMS_INTERRUPT_MASK, RTEMS_INTERRUPT_LEVEL( 1 ) );
622      break;
623    }
624
625    case RtemsSignalReqCatch_Post_IntLvl_NA:
626      break;
627  }
628}
629
630static void RtemsSignalReqCatch_Teardown( RtemsSignalReqCatch_Context *ctx )
631{
632  rtems_status_code sc;
633
634  sc = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
635  T_rsc_success( sc );
636}
637
638static void RtemsSignalReqCatch_Teardown_Wrap( void *arg )
639{
640  RtemsSignalReqCatch_Context *ctx;
641
642  ctx = arg;
643  ctx->in_action_loop = false;
644  RtemsSignalReqCatch_Teardown( ctx );
645}
646
647static size_t RtemsSignalReqCatch_Scope( void *arg, char *buf, size_t n )
648{
649  RtemsSignalReqCatch_Context *ctx;
650
651  ctx = arg;
652
653  if ( ctx->in_action_loop ) {
654    return T_get_scope( RtemsSignalReqCatch_PreDesc, buf, n, ctx->pcs );
655  }
656
657  return 0;
658}
659
660static T_fixture RtemsSignalReqCatch_Fixture = {
661  .setup = NULL,
662  .stop = NULL,
663  .teardown = RtemsSignalReqCatch_Teardown_Wrap,
664  .scope = RtemsSignalReqCatch_Scope,
665  .initial_context = &RtemsSignalReqCatch_Instance
666};
667
668static const uint8_t RtemsSignalReqCatch_TransitionMap[][ 6 ] = {
669  {
670    RtemsSignalReqCatch_Post_Status_Ok,
671    RtemsSignalReqCatch_Post_Send_NotDef,
672    RtemsSignalReqCatch_Post_Preempt_Yes,
673    RtemsSignalReqCatch_Post_Timeslice_Yes,
674    RtemsSignalReqCatch_Post_ASR_Yes,
675    RtemsSignalReqCatch_Post_IntLvl_Zero
676  }, {
677    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
678    RtemsSignalReqCatch_Post_Send_NotDef,
679    RtemsSignalReqCatch_Post_Preempt_Yes,
680    RtemsSignalReqCatch_Post_Timeslice_Yes,
681    RtemsSignalReqCatch_Post_ASR_Yes,
682    RtemsSignalReqCatch_Post_IntLvl_Positive
683  }, {
684    RtemsSignalReqCatch_Post_Status_Ok,
685    RtemsSignalReqCatch_Post_Send_NotDef,
686    RtemsSignalReqCatch_Post_Preempt_Yes,
687    RtemsSignalReqCatch_Post_Timeslice_Yes,
688    RtemsSignalReqCatch_Post_ASR_No,
689    RtemsSignalReqCatch_Post_IntLvl_Zero
690  }, {
691    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
692    RtemsSignalReqCatch_Post_Send_NotDef,
693    RtemsSignalReqCatch_Post_Preempt_Yes,
694    RtemsSignalReqCatch_Post_Timeslice_Yes,
695    RtemsSignalReqCatch_Post_ASR_No,
696    RtemsSignalReqCatch_Post_IntLvl_Positive
697  }, {
698    RtemsSignalReqCatch_Post_Status_Ok,
699    RtemsSignalReqCatch_Post_Send_NotDef,
700    RtemsSignalReqCatch_Post_Preempt_Yes,
701    RtemsSignalReqCatch_Post_Timeslice_No,
702    RtemsSignalReqCatch_Post_ASR_Yes,
703    RtemsSignalReqCatch_Post_IntLvl_Zero
704  }, {
705    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
706    RtemsSignalReqCatch_Post_Send_NotDef,
707    RtemsSignalReqCatch_Post_Preempt_Yes,
708    RtemsSignalReqCatch_Post_Timeslice_No,
709    RtemsSignalReqCatch_Post_ASR_Yes,
710    RtemsSignalReqCatch_Post_IntLvl_Positive
711  }, {
712    RtemsSignalReqCatch_Post_Status_Ok,
713    RtemsSignalReqCatch_Post_Send_NotDef,
714    RtemsSignalReqCatch_Post_Preempt_Yes,
715    RtemsSignalReqCatch_Post_Timeslice_No,
716    RtemsSignalReqCatch_Post_ASR_No,
717    RtemsSignalReqCatch_Post_IntLvl_Zero
718  }, {
719    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
720    RtemsSignalReqCatch_Post_Send_NotDef,
721    RtemsSignalReqCatch_Post_Preempt_Yes,
722    RtemsSignalReqCatch_Post_Timeslice_No,
723    RtemsSignalReqCatch_Post_ASR_No,
724    RtemsSignalReqCatch_Post_IntLvl_Positive
725  }, {
726    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
727    RtemsSignalReqCatch_Post_Send_NotDef,
728    RtemsSignalReqCatch_Post_Preempt_No,
729    RtemsSignalReqCatch_Post_Timeslice_Yes,
730    RtemsSignalReqCatch_Post_ASR_Yes,
731    RtemsSignalReqCatch_Post_IntLvl_Zero
732  }, {
733    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
734    RtemsSignalReqCatch_Post_Send_NotDef,
735    RtemsSignalReqCatch_Post_Preempt_No,
736    RtemsSignalReqCatch_Post_Timeslice_Yes,
737    RtemsSignalReqCatch_Post_ASR_Yes,
738    RtemsSignalReqCatch_Post_IntLvl_Positive
739  }, {
740    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
741    RtemsSignalReqCatch_Post_Send_NotDef,
742    RtemsSignalReqCatch_Post_Preempt_No,
743    RtemsSignalReqCatch_Post_Timeslice_Yes,
744    RtemsSignalReqCatch_Post_ASR_No,
745    RtemsSignalReqCatch_Post_IntLvl_Zero
746  }, {
747    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
748    RtemsSignalReqCatch_Post_Send_NotDef,
749    RtemsSignalReqCatch_Post_Preempt_No,
750    RtemsSignalReqCatch_Post_Timeslice_Yes,
751    RtemsSignalReqCatch_Post_ASR_No,
752    RtemsSignalReqCatch_Post_IntLvl_Positive
753  }, {
754    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
755    RtemsSignalReqCatch_Post_Send_NotDef,
756    RtemsSignalReqCatch_Post_Preempt_No,
757    RtemsSignalReqCatch_Post_Timeslice_No,
758    RtemsSignalReqCatch_Post_ASR_Yes,
759    RtemsSignalReqCatch_Post_IntLvl_Zero
760  }, {
761    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
762    RtemsSignalReqCatch_Post_Send_NotDef,
763    RtemsSignalReqCatch_Post_Preempt_No,
764    RtemsSignalReqCatch_Post_Timeslice_No,
765    RtemsSignalReqCatch_Post_ASR_Yes,
766    RtemsSignalReqCatch_Post_IntLvl_Positive
767  }, {
768    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
769    RtemsSignalReqCatch_Post_Send_NotDef,
770    RtemsSignalReqCatch_Post_Preempt_No,
771    RtemsSignalReqCatch_Post_Timeslice_No,
772    RtemsSignalReqCatch_Post_ASR_No,
773    RtemsSignalReqCatch_Post_IntLvl_Zero
774  }, {
775    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
776    RtemsSignalReqCatch_Post_Send_NotDef,
777    RtemsSignalReqCatch_Post_Preempt_No,
778    RtemsSignalReqCatch_Post_Timeslice_No,
779    RtemsSignalReqCatch_Post_ASR_No,
780    RtemsSignalReqCatch_Post_IntLvl_Positive
781  }, {
782    RtemsSignalReqCatch_Post_Status_Ok,
783    RtemsSignalReqCatch_Post_Send_New,
784    RtemsSignalReqCatch_Post_Preempt_Yes,
785    RtemsSignalReqCatch_Post_Timeslice_Yes,
786    RtemsSignalReqCatch_Post_ASR_Yes,
787    RtemsSignalReqCatch_Post_IntLvl_Zero
788  }, {
789    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
790    RtemsSignalReqCatch_Post_Send_New,
791    RtemsSignalReqCatch_Post_Preempt_Yes,
792    RtemsSignalReqCatch_Post_Timeslice_Yes,
793    RtemsSignalReqCatch_Post_ASR_Yes,
794    RtemsSignalReqCatch_Post_IntLvl_Positive
795  }, {
796    RtemsSignalReqCatch_Post_Status_Ok,
797    RtemsSignalReqCatch_Post_Send_New,
798    RtemsSignalReqCatch_Post_Preempt_Yes,
799    RtemsSignalReqCatch_Post_Timeslice_Yes,
800    RtemsSignalReqCatch_Post_ASR_No,
801    RtemsSignalReqCatch_Post_IntLvl_Zero
802  }, {
803    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
804    RtemsSignalReqCatch_Post_Send_New,
805    RtemsSignalReqCatch_Post_Preempt_Yes,
806    RtemsSignalReqCatch_Post_Timeslice_Yes,
807    RtemsSignalReqCatch_Post_ASR_No,
808    RtemsSignalReqCatch_Post_IntLvl_Positive
809  }, {
810    RtemsSignalReqCatch_Post_Status_Ok,
811    RtemsSignalReqCatch_Post_Send_New,
812    RtemsSignalReqCatch_Post_Preempt_Yes,
813    RtemsSignalReqCatch_Post_Timeslice_No,
814    RtemsSignalReqCatch_Post_ASR_Yes,
815    RtemsSignalReqCatch_Post_IntLvl_Zero
816  }, {
817    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
818    RtemsSignalReqCatch_Post_Send_New,
819    RtemsSignalReqCatch_Post_Preempt_Yes,
820    RtemsSignalReqCatch_Post_Timeslice_No,
821    RtemsSignalReqCatch_Post_ASR_Yes,
822    RtemsSignalReqCatch_Post_IntLvl_Positive
823  }, {
824    RtemsSignalReqCatch_Post_Status_Ok,
825    RtemsSignalReqCatch_Post_Send_New,
826    RtemsSignalReqCatch_Post_Preempt_Yes,
827    RtemsSignalReqCatch_Post_Timeslice_No,
828    RtemsSignalReqCatch_Post_ASR_No,
829    RtemsSignalReqCatch_Post_IntLvl_Zero
830  }, {
831    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
832    RtemsSignalReqCatch_Post_Send_New,
833    RtemsSignalReqCatch_Post_Preempt_Yes,
834    RtemsSignalReqCatch_Post_Timeslice_No,
835    RtemsSignalReqCatch_Post_ASR_No,
836    RtemsSignalReqCatch_Post_IntLvl_Positive
837  }, {
838    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
839    RtemsSignalReqCatch_Post_Send_New,
840    RtemsSignalReqCatch_Post_Preempt_No,
841    RtemsSignalReqCatch_Post_Timeslice_Yes,
842    RtemsSignalReqCatch_Post_ASR_Yes,
843    RtemsSignalReqCatch_Post_IntLvl_Zero
844  }, {
845    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
846    RtemsSignalReqCatch_Post_Send_New,
847    RtemsSignalReqCatch_Post_Preempt_No,
848    RtemsSignalReqCatch_Post_Timeslice_Yes,
849    RtemsSignalReqCatch_Post_ASR_Yes,
850    RtemsSignalReqCatch_Post_IntLvl_Positive
851  }, {
852    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
853    RtemsSignalReqCatch_Post_Send_New,
854    RtemsSignalReqCatch_Post_Preempt_No,
855    RtemsSignalReqCatch_Post_Timeslice_Yes,
856    RtemsSignalReqCatch_Post_ASR_No,
857    RtemsSignalReqCatch_Post_IntLvl_Zero
858  }, {
859    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
860    RtemsSignalReqCatch_Post_Send_New,
861    RtemsSignalReqCatch_Post_Preempt_No,
862    RtemsSignalReqCatch_Post_Timeslice_Yes,
863    RtemsSignalReqCatch_Post_ASR_No,
864    RtemsSignalReqCatch_Post_IntLvl_Positive
865  }, {
866    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
867    RtemsSignalReqCatch_Post_Send_New,
868    RtemsSignalReqCatch_Post_Preempt_No,
869    RtemsSignalReqCatch_Post_Timeslice_No,
870    RtemsSignalReqCatch_Post_ASR_Yes,
871    RtemsSignalReqCatch_Post_IntLvl_Zero
872  }, {
873    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
874    RtemsSignalReqCatch_Post_Send_New,
875    RtemsSignalReqCatch_Post_Preempt_No,
876    RtemsSignalReqCatch_Post_Timeslice_No,
877    RtemsSignalReqCatch_Post_ASR_Yes,
878    RtemsSignalReqCatch_Post_IntLvl_Positive
879  }, {
880    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
881    RtemsSignalReqCatch_Post_Send_New,
882    RtemsSignalReqCatch_Post_Preempt_No,
883    RtemsSignalReqCatch_Post_Timeslice_No,
884    RtemsSignalReqCatch_Post_ASR_No,
885    RtemsSignalReqCatch_Post_IntLvl_Zero
886  }, {
887    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
888    RtemsSignalReqCatch_Post_Send_New,
889    RtemsSignalReqCatch_Post_Preempt_No,
890    RtemsSignalReqCatch_Post_Timeslice_No,
891    RtemsSignalReqCatch_Post_ASR_No,
892    RtemsSignalReqCatch_Post_IntLvl_Positive
893  }
894};
895
896static const struct {
897  uint8_t Skip : 1;
898  uint8_t Pre_Handler_NA : 1;
899  uint8_t Pre_Preempt_NA : 1;
900  uint8_t Pre_Timeslice_NA : 1;
901  uint8_t Pre_ASR_NA : 1;
902  uint8_t Pre_IntLvl_NA : 1;
903} RtemsSignalReqCatch_TransitionInfo[] = {
904  {
905    0, 0, 0, 0, 0, 0
906  }, {
907    0, 0, 0, 0, 0, 0
908  }, {
909    0, 0, 0, 0, 0, 0
910  }, {
911    0, 0, 0, 0, 0, 0
912  }, {
913    0, 0, 0, 0, 0, 0
914  }, {
915    0, 0, 0, 0, 0, 0
916  }, {
917    0, 0, 0, 0, 0, 0
918  }, {
919    0, 0, 0, 0, 0, 0
920  }, {
921    0, 0, 0, 0, 0, 0
922  }, {
923    0, 0, 0, 0, 0, 0
924  }, {
925    0, 0, 0, 0, 0, 0
926  }, {
927    0, 0, 0, 0, 0, 0
928  }, {
929    0, 0, 0, 0, 0, 0
930  }, {
931    0, 0, 0, 0, 0, 0
932  }, {
933    0, 0, 0, 0, 0, 0
934  }, {
935    0, 0, 0, 0, 0, 0
936  }, {
937    0, 0, 0, 0, 0, 0
938  }, {
939    0, 0, 0, 0, 0, 0
940  }, {
941    0, 0, 0, 0, 0, 0
942  }, {
943    0, 0, 0, 0, 0, 0
944  }, {
945    0, 0, 0, 0, 0, 0
946  }, {
947    0, 0, 0, 0, 0, 0
948  }, {
949    0, 0, 0, 0, 0, 0
950  }, {
951    0, 0, 0, 0, 0, 0
952  }, {
953    0, 0, 0, 0, 0, 0
954  }, {
955    0, 0, 0, 0, 0, 0
956  }, {
957    0, 0, 0, 0, 0, 0
958  }, {
959    0, 0, 0, 0, 0, 0
960  }, {
961    0, 0, 0, 0, 0, 0
962  }, {
963    0, 0, 0, 0, 0, 0
964  }, {
965    0, 0, 0, 0, 0, 0
966  }, {
967    0, 0, 0, 0, 0, 0
968  }
969};
970
971static void RtemsSignalReqCatch_Prepare( RtemsSignalReqCatch_Context *ctx )
972{
973  rtems_status_code sc;
974
975  ctx->default_handler_calls = 0;
976  ctx->handler_calls = 0;
977  ctx->handler_mode = 0xffffffff;
978  ctx->normal_mode = RTEMS_DEFAULT_MODES;
979  ctx->handler = NULL;
980  ctx->mode = RTEMS_DEFAULT_MODES;
981
982  sc = rtems_signal_catch( DefaultHandler, RTEMS_NO_ASR );
983  T_rsc_success( sc );
984}
985
986static void RtemsSignalReqCatch_Action( RtemsSignalReqCatch_Context *ctx )
987{
988  rtems_status_code sc;
989  rtems_mode        mode;
990
991  ctx->catch_status = rtems_signal_catch( ctx->handler, ctx->mode );
992
993  sc = rtems_task_mode( ctx->normal_mode, RTEMS_ALL_MODE_MASKS, &mode );
994  T_rsc_success( sc );
995
996  ctx->send_status = rtems_signal_send( RTEMS_SELF, 0xdeadbeef );
997
998  sc = rtems_task_mode( mode, RTEMS_ALL_MODE_MASKS, &mode );
999  T_rsc_success( sc );
1000}
1001
1002/**
1003 * @fn void T_case_body_RtemsSignalReqCatch( void )
1004 */
1005T_TEST_CASE_FIXTURE( RtemsSignalReqCatch, &RtemsSignalReqCatch_Fixture )
1006{
1007  RtemsSignalReqCatch_Context *ctx;
1008  size_t index;
1009
1010  ctx = T_fixture_context();
1011  ctx->in_action_loop = true;
1012  index = 0;
1013
1014  for (
1015    ctx->pcs[ 0 ] = RtemsSignalReqCatch_Pre_Handler_Invalid;
1016    ctx->pcs[ 0 ] < RtemsSignalReqCatch_Pre_Handler_NA;
1017    ++ctx->pcs[ 0 ]
1018  ) {
1019    if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Handler_NA ) {
1020      ctx->pcs[ 0 ] = RtemsSignalReqCatch_Pre_Handler_NA;
1021      index += ( RtemsSignalReqCatch_Pre_Handler_NA - 1 )
1022        * RtemsSignalReqCatch_Pre_Preempt_NA
1023        * RtemsSignalReqCatch_Pre_Timeslice_NA
1024        * RtemsSignalReqCatch_Pre_ASR_NA
1025        * RtemsSignalReqCatch_Pre_IntLvl_NA;
1026    }
1027
1028    for (
1029      ctx->pcs[ 1 ] = RtemsSignalReqCatch_Pre_Preempt_Yes;
1030      ctx->pcs[ 1 ] < RtemsSignalReqCatch_Pre_Preempt_NA;
1031      ++ctx->pcs[ 1 ]
1032    ) {
1033      if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Preempt_NA ) {
1034        ctx->pcs[ 1 ] = RtemsSignalReqCatch_Pre_Preempt_NA;
1035        index += ( RtemsSignalReqCatch_Pre_Preempt_NA - 1 )
1036          * RtemsSignalReqCatch_Pre_Timeslice_NA
1037          * RtemsSignalReqCatch_Pre_ASR_NA
1038          * RtemsSignalReqCatch_Pre_IntLvl_NA;
1039      }
1040
1041      for (
1042        ctx->pcs[ 2 ] = RtemsSignalReqCatch_Pre_Timeslice_Yes;
1043        ctx->pcs[ 2 ] < RtemsSignalReqCatch_Pre_Timeslice_NA;
1044        ++ctx->pcs[ 2 ]
1045      ) {
1046        if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Timeslice_NA ) {
1047          ctx->pcs[ 2 ] = RtemsSignalReqCatch_Pre_Timeslice_NA;
1048          index += ( RtemsSignalReqCatch_Pre_Timeslice_NA - 1 )
1049            * RtemsSignalReqCatch_Pre_ASR_NA
1050            * RtemsSignalReqCatch_Pre_IntLvl_NA;
1051        }
1052
1053        for (
1054          ctx->pcs[ 3 ] = RtemsSignalReqCatch_Pre_ASR_Yes;
1055          ctx->pcs[ 3 ] < RtemsSignalReqCatch_Pre_ASR_NA;
1056          ++ctx->pcs[ 3 ]
1057        ) {
1058          if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_ASR_NA ) {
1059            ctx->pcs[ 3 ] = RtemsSignalReqCatch_Pre_ASR_NA;
1060            index += ( RtemsSignalReqCatch_Pre_ASR_NA - 1 )
1061              * RtemsSignalReqCatch_Pre_IntLvl_NA;
1062          }
1063
1064          for (
1065            ctx->pcs[ 4 ] = RtemsSignalReqCatch_Pre_IntLvl_Zero;
1066            ctx->pcs[ 4 ] < RtemsSignalReqCatch_Pre_IntLvl_NA;
1067            ++ctx->pcs[ 4 ]
1068          ) {
1069            if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_IntLvl_NA ) {
1070              ctx->pcs[ 4 ] = RtemsSignalReqCatch_Pre_IntLvl_NA;
1071              index += ( RtemsSignalReqCatch_Pre_IntLvl_NA - 1 );
1072            }
1073
1074            if ( RtemsSignalReqCatch_TransitionInfo[ index ].Skip ) {
1075              ++index;
1076              continue;
1077            }
1078
1079            RtemsSignalReqCatch_Prepare( ctx );
1080            RtemsSignalReqCatch_Pre_Handler_Prepare( ctx, ctx->pcs[ 0 ] );
1081            RtemsSignalReqCatch_Pre_Preempt_Prepare( ctx, ctx->pcs[ 1 ] );
1082            RtemsSignalReqCatch_Pre_Timeslice_Prepare( ctx, ctx->pcs[ 2 ] );
1083            RtemsSignalReqCatch_Pre_ASR_Prepare( ctx, ctx->pcs[ 3 ] );
1084            RtemsSignalReqCatch_Pre_IntLvl_Prepare( ctx, ctx->pcs[ 4 ] );
1085            RtemsSignalReqCatch_Action( ctx );
1086            RtemsSignalReqCatch_Post_Status_Check(
1087              ctx,
1088              RtemsSignalReqCatch_TransitionMap[ index ][ 0 ]
1089            );
1090            RtemsSignalReqCatch_Post_Send_Check(
1091              ctx,
1092              RtemsSignalReqCatch_TransitionMap[ index ][ 1 ]
1093            );
1094            RtemsSignalReqCatch_Post_Preempt_Check(
1095              ctx,
1096              RtemsSignalReqCatch_TransitionMap[ index ][ 2 ]
1097            );
1098            RtemsSignalReqCatch_Post_Timeslice_Check(
1099              ctx,
1100              RtemsSignalReqCatch_TransitionMap[ index ][ 3 ]
1101            );
1102            RtemsSignalReqCatch_Post_ASR_Check(
1103              ctx,
1104              RtemsSignalReqCatch_TransitionMap[ index ][ 4 ]
1105            );
1106            RtemsSignalReqCatch_Post_IntLvl_Check(
1107              ctx,
1108              RtemsSignalReqCatch_TransitionMap[ index ][ 5 ]
1109            );
1110            ++index;
1111          }
1112        }
1113      }
1114    }
1115  }
1116}
1117
1118/** @} */
Note: See TracBrowser for help on using the repository browser.