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

Last change on this file since 83b1b25d was 83b1b25d, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 2, 2021 at 11:31:45 AM

rtems: Simplify rtems_signal_catch()

In uniprocessor configurations, we can simplify rtems_signal_catch().
Add a validation test for the SMP special case.

  • Property mode set to 100644
File size: 45.8 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#include <string.h>
57#include <rtems/score/smpbarrier.h>
58
59#include <rtems/test.h>
60
61/**
62 * @defgroup RTEMSTestCaseRtemsSignalReqCatch spec:/rtems/signal/req/catch
63 *
64 * @ingroup RTEMSTestSuiteTestsuitesValidation0
65 * @ingroup RTEMSTestSuiteTestsuitesValidation1
66 *
67 * @{
68 */
69
70typedef enum {
71  RtemsSignalReqCatch_Pre_Pending_Yes,
72  RtemsSignalReqCatch_Pre_Pending_No,
73  RtemsSignalReqCatch_Pre_Pending_NA
74} RtemsSignalReqCatch_Pre_Pending;
75
76typedef enum {
77  RtemsSignalReqCatch_Pre_Handler_Invalid,
78  RtemsSignalReqCatch_Pre_Handler_Valid,
79  RtemsSignalReqCatch_Pre_Handler_NA
80} RtemsSignalReqCatch_Pre_Handler;
81
82typedef enum {
83  RtemsSignalReqCatch_Pre_Preempt_Yes,
84  RtemsSignalReqCatch_Pre_Preempt_No,
85  RtemsSignalReqCatch_Pre_Preempt_NA
86} RtemsSignalReqCatch_Pre_Preempt;
87
88typedef enum {
89  RtemsSignalReqCatch_Pre_Timeslice_Yes,
90  RtemsSignalReqCatch_Pre_Timeslice_No,
91  RtemsSignalReqCatch_Pre_Timeslice_NA
92} RtemsSignalReqCatch_Pre_Timeslice;
93
94typedef enum {
95  RtemsSignalReqCatch_Pre_ASR_Yes,
96  RtemsSignalReqCatch_Pre_ASR_No,
97  RtemsSignalReqCatch_Pre_ASR_NA
98} RtemsSignalReqCatch_Pre_ASR;
99
100typedef enum {
101  RtemsSignalReqCatch_Pre_IntLvl_Zero,
102  RtemsSignalReqCatch_Pre_IntLvl_Positive,
103  RtemsSignalReqCatch_Pre_IntLvl_NA
104} RtemsSignalReqCatch_Pre_IntLvl;
105
106typedef enum {
107  RtemsSignalReqCatch_Post_Status_Ok,
108  RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
109  RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
110  RtemsSignalReqCatch_Post_Status_NA
111} RtemsSignalReqCatch_Post_Status;
112
113typedef enum {
114  RtemsSignalReqCatch_Post_Send_New,
115  RtemsSignalReqCatch_Post_Send_NotDef,
116  RtemsSignalReqCatch_Post_Send_NA
117} RtemsSignalReqCatch_Post_Send;
118
119typedef enum {
120  RtemsSignalReqCatch_Post_Preempt_Yes,
121  RtemsSignalReqCatch_Post_Preempt_No,
122  RtemsSignalReqCatch_Post_Preempt_NA
123} RtemsSignalReqCatch_Post_Preempt;
124
125typedef enum {
126  RtemsSignalReqCatch_Post_Timeslice_Yes,
127  RtemsSignalReqCatch_Post_Timeslice_No,
128  RtemsSignalReqCatch_Post_Timeslice_NA
129} RtemsSignalReqCatch_Post_Timeslice;
130
131typedef enum {
132  RtemsSignalReqCatch_Post_ASR_Yes,
133  RtemsSignalReqCatch_Post_ASR_No,
134  RtemsSignalReqCatch_Post_ASR_NA
135} RtemsSignalReqCatch_Post_ASR;
136
137typedef enum {
138  RtemsSignalReqCatch_Post_IntLvl_Zero,
139  RtemsSignalReqCatch_Post_IntLvl_Positive,
140  RtemsSignalReqCatch_Post_IntLvl_NA
141} RtemsSignalReqCatch_Post_IntLvl;
142
143/**
144 * @brief Test context for spec:/rtems/signal/req/catch test case.
145 */
146typedef struct {
147  rtems_id runner_id;
148
149  rtems_id worker_id;
150
151  uint32_t pending_signals;
152
153  SMP_barrier_Control barrier;
154
155  SMP_barrier_State runner_barrier_state;
156
157  uint32_t default_handler_calls;
158
159  uint32_t handler_calls;
160
161  rtems_mode handler_mode;
162
163  rtems_mode normal_mode;
164
165  rtems_asr_entry handler;
166
167  rtems_mode mode;
168
169  rtems_status_code catch_status;
170
171  rtems_status_code send_status;
172
173  /**
174   * @brief This member defines the pre-condition states for the next action.
175   */
176  size_t pcs[ 6 ];
177
178  /**
179   * @brief This member indicates if the test action loop is currently
180   *   executed.
181   */
182  bool in_action_loop;
183} RtemsSignalReqCatch_Context;
184
185static RtemsSignalReqCatch_Context
186  RtemsSignalReqCatch_Instance;
187
188static const char * const RtemsSignalReqCatch_PreDesc_Pending[] = {
189  "Yes",
190  "No",
191  "NA"
192};
193
194static const char * const RtemsSignalReqCatch_PreDesc_Handler[] = {
195  "Invalid",
196  "Valid",
197  "NA"
198};
199
200static const char * const RtemsSignalReqCatch_PreDesc_Preempt[] = {
201  "Yes",
202  "No",
203  "NA"
204};
205
206static const char * const RtemsSignalReqCatch_PreDesc_Timeslice[] = {
207  "Yes",
208  "No",
209  "NA"
210};
211
212static const char * const RtemsSignalReqCatch_PreDesc_ASR[] = {
213  "Yes",
214  "No",
215  "NA"
216};
217
218static const char * const RtemsSignalReqCatch_PreDesc_IntLvl[] = {
219  "Zero",
220  "Positive",
221  "NA"
222};
223
224static const char * const * const RtemsSignalReqCatch_PreDesc[] = {
225  RtemsSignalReqCatch_PreDesc_Pending,
226  RtemsSignalReqCatch_PreDesc_Handler,
227  RtemsSignalReqCatch_PreDesc_Preempt,
228  RtemsSignalReqCatch_PreDesc_Timeslice,
229  RtemsSignalReqCatch_PreDesc_ASR,
230  RtemsSignalReqCatch_PreDesc_IntLvl,
231  NULL
232};
233
234typedef RtemsSignalReqCatch_Context Context;
235
236static void DefaultHandler( rtems_signal_set signal_set )
237{
238  Context *ctx;
239
240  ctx = T_fixture_context();
241  ++ctx->default_handler_calls;
242
243  if ( ctx->pending_signals != 0 && ctx->default_handler_calls == 1 ) {
244    T_eq_u32( signal_set, 0x600df00d );
245  } else {
246    T_eq_u32( signal_set, 0xdeadbeef );
247  }
248}
249
250static void SignalHandler( rtems_signal_set signal_set )
251{
252  Context          *ctx;
253  rtems_status_code sc;
254
255  ctx = T_fixture_context();
256  ++ctx->handler_calls;
257
258  sc = rtems_task_mode(
259    RTEMS_DEFAULT_MODES,
260    RTEMS_CURRENT_MODE,
261    &ctx->handler_mode
262  );
263  T_rsc_success( sc );
264
265  if ( ctx->pending_signals != 0 && ctx->handler_calls == 1 ) {
266    T_eq_u32( signal_set, 0x600df00d );
267  } else {
268    T_eq_u32( signal_set, 0xdeadbeef );
269  }
270}
271
272static void CheckHandlerMode( Context *ctx, rtems_mode mask, rtems_mode mode )
273{
274  if ( ctx->catch_status == RTEMS_SUCCESSFUL && ctx->handler != NULL ) {
275    T_ne_u32( ctx->handler_mode, 0xffffffff );
276    T_eq_u32( ctx->handler_mode & mask, mode );
277  }
278}
279
280static void Worker( rtems_task_argument arg )
281{
282  Context          *ctx;
283  SMP_barrier_State barrier_state;
284
285  ctx = (Context *) arg;
286  _SMP_barrier_State_initialize( &barrier_state );
287
288  while ( true ) {
289    rtems_status_code sc;
290
291    _SMP_barrier_Wait( &ctx->barrier, &barrier_state, 2 );
292
293    sc = rtems_signal_send( ctx->runner_id, 0x600df00d );
294    T_rsc_success( sc );
295
296    _SMP_barrier_Wait( &ctx->barrier, &barrier_state, 2 );
297  }
298}
299
300static void RtemsSignalReqCatch_Pre_Pending_Prepare(
301  RtemsSignalReqCatch_Context    *ctx,
302  RtemsSignalReqCatch_Pre_Pending state
303)
304{
305  switch ( state ) {
306    case RtemsSignalReqCatch_Pre_Pending_Yes: {
307      /*
308       * Where the system has more than one processor, when
309       * rtems_signal_catch() is called, the calling task shall have pending
310       * signals.
311       */
312      ctx->pending_signals = ( rtems_scheduler_get_processor_maximum() > 1 ) ? 1 : 0;
313      break;
314    }
315
316    case RtemsSignalReqCatch_Pre_Pending_No: {
317      /*
318       * When rtems_signal_catch() is called, the calling task shall have no
319       * pending signals.
320       */
321      ctx->pending_signals = 0;
322      break;
323    }
324
325    case RtemsSignalReqCatch_Pre_Pending_NA:
326      break;
327  }
328}
329
330static void RtemsSignalReqCatch_Pre_Handler_Prepare(
331  RtemsSignalReqCatch_Context    *ctx,
332  RtemsSignalReqCatch_Pre_Handler state
333)
334{
335  switch ( state ) {
336    case RtemsSignalReqCatch_Pre_Handler_Invalid: {
337      /*
338       * The ``asr_handler`` parameter shall be NULL.
339       */
340      ctx->handler = NULL;
341      break;
342    }
343
344    case RtemsSignalReqCatch_Pre_Handler_Valid: {
345      /*
346       * The ``asr_handler`` parameter shall be a valid ASR handler.
347       */
348      ctx->handler = SignalHandler;
349      break;
350    }
351
352    case RtemsSignalReqCatch_Pre_Handler_NA:
353      break;
354  }
355}
356
357static void RtemsSignalReqCatch_Pre_Preempt_Prepare(
358  RtemsSignalReqCatch_Context    *ctx,
359  RtemsSignalReqCatch_Pre_Preempt state
360)
361{
362  switch ( state ) {
363    case RtemsSignalReqCatch_Pre_Preempt_Yes: {
364      /*
365       * The ``mode_set`` parameter shall specify that preemption is enabled.
366       */
367      #if defined(RTEMS_SMP)
368      if ( rtems_configuration_get_maximum_processors() == 1 ) {
369        ctx->normal_mode |= RTEMS_NO_PREEMPT;
370      }
371      #else
372      ctx->normal_mode |= RTEMS_NO_PREEMPT;
373      #endif
374      break;
375    }
376
377    case RtemsSignalReqCatch_Pre_Preempt_No: {
378      /*
379       * The ``mode_set`` parameter shall specify that preemption is disabled.
380       */
381      ctx->mode |= RTEMS_NO_PREEMPT;
382      break;
383    }
384
385    case RtemsSignalReqCatch_Pre_Preempt_NA:
386      break;
387  }
388}
389
390static void RtemsSignalReqCatch_Pre_Timeslice_Prepare(
391  RtemsSignalReqCatch_Context      *ctx,
392  RtemsSignalReqCatch_Pre_Timeslice state
393)
394{
395  switch ( state ) {
396    case RtemsSignalReqCatch_Pre_Timeslice_Yes: {
397      /*
398       * The ``mode_set`` parameter shall specify that timeslicing is enabled.
399       */
400      ctx->mode |= RTEMS_TIMESLICE;
401      break;
402    }
403
404    case RtemsSignalReqCatch_Pre_Timeslice_No: {
405      /*
406       * The ``mode_set`` parameter shall specify that timeslicing is disabled.
407       */
408      ctx->normal_mode |= RTEMS_TIMESLICE;
409      break;
410    }
411
412    case RtemsSignalReqCatch_Pre_Timeslice_NA:
413      break;
414  }
415}
416
417static void RtemsSignalReqCatch_Pre_ASR_Prepare(
418  RtemsSignalReqCatch_Context *ctx,
419  RtemsSignalReqCatch_Pre_ASR  state
420)
421{
422  switch ( state ) {
423    case RtemsSignalReqCatch_Pre_ASR_Yes: {
424      /*
425       * The ``mode_set`` parameter shall specify that ASR processing is
426       * enabled.
427       */
428      /* We cannot disable ASR processing at normal task level for this test */
429      break;
430    }
431
432    case RtemsSignalReqCatch_Pre_ASR_No: {
433      /*
434       * The ``mode_set`` parameter shall specify that ASR processing is
435       * disabled.
436       */
437      ctx->mode |= RTEMS_NO_ASR;
438      break;
439    }
440
441    case RtemsSignalReqCatch_Pre_ASR_NA:
442      break;
443  }
444}
445
446static void RtemsSignalReqCatch_Pre_IntLvl_Prepare(
447  RtemsSignalReqCatch_Context   *ctx,
448  RtemsSignalReqCatch_Pre_IntLvl state
449)
450{
451  switch ( state ) {
452    case RtemsSignalReqCatch_Pre_IntLvl_Zero: {
453      /*
454       * The ``mode_set`` parameter shall specify an interrupt level of zero.
455       */
456      #if !defined(RTEMS_SMP) && CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
457      ctx->normal_mode |= RTEMS_INTERRUPT_LEVEL( 1 );
458      #endif
459      break;
460    }
461
462    case RtemsSignalReqCatch_Pre_IntLvl_Positive: {
463      /*
464       * The ``mode_set`` parameter shall specify a positive interrupt level.
465       */
466      ctx->mode |= RTEMS_INTERRUPT_LEVEL( 1 );
467      break;
468    }
469
470    case RtemsSignalReqCatch_Pre_IntLvl_NA:
471      break;
472  }
473}
474
475static void RtemsSignalReqCatch_Post_Status_Check(
476  RtemsSignalReqCatch_Context    *ctx,
477  RtemsSignalReqCatch_Post_Status state
478)
479{
480  switch ( state ) {
481    case RtemsSignalReqCatch_Post_Status_Ok: {
482      /*
483       * The return status of rtems_signal_catch() shall be RTEMS_SUCCESSFUL.
484       */
485      T_rsc_success( ctx->catch_status );
486      break;
487    }
488
489    case RtemsSignalReqCatch_Post_Status_NotImplNoPreempt: {
490      /*
491       * Where the system is configured with SMP support, if the scheduler does
492       * not support the no-preempt mode, then the return status of
493       * rtems_signal_catch() shall be RTEMS_NOT_IMPLEMENTED, otherwise the
494       * return status shall be RTEMS_SUCCESSFUL.
495       */
496      #if defined(RTEMS_SMP)
497      if ( rtems_configuration_get_maximum_processors() > 1 ) {
498        T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
499      } else {
500        T_rsc_success( ctx->catch_status );
501      }
502      #else
503      T_rsc_success( ctx->catch_status );
504      #endif
505      break;
506    }
507
508    case RtemsSignalReqCatch_Post_Status_NotImplIntLvl: {
509      /*
510       * Where the system is configured with SMP support and the configured
511       * processor maximum is greater than one, or the CPU port enabled robust
512       * thread dispatching, the return status of rtems_signal_catch() shall be
513       * RTEMS_NOT_IMPLEMENTED, otherwise the return status shall be
514       * RTEMS_SUCCESSFUL.
515       */
516      #if CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
517      T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
518      #elif defined(RTEMS_SMP)
519      if ( rtems_configuration_get_maximum_processors() > 1 ) {
520        T_rsc( ctx->catch_status, RTEMS_NOT_IMPLEMENTED );
521      } else {
522        T_rsc_success( ctx->catch_status );
523      }
524      #else
525      T_rsc_success( ctx->catch_status );
526      #endif
527      break;
528    }
529
530    case RtemsSignalReqCatch_Post_Status_NA:
531      break;
532  }
533}
534
535static void RtemsSignalReqCatch_Post_Send_Check(
536  RtemsSignalReqCatch_Context  *ctx,
537  RtemsSignalReqCatch_Post_Send state
538)
539{
540  switch ( state ) {
541    case RtemsSignalReqCatch_Post_Send_New: {
542      /*
543       * When a signal set is sent to the caller of rtems_signal_catch() and
544       * the call was successful, the ASR processing shall be done with the
545       * specified handler, otherwise the ASR information of the caller shall
546       * be unchanged.
547       */
548      T_rsc_success( ctx->send_status );
549
550      if ( ctx->catch_status == RTEMS_SUCCESSFUL ) {
551        T_eq_u32( ctx->default_handler_calls, 0 );
552        T_eq_u32( ctx->handler_calls, 1 + ctx->pending_signals );
553        T_ne_u32( ctx->handler_mode, 0xffffffff );
554      } else {
555        T_eq_u32( ctx->default_handler_calls, 1 + ctx->pending_signals );
556        T_eq_u32( ctx->handler_calls, 0 );
557        T_eq_u32( ctx->handler_mode, 0xffffffff );
558      }
559      break;
560    }
561
562    case RtemsSignalReqCatch_Post_Send_NotDef: {
563      /*
564       * When a signal set is sent to the caller of rtems_signal_catch() and
565       * the call was successful, the ASR processing shall be deactivated and
566       * all pending signals shall be cleared, otherwise the ASR information of
567       * the caller shall be unchanged.
568       */
569      if ( ctx->catch_status == RTEMS_SUCCESSFUL ) {
570        T_rsc( ctx->send_status, RTEMS_NOT_DEFINED );
571        T_eq_u32( ctx->default_handler_calls, 0 );
572        T_eq_u32( ctx->handler_calls, 0 );
573        T_eq_u32( ctx->handler_mode, 0xffffffff );
574      } else {
575        T_rsc_success( ctx->send_status );
576        T_eq_u32( ctx->default_handler_calls, 1 + ctx->pending_signals );
577        T_eq_u32( ctx->handler_calls, 0 );
578        T_eq_u32( ctx->handler_mode, 0xffffffff );
579      }
580      break;
581    }
582
583    case RtemsSignalReqCatch_Post_Send_NA:
584      break;
585  }
586}
587
588static void RtemsSignalReqCatch_Post_Preempt_Check(
589  RtemsSignalReqCatch_Context     *ctx,
590  RtemsSignalReqCatch_Post_Preempt state
591)
592{
593  switch ( state ) {
594    case RtemsSignalReqCatch_Post_Preempt_Yes: {
595      /*
596       * When a signal set is sent to the caller of rtems_signal_catch() and
597       * the call with a valid handler was successful, the ASR processing shall
598       * be done with preemption enabled.
599       */
600      CheckHandlerMode( ctx, RTEMS_PREEMPT_MASK, RTEMS_PREEMPT );
601      break;
602    }
603
604    case RtemsSignalReqCatch_Post_Preempt_No: {
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 preemption disabled.
609       */
610      CheckHandlerMode( ctx, RTEMS_PREEMPT_MASK, RTEMS_NO_PREEMPT );
611      break;
612    }
613
614    case RtemsSignalReqCatch_Post_Preempt_NA:
615      break;
616  }
617}
618
619static void RtemsSignalReqCatch_Post_Timeslice_Check(
620  RtemsSignalReqCatch_Context       *ctx,
621  RtemsSignalReqCatch_Post_Timeslice state
622)
623{
624  switch ( state ) {
625    case RtemsSignalReqCatch_Post_Timeslice_Yes: {
626      /*
627       * When a signal set is sent to the caller of rtems_signal_catch() and
628       * the call with a valid handler was successful, the ASR processing shall
629       * be done with timeslicing enabled.
630       */
631      CheckHandlerMode( ctx, RTEMS_TIMESLICE_MASK, RTEMS_TIMESLICE );
632      break;
633    }
634
635    case RtemsSignalReqCatch_Post_Timeslice_No: {
636      /*
637       * When a signal set is sent to the caller of rtems_signal_catch() and
638       * the call with a valid handler was successful, the ASR processing shall
639       * be done with timeslicing disabled.
640       */
641      CheckHandlerMode( ctx, RTEMS_TIMESLICE_MASK, RTEMS_NO_TIMESLICE );
642      break;
643    }
644
645    case RtemsSignalReqCatch_Post_Timeslice_NA:
646      break;
647  }
648}
649
650static void RtemsSignalReqCatch_Post_ASR_Check(
651  RtemsSignalReqCatch_Context *ctx,
652  RtemsSignalReqCatch_Post_ASR state
653)
654{
655  switch ( state ) {
656    case RtemsSignalReqCatch_Post_ASR_Yes: {
657      /*
658       * When a signal set is sent to the caller of rtems_signal_catch() and
659       * the call with a valid handler was successful, the ASR processing shall
660       * be done with ASR processing enabled.
661       */
662      CheckHandlerMode( ctx, RTEMS_ASR_MASK, RTEMS_ASR );
663      break;
664    }
665
666    case RtemsSignalReqCatch_Post_ASR_No: {
667      /*
668       * When a signal set is sent to the caller of rtems_signal_catch() and
669       * the call with a valid handler was successful, the ASR processing shall
670       * be done with ASR processing disabled.
671       */
672      CheckHandlerMode( ctx, RTEMS_ASR_MASK, RTEMS_NO_ASR );
673      break;
674    }
675
676    case RtemsSignalReqCatch_Post_ASR_NA:
677      break;
678  }
679}
680
681static void RtemsSignalReqCatch_Post_IntLvl_Check(
682  RtemsSignalReqCatch_Context    *ctx,
683  RtemsSignalReqCatch_Post_IntLvl state
684)
685{
686  switch ( state ) {
687    case RtemsSignalReqCatch_Post_IntLvl_Zero: {
688      /*
689       * When a signal set is sent to the caller of rtems_signal_catch() and
690       * the call with a valid handler was successful, the ASR processing shall
691       * be done with interrupts enabled.
692       */
693      CheckHandlerMode( ctx, RTEMS_INTERRUPT_MASK, RTEMS_INTERRUPT_LEVEL( 0 ) );
694      break;
695    }
696
697    case RtemsSignalReqCatch_Post_IntLvl_Positive: {
698      /*
699       * When a signal set is sent to the caller of rtems_signal_catch() and
700       * the call with a valid handler was successful, the ASR processing shall
701       * be done with interrupts disabled according to the specified interrupt
702       * level.
703       */
704      CheckHandlerMode( ctx, RTEMS_INTERRUPT_MASK, RTEMS_INTERRUPT_LEVEL( 1 ) );
705      break;
706    }
707
708    case RtemsSignalReqCatch_Post_IntLvl_NA:
709      break;
710  }
711}
712
713static void RtemsSignalReqCatch_Setup( RtemsSignalReqCatch_Context *ctx )
714{
715  memset( ctx, 0, sizeof( *ctx ) );
716  ctx->runner_id = rtems_task_self();
717  _SMP_barrier_Control_initialize( &ctx->barrier );
718  _SMP_barrier_State_initialize( &ctx->runner_barrier_state );
719
720  if ( rtems_scheduler_get_processor_maximum() > 1 ) {
721    rtems_status_code sc;
722    rtems_id          scheduler_id;
723
724    sc = rtems_task_create(
725      rtems_build_name( 'W', 'O', 'R', 'K' ),
726      1,
727      RTEMS_MINIMUM_STACK_SIZE,
728      RTEMS_DEFAULT_MODES,
729      RTEMS_DEFAULT_ATTRIBUTES,
730      &ctx->worker_id
731    );
732    T_assert_rsc_success( sc );
733
734    sc = rtems_scheduler_ident_by_processor( 1, &scheduler_id );
735    T_assert_rsc_success( sc );
736
737    sc = rtems_task_set_scheduler( ctx->worker_id, scheduler_id, 1 );
738    T_assert_rsc_success( sc );
739
740    sc = rtems_task_start(
741      ctx->worker_id,
742      Worker,
743      (rtems_task_argument) ctx
744    );
745    T_assert_rsc_success( sc );
746  }
747}
748
749static void RtemsSignalReqCatch_Setup_Wrap( void *arg )
750{
751  RtemsSignalReqCatch_Context *ctx;
752
753  ctx = arg;
754  ctx->in_action_loop = false;
755  RtemsSignalReqCatch_Setup( ctx );
756}
757
758static void RtemsSignalReqCatch_Teardown( RtemsSignalReqCatch_Context *ctx )
759{
760  rtems_status_code sc;
761
762  if ( ctx->worker_id != 0 ) {
763    sc = rtems_task_delete( ctx->worker_id );
764    T_rsc_success( sc );
765  }
766
767  sc = rtems_signal_catch( NULL, RTEMS_DEFAULT_MODES );
768  T_rsc_success( sc );
769}
770
771static void RtemsSignalReqCatch_Teardown_Wrap( void *arg )
772{
773  RtemsSignalReqCatch_Context *ctx;
774
775  ctx = arg;
776  ctx->in_action_loop = false;
777  RtemsSignalReqCatch_Teardown( ctx );
778}
779
780static size_t RtemsSignalReqCatch_Scope( void *arg, char *buf, size_t n )
781{
782  RtemsSignalReqCatch_Context *ctx;
783
784  ctx = arg;
785
786  if ( ctx->in_action_loop ) {
787    return T_get_scope( RtemsSignalReqCatch_PreDesc, buf, n, ctx->pcs );
788  }
789
790  return 0;
791}
792
793static T_fixture RtemsSignalReqCatch_Fixture = {
794  .setup = RtemsSignalReqCatch_Setup_Wrap,
795  .stop = NULL,
796  .teardown = RtemsSignalReqCatch_Teardown_Wrap,
797  .scope = RtemsSignalReqCatch_Scope,
798  .initial_context = &RtemsSignalReqCatch_Instance
799};
800
801static const uint8_t RtemsSignalReqCatch_TransitionMap[][ 6 ] = {
802  {
803    RtemsSignalReqCatch_Post_Status_Ok,
804    RtemsSignalReqCatch_Post_Send_NotDef,
805    RtemsSignalReqCatch_Post_Preempt_Yes,
806    RtemsSignalReqCatch_Post_Timeslice_Yes,
807    RtemsSignalReqCatch_Post_ASR_Yes,
808    RtemsSignalReqCatch_Post_IntLvl_Zero
809  }, {
810    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
811    RtemsSignalReqCatch_Post_Send_NotDef,
812    RtemsSignalReqCatch_Post_Preempt_Yes,
813    RtemsSignalReqCatch_Post_Timeslice_Yes,
814    RtemsSignalReqCatch_Post_ASR_Yes,
815    RtemsSignalReqCatch_Post_IntLvl_Positive
816  }, {
817    RtemsSignalReqCatch_Post_Status_Ok,
818    RtemsSignalReqCatch_Post_Send_NotDef,
819    RtemsSignalReqCatch_Post_Preempt_Yes,
820    RtemsSignalReqCatch_Post_Timeslice_Yes,
821    RtemsSignalReqCatch_Post_ASR_No,
822    RtemsSignalReqCatch_Post_IntLvl_Zero
823  }, {
824    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
825    RtemsSignalReqCatch_Post_Send_NotDef,
826    RtemsSignalReqCatch_Post_Preempt_Yes,
827    RtemsSignalReqCatch_Post_Timeslice_Yes,
828    RtemsSignalReqCatch_Post_ASR_No,
829    RtemsSignalReqCatch_Post_IntLvl_Positive
830  }, {
831    RtemsSignalReqCatch_Post_Status_Ok,
832    RtemsSignalReqCatch_Post_Send_NotDef,
833    RtemsSignalReqCatch_Post_Preempt_Yes,
834    RtemsSignalReqCatch_Post_Timeslice_No,
835    RtemsSignalReqCatch_Post_ASR_Yes,
836    RtemsSignalReqCatch_Post_IntLvl_Zero
837  }, {
838    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
839    RtemsSignalReqCatch_Post_Send_NotDef,
840    RtemsSignalReqCatch_Post_Preempt_Yes,
841    RtemsSignalReqCatch_Post_Timeslice_No,
842    RtemsSignalReqCatch_Post_ASR_Yes,
843    RtemsSignalReqCatch_Post_IntLvl_Positive
844  }, {
845    RtemsSignalReqCatch_Post_Status_Ok,
846    RtemsSignalReqCatch_Post_Send_NotDef,
847    RtemsSignalReqCatch_Post_Preempt_Yes,
848    RtemsSignalReqCatch_Post_Timeslice_No,
849    RtemsSignalReqCatch_Post_ASR_No,
850    RtemsSignalReqCatch_Post_IntLvl_Zero
851  }, {
852    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
853    RtemsSignalReqCatch_Post_Send_NotDef,
854    RtemsSignalReqCatch_Post_Preempt_Yes,
855    RtemsSignalReqCatch_Post_Timeslice_No,
856    RtemsSignalReqCatch_Post_ASR_No,
857    RtemsSignalReqCatch_Post_IntLvl_Positive
858  }, {
859    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
860    RtemsSignalReqCatch_Post_Send_NotDef,
861    RtemsSignalReqCatch_Post_Preempt_No,
862    RtemsSignalReqCatch_Post_Timeslice_Yes,
863    RtemsSignalReqCatch_Post_ASR_Yes,
864    RtemsSignalReqCatch_Post_IntLvl_Zero
865  }, {
866    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
867    RtemsSignalReqCatch_Post_Send_NotDef,
868    RtemsSignalReqCatch_Post_Preempt_No,
869    RtemsSignalReqCatch_Post_Timeslice_Yes,
870    RtemsSignalReqCatch_Post_ASR_Yes,
871    RtemsSignalReqCatch_Post_IntLvl_Positive
872  }, {
873    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
874    RtemsSignalReqCatch_Post_Send_NotDef,
875    RtemsSignalReqCatch_Post_Preempt_No,
876    RtemsSignalReqCatch_Post_Timeslice_Yes,
877    RtemsSignalReqCatch_Post_ASR_No,
878    RtemsSignalReqCatch_Post_IntLvl_Zero
879  }, {
880    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
881    RtemsSignalReqCatch_Post_Send_NotDef,
882    RtemsSignalReqCatch_Post_Preempt_No,
883    RtemsSignalReqCatch_Post_Timeslice_Yes,
884    RtemsSignalReqCatch_Post_ASR_No,
885    RtemsSignalReqCatch_Post_IntLvl_Positive
886  }, {
887    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
888    RtemsSignalReqCatch_Post_Send_NotDef,
889    RtemsSignalReqCatch_Post_Preempt_No,
890    RtemsSignalReqCatch_Post_Timeslice_No,
891    RtemsSignalReqCatch_Post_ASR_Yes,
892    RtemsSignalReqCatch_Post_IntLvl_Zero
893  }, {
894    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
895    RtemsSignalReqCatch_Post_Send_NotDef,
896    RtemsSignalReqCatch_Post_Preempt_No,
897    RtemsSignalReqCatch_Post_Timeslice_No,
898    RtemsSignalReqCatch_Post_ASR_Yes,
899    RtemsSignalReqCatch_Post_IntLvl_Positive
900  }, {
901    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
902    RtemsSignalReqCatch_Post_Send_NotDef,
903    RtemsSignalReqCatch_Post_Preempt_No,
904    RtemsSignalReqCatch_Post_Timeslice_No,
905    RtemsSignalReqCatch_Post_ASR_No,
906    RtemsSignalReqCatch_Post_IntLvl_Zero
907  }, {
908    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
909    RtemsSignalReqCatch_Post_Send_NotDef,
910    RtemsSignalReqCatch_Post_Preempt_No,
911    RtemsSignalReqCatch_Post_Timeslice_No,
912    RtemsSignalReqCatch_Post_ASR_No,
913    RtemsSignalReqCatch_Post_IntLvl_Positive
914  }, {
915    RtemsSignalReqCatch_Post_Status_Ok,
916    RtemsSignalReqCatch_Post_Send_New,
917    RtemsSignalReqCatch_Post_Preempt_Yes,
918    RtemsSignalReqCatch_Post_Timeslice_Yes,
919    RtemsSignalReqCatch_Post_ASR_Yes,
920    RtemsSignalReqCatch_Post_IntLvl_Zero
921  }, {
922    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
923    RtemsSignalReqCatch_Post_Send_New,
924    RtemsSignalReqCatch_Post_Preempt_Yes,
925    RtemsSignalReqCatch_Post_Timeslice_Yes,
926    RtemsSignalReqCatch_Post_ASR_Yes,
927    RtemsSignalReqCatch_Post_IntLvl_Positive
928  }, {
929    RtemsSignalReqCatch_Post_Status_Ok,
930    RtemsSignalReqCatch_Post_Send_New,
931    RtemsSignalReqCatch_Post_Preempt_Yes,
932    RtemsSignalReqCatch_Post_Timeslice_Yes,
933    RtemsSignalReqCatch_Post_ASR_No,
934    RtemsSignalReqCatch_Post_IntLvl_Zero
935  }, {
936    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
937    RtemsSignalReqCatch_Post_Send_New,
938    RtemsSignalReqCatch_Post_Preempt_Yes,
939    RtemsSignalReqCatch_Post_Timeslice_Yes,
940    RtemsSignalReqCatch_Post_ASR_No,
941    RtemsSignalReqCatch_Post_IntLvl_Positive
942  }, {
943    RtemsSignalReqCatch_Post_Status_Ok,
944    RtemsSignalReqCatch_Post_Send_New,
945    RtemsSignalReqCatch_Post_Preempt_Yes,
946    RtemsSignalReqCatch_Post_Timeslice_No,
947    RtemsSignalReqCatch_Post_ASR_Yes,
948    RtemsSignalReqCatch_Post_IntLvl_Zero
949  }, {
950    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
951    RtemsSignalReqCatch_Post_Send_New,
952    RtemsSignalReqCatch_Post_Preempt_Yes,
953    RtemsSignalReqCatch_Post_Timeslice_No,
954    RtemsSignalReqCatch_Post_ASR_Yes,
955    RtemsSignalReqCatch_Post_IntLvl_Positive
956  }, {
957    RtemsSignalReqCatch_Post_Status_Ok,
958    RtemsSignalReqCatch_Post_Send_New,
959    RtemsSignalReqCatch_Post_Preempt_Yes,
960    RtemsSignalReqCatch_Post_Timeslice_No,
961    RtemsSignalReqCatch_Post_ASR_No,
962    RtemsSignalReqCatch_Post_IntLvl_Zero
963  }, {
964    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
965    RtemsSignalReqCatch_Post_Send_New,
966    RtemsSignalReqCatch_Post_Preempt_Yes,
967    RtemsSignalReqCatch_Post_Timeslice_No,
968    RtemsSignalReqCatch_Post_ASR_No,
969    RtemsSignalReqCatch_Post_IntLvl_Positive
970  }, {
971    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
972    RtemsSignalReqCatch_Post_Send_New,
973    RtemsSignalReqCatch_Post_Preempt_No,
974    RtemsSignalReqCatch_Post_Timeslice_Yes,
975    RtemsSignalReqCatch_Post_ASR_Yes,
976    RtemsSignalReqCatch_Post_IntLvl_Zero
977  }, {
978    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
979    RtemsSignalReqCatch_Post_Send_New,
980    RtemsSignalReqCatch_Post_Preempt_No,
981    RtemsSignalReqCatch_Post_Timeslice_Yes,
982    RtemsSignalReqCatch_Post_ASR_Yes,
983    RtemsSignalReqCatch_Post_IntLvl_Positive
984  }, {
985    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
986    RtemsSignalReqCatch_Post_Send_New,
987    RtemsSignalReqCatch_Post_Preempt_No,
988    RtemsSignalReqCatch_Post_Timeslice_Yes,
989    RtemsSignalReqCatch_Post_ASR_No,
990    RtemsSignalReqCatch_Post_IntLvl_Zero
991  }, {
992    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
993    RtemsSignalReqCatch_Post_Send_New,
994    RtemsSignalReqCatch_Post_Preempt_No,
995    RtemsSignalReqCatch_Post_Timeslice_Yes,
996    RtemsSignalReqCatch_Post_ASR_No,
997    RtemsSignalReqCatch_Post_IntLvl_Positive
998  }, {
999    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1000    RtemsSignalReqCatch_Post_Send_New,
1001    RtemsSignalReqCatch_Post_Preempt_No,
1002    RtemsSignalReqCatch_Post_Timeslice_No,
1003    RtemsSignalReqCatch_Post_ASR_Yes,
1004    RtemsSignalReqCatch_Post_IntLvl_Zero
1005  }, {
1006    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1007    RtemsSignalReqCatch_Post_Send_New,
1008    RtemsSignalReqCatch_Post_Preempt_No,
1009    RtemsSignalReqCatch_Post_Timeslice_No,
1010    RtemsSignalReqCatch_Post_ASR_Yes,
1011    RtemsSignalReqCatch_Post_IntLvl_Positive
1012  }, {
1013    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1014    RtemsSignalReqCatch_Post_Send_New,
1015    RtemsSignalReqCatch_Post_Preempt_No,
1016    RtemsSignalReqCatch_Post_Timeslice_No,
1017    RtemsSignalReqCatch_Post_ASR_No,
1018    RtemsSignalReqCatch_Post_IntLvl_Zero
1019  }, {
1020    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1021    RtemsSignalReqCatch_Post_Send_New,
1022    RtemsSignalReqCatch_Post_Preempt_No,
1023    RtemsSignalReqCatch_Post_Timeslice_No,
1024    RtemsSignalReqCatch_Post_ASR_No,
1025    RtemsSignalReqCatch_Post_IntLvl_Positive
1026  }, {
1027    RtemsSignalReqCatch_Post_Status_Ok,
1028    RtemsSignalReqCatch_Post_Send_NotDef,
1029    RtemsSignalReqCatch_Post_Preempt_Yes,
1030    RtemsSignalReqCatch_Post_Timeslice_Yes,
1031    RtemsSignalReqCatch_Post_ASR_Yes,
1032    RtemsSignalReqCatch_Post_IntLvl_Zero
1033  }, {
1034    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1035    RtemsSignalReqCatch_Post_Send_NotDef,
1036    RtemsSignalReqCatch_Post_Preempt_Yes,
1037    RtemsSignalReqCatch_Post_Timeslice_Yes,
1038    RtemsSignalReqCatch_Post_ASR_Yes,
1039    RtemsSignalReqCatch_Post_IntLvl_Positive
1040  }, {
1041    RtemsSignalReqCatch_Post_Status_Ok,
1042    RtemsSignalReqCatch_Post_Send_NotDef,
1043    RtemsSignalReqCatch_Post_Preempt_Yes,
1044    RtemsSignalReqCatch_Post_Timeslice_Yes,
1045    RtemsSignalReqCatch_Post_ASR_No,
1046    RtemsSignalReqCatch_Post_IntLvl_Zero
1047  }, {
1048    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1049    RtemsSignalReqCatch_Post_Send_NotDef,
1050    RtemsSignalReqCatch_Post_Preempt_Yes,
1051    RtemsSignalReqCatch_Post_Timeslice_Yes,
1052    RtemsSignalReqCatch_Post_ASR_No,
1053    RtemsSignalReqCatch_Post_IntLvl_Positive
1054  }, {
1055    RtemsSignalReqCatch_Post_Status_Ok,
1056    RtemsSignalReqCatch_Post_Send_NotDef,
1057    RtemsSignalReqCatch_Post_Preempt_Yes,
1058    RtemsSignalReqCatch_Post_Timeslice_No,
1059    RtemsSignalReqCatch_Post_ASR_Yes,
1060    RtemsSignalReqCatch_Post_IntLvl_Zero
1061  }, {
1062    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1063    RtemsSignalReqCatch_Post_Send_NotDef,
1064    RtemsSignalReqCatch_Post_Preempt_Yes,
1065    RtemsSignalReqCatch_Post_Timeslice_No,
1066    RtemsSignalReqCatch_Post_ASR_Yes,
1067    RtemsSignalReqCatch_Post_IntLvl_Positive
1068  }, {
1069    RtemsSignalReqCatch_Post_Status_Ok,
1070    RtemsSignalReqCatch_Post_Send_NotDef,
1071    RtemsSignalReqCatch_Post_Preempt_Yes,
1072    RtemsSignalReqCatch_Post_Timeslice_No,
1073    RtemsSignalReqCatch_Post_ASR_No,
1074    RtemsSignalReqCatch_Post_IntLvl_Zero
1075  }, {
1076    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1077    RtemsSignalReqCatch_Post_Send_NotDef,
1078    RtemsSignalReqCatch_Post_Preempt_Yes,
1079    RtemsSignalReqCatch_Post_Timeslice_No,
1080    RtemsSignalReqCatch_Post_ASR_No,
1081    RtemsSignalReqCatch_Post_IntLvl_Positive
1082  }, {
1083    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1084    RtemsSignalReqCatch_Post_Send_NotDef,
1085    RtemsSignalReqCatch_Post_Preempt_No,
1086    RtemsSignalReqCatch_Post_Timeslice_Yes,
1087    RtemsSignalReqCatch_Post_ASR_Yes,
1088    RtemsSignalReqCatch_Post_IntLvl_Zero
1089  }, {
1090    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1091    RtemsSignalReqCatch_Post_Send_NotDef,
1092    RtemsSignalReqCatch_Post_Preempt_No,
1093    RtemsSignalReqCatch_Post_Timeslice_Yes,
1094    RtemsSignalReqCatch_Post_ASR_Yes,
1095    RtemsSignalReqCatch_Post_IntLvl_Positive
1096  }, {
1097    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1098    RtemsSignalReqCatch_Post_Send_NotDef,
1099    RtemsSignalReqCatch_Post_Preempt_No,
1100    RtemsSignalReqCatch_Post_Timeslice_Yes,
1101    RtemsSignalReqCatch_Post_ASR_No,
1102    RtemsSignalReqCatch_Post_IntLvl_Zero
1103  }, {
1104    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1105    RtemsSignalReqCatch_Post_Send_NotDef,
1106    RtemsSignalReqCatch_Post_Preempt_No,
1107    RtemsSignalReqCatch_Post_Timeslice_Yes,
1108    RtemsSignalReqCatch_Post_ASR_No,
1109    RtemsSignalReqCatch_Post_IntLvl_Positive
1110  }, {
1111    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1112    RtemsSignalReqCatch_Post_Send_NotDef,
1113    RtemsSignalReqCatch_Post_Preempt_No,
1114    RtemsSignalReqCatch_Post_Timeslice_No,
1115    RtemsSignalReqCatch_Post_ASR_Yes,
1116    RtemsSignalReqCatch_Post_IntLvl_Zero
1117  }, {
1118    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1119    RtemsSignalReqCatch_Post_Send_NotDef,
1120    RtemsSignalReqCatch_Post_Preempt_No,
1121    RtemsSignalReqCatch_Post_Timeslice_No,
1122    RtemsSignalReqCatch_Post_ASR_Yes,
1123    RtemsSignalReqCatch_Post_IntLvl_Positive
1124  }, {
1125    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1126    RtemsSignalReqCatch_Post_Send_NotDef,
1127    RtemsSignalReqCatch_Post_Preempt_No,
1128    RtemsSignalReqCatch_Post_Timeslice_No,
1129    RtemsSignalReqCatch_Post_ASR_No,
1130    RtemsSignalReqCatch_Post_IntLvl_Zero
1131  }, {
1132    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1133    RtemsSignalReqCatch_Post_Send_NotDef,
1134    RtemsSignalReqCatch_Post_Preempt_No,
1135    RtemsSignalReqCatch_Post_Timeslice_No,
1136    RtemsSignalReqCatch_Post_ASR_No,
1137    RtemsSignalReqCatch_Post_IntLvl_Positive
1138  }, {
1139    RtemsSignalReqCatch_Post_Status_Ok,
1140    RtemsSignalReqCatch_Post_Send_New,
1141    RtemsSignalReqCatch_Post_Preempt_Yes,
1142    RtemsSignalReqCatch_Post_Timeslice_Yes,
1143    RtemsSignalReqCatch_Post_ASR_Yes,
1144    RtemsSignalReqCatch_Post_IntLvl_Zero
1145  }, {
1146    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1147    RtemsSignalReqCatch_Post_Send_New,
1148    RtemsSignalReqCatch_Post_Preempt_Yes,
1149    RtemsSignalReqCatch_Post_Timeslice_Yes,
1150    RtemsSignalReqCatch_Post_ASR_Yes,
1151    RtemsSignalReqCatch_Post_IntLvl_Positive
1152  }, {
1153    RtemsSignalReqCatch_Post_Status_Ok,
1154    RtemsSignalReqCatch_Post_Send_New,
1155    RtemsSignalReqCatch_Post_Preempt_Yes,
1156    RtemsSignalReqCatch_Post_Timeslice_Yes,
1157    RtemsSignalReqCatch_Post_ASR_No,
1158    RtemsSignalReqCatch_Post_IntLvl_Zero
1159  }, {
1160    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1161    RtemsSignalReqCatch_Post_Send_New,
1162    RtemsSignalReqCatch_Post_Preempt_Yes,
1163    RtemsSignalReqCatch_Post_Timeslice_Yes,
1164    RtemsSignalReqCatch_Post_ASR_No,
1165    RtemsSignalReqCatch_Post_IntLvl_Positive
1166  }, {
1167    RtemsSignalReqCatch_Post_Status_Ok,
1168    RtemsSignalReqCatch_Post_Send_New,
1169    RtemsSignalReqCatch_Post_Preempt_Yes,
1170    RtemsSignalReqCatch_Post_Timeslice_No,
1171    RtemsSignalReqCatch_Post_ASR_Yes,
1172    RtemsSignalReqCatch_Post_IntLvl_Zero
1173  }, {
1174    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1175    RtemsSignalReqCatch_Post_Send_New,
1176    RtemsSignalReqCatch_Post_Preempt_Yes,
1177    RtemsSignalReqCatch_Post_Timeslice_No,
1178    RtemsSignalReqCatch_Post_ASR_Yes,
1179    RtemsSignalReqCatch_Post_IntLvl_Positive
1180  }, {
1181    RtemsSignalReqCatch_Post_Status_Ok,
1182    RtemsSignalReqCatch_Post_Send_New,
1183    RtemsSignalReqCatch_Post_Preempt_Yes,
1184    RtemsSignalReqCatch_Post_Timeslice_No,
1185    RtemsSignalReqCatch_Post_ASR_No,
1186    RtemsSignalReqCatch_Post_IntLvl_Zero
1187  }, {
1188    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1189    RtemsSignalReqCatch_Post_Send_New,
1190    RtemsSignalReqCatch_Post_Preempt_Yes,
1191    RtemsSignalReqCatch_Post_Timeslice_No,
1192    RtemsSignalReqCatch_Post_ASR_No,
1193    RtemsSignalReqCatch_Post_IntLvl_Positive
1194  }, {
1195    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1196    RtemsSignalReqCatch_Post_Send_New,
1197    RtemsSignalReqCatch_Post_Preempt_No,
1198    RtemsSignalReqCatch_Post_Timeslice_Yes,
1199    RtemsSignalReqCatch_Post_ASR_Yes,
1200    RtemsSignalReqCatch_Post_IntLvl_Zero
1201  }, {
1202    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1203    RtemsSignalReqCatch_Post_Send_New,
1204    RtemsSignalReqCatch_Post_Preempt_No,
1205    RtemsSignalReqCatch_Post_Timeslice_Yes,
1206    RtemsSignalReqCatch_Post_ASR_Yes,
1207    RtemsSignalReqCatch_Post_IntLvl_Positive
1208  }, {
1209    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1210    RtemsSignalReqCatch_Post_Send_New,
1211    RtemsSignalReqCatch_Post_Preempt_No,
1212    RtemsSignalReqCatch_Post_Timeslice_Yes,
1213    RtemsSignalReqCatch_Post_ASR_No,
1214    RtemsSignalReqCatch_Post_IntLvl_Zero
1215  }, {
1216    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1217    RtemsSignalReqCatch_Post_Send_New,
1218    RtemsSignalReqCatch_Post_Preempt_No,
1219    RtemsSignalReqCatch_Post_Timeslice_Yes,
1220    RtemsSignalReqCatch_Post_ASR_No,
1221    RtemsSignalReqCatch_Post_IntLvl_Positive
1222  }, {
1223    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1224    RtemsSignalReqCatch_Post_Send_New,
1225    RtemsSignalReqCatch_Post_Preempt_No,
1226    RtemsSignalReqCatch_Post_Timeslice_No,
1227    RtemsSignalReqCatch_Post_ASR_Yes,
1228    RtemsSignalReqCatch_Post_IntLvl_Zero
1229  }, {
1230    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1231    RtemsSignalReqCatch_Post_Send_New,
1232    RtemsSignalReqCatch_Post_Preempt_No,
1233    RtemsSignalReqCatch_Post_Timeslice_No,
1234    RtemsSignalReqCatch_Post_ASR_Yes,
1235    RtemsSignalReqCatch_Post_IntLvl_Positive
1236  }, {
1237    RtemsSignalReqCatch_Post_Status_NotImplNoPreempt,
1238    RtemsSignalReqCatch_Post_Send_New,
1239    RtemsSignalReqCatch_Post_Preempt_No,
1240    RtemsSignalReqCatch_Post_Timeslice_No,
1241    RtemsSignalReqCatch_Post_ASR_No,
1242    RtemsSignalReqCatch_Post_IntLvl_Zero
1243  }, {
1244    RtemsSignalReqCatch_Post_Status_NotImplIntLvl,
1245    RtemsSignalReqCatch_Post_Send_New,
1246    RtemsSignalReqCatch_Post_Preempt_No,
1247    RtemsSignalReqCatch_Post_Timeslice_No,
1248    RtemsSignalReqCatch_Post_ASR_No,
1249    RtemsSignalReqCatch_Post_IntLvl_Positive
1250  }
1251};
1252
1253static const struct {
1254  uint8_t Skip : 1;
1255  uint8_t Pre_Pending_NA : 1;
1256  uint8_t Pre_Handler_NA : 1;
1257  uint8_t Pre_Preempt_NA : 1;
1258  uint8_t Pre_Timeslice_NA : 1;
1259  uint8_t Pre_ASR_NA : 1;
1260  uint8_t Pre_IntLvl_NA : 1;
1261} RtemsSignalReqCatch_TransitionInfo[] = {
1262  {
1263    0, 0, 0, 0, 0, 0, 0
1264  }, {
1265    0, 0, 0, 0, 0, 0, 0
1266  }, {
1267    0, 0, 0, 0, 0, 0, 0
1268  }, {
1269    0, 0, 0, 0, 0, 0, 0
1270  }, {
1271    0, 0, 0, 0, 0, 0, 0
1272  }, {
1273    0, 0, 0, 0, 0, 0, 0
1274  }, {
1275    0, 0, 0, 0, 0, 0, 0
1276  }, {
1277    0, 0, 0, 0, 0, 0, 0
1278  }, {
1279    0, 0, 0, 0, 0, 0, 0
1280  }, {
1281    0, 0, 0, 0, 0, 0, 0
1282  }, {
1283    0, 0, 0, 0, 0, 0, 0
1284  }, {
1285    0, 0, 0, 0, 0, 0, 0
1286  }, {
1287    0, 0, 0, 0, 0, 0, 0
1288  }, {
1289    0, 0, 0, 0, 0, 0, 0
1290  }, {
1291    0, 0, 0, 0, 0, 0, 0
1292  }, {
1293    0, 0, 0, 0, 0, 0, 0
1294  }, {
1295    0, 0, 0, 0, 0, 0, 0
1296  }, {
1297    0, 0, 0, 0, 0, 0, 0
1298  }, {
1299    0, 0, 0, 0, 0, 0, 0
1300  }, {
1301    0, 0, 0, 0, 0, 0, 0
1302  }, {
1303    0, 0, 0, 0, 0, 0, 0
1304  }, {
1305    0, 0, 0, 0, 0, 0, 0
1306  }, {
1307    0, 0, 0, 0, 0, 0, 0
1308  }, {
1309    0, 0, 0, 0, 0, 0, 0
1310  }, {
1311    0, 0, 0, 0, 0, 0, 0
1312  }, {
1313    0, 0, 0, 0, 0, 0, 0
1314  }, {
1315    0, 0, 0, 0, 0, 0, 0
1316  }, {
1317    0, 0, 0, 0, 0, 0, 0
1318  }, {
1319    0, 0, 0, 0, 0, 0, 0
1320  }, {
1321    0, 0, 0, 0, 0, 0, 0
1322  }, {
1323    0, 0, 0, 0, 0, 0, 0
1324  }, {
1325    0, 0, 0, 0, 0, 0, 0
1326  }, {
1327    0, 0, 0, 0, 0, 0, 0
1328  }, {
1329    0, 0, 0, 0, 0, 0, 0
1330  }, {
1331    0, 0, 0, 0, 0, 0, 0
1332  }, {
1333    0, 0, 0, 0, 0, 0, 0
1334  }, {
1335    0, 0, 0, 0, 0, 0, 0
1336  }, {
1337    0, 0, 0, 0, 0, 0, 0
1338  }, {
1339    0, 0, 0, 0, 0, 0, 0
1340  }, {
1341    0, 0, 0, 0, 0, 0, 0
1342  }, {
1343    0, 0, 0, 0, 0, 0, 0
1344  }, {
1345    0, 0, 0, 0, 0, 0, 0
1346  }, {
1347    0, 0, 0, 0, 0, 0, 0
1348  }, {
1349    0, 0, 0, 0, 0, 0, 0
1350  }, {
1351    0, 0, 0, 0, 0, 0, 0
1352  }, {
1353    0, 0, 0, 0, 0, 0, 0
1354  }, {
1355    0, 0, 0, 0, 0, 0, 0
1356  }, {
1357    0, 0, 0, 0, 0, 0, 0
1358  }, {
1359    0, 0, 0, 0, 0, 0, 0
1360  }, {
1361    0, 0, 0, 0, 0, 0, 0
1362  }, {
1363    0, 0, 0, 0, 0, 0, 0
1364  }, {
1365    0, 0, 0, 0, 0, 0, 0
1366  }, {
1367    0, 0, 0, 0, 0, 0, 0
1368  }, {
1369    0, 0, 0, 0, 0, 0, 0
1370  }, {
1371    0, 0, 0, 0, 0, 0, 0
1372  }, {
1373    0, 0, 0, 0, 0, 0, 0
1374  }, {
1375    0, 0, 0, 0, 0, 0, 0
1376  }, {
1377    0, 0, 0, 0, 0, 0, 0
1378  }, {
1379    0, 0, 0, 0, 0, 0, 0
1380  }, {
1381    0, 0, 0, 0, 0, 0, 0
1382  }, {
1383    0, 0, 0, 0, 0, 0, 0
1384  }, {
1385    0, 0, 0, 0, 0, 0, 0
1386  }, {
1387    0, 0, 0, 0, 0, 0, 0
1388  }, {
1389    0, 0, 0, 0, 0, 0, 0
1390  }
1391};
1392
1393static void RtemsSignalReqCatch_Prepare( RtemsSignalReqCatch_Context *ctx )
1394{
1395  rtems_status_code sc;
1396
1397  ctx->default_handler_calls = 0;
1398  ctx->handler_calls = 0;
1399  ctx->handler_mode = 0xffffffff;
1400  ctx->normal_mode = RTEMS_DEFAULT_MODES;
1401  ctx->handler = NULL;
1402  ctx->mode = RTEMS_DEFAULT_MODES;
1403
1404  sc = rtems_signal_catch( DefaultHandler, RTEMS_NO_ASR );
1405  T_rsc_success( sc );
1406}
1407
1408static void RtemsSignalReqCatch_Action( RtemsSignalReqCatch_Context *ctx )
1409{
1410  rtems_status_code sc;
1411  rtems_mode        mode;
1412
1413  if ( ctx->pending_signals != 0 ) {
1414    rtems_interrupt_level level;
1415
1416    rtems_interrupt_local_disable(level);
1417    _SMP_barrier_Wait( &ctx->barrier, &ctx->runner_barrier_state, 2 );
1418    _SMP_barrier_Wait( &ctx->barrier, &ctx->runner_barrier_state, 2 );
1419    ctx->catch_status = rtems_signal_catch( ctx->handler, ctx->mode );
1420    rtems_interrupt_local_enable(level);
1421  } else {
1422    ctx->catch_status = rtems_signal_catch( ctx->handler, ctx->mode );
1423  }
1424
1425  sc = rtems_task_mode( ctx->normal_mode, RTEMS_ALL_MODE_MASKS, &mode );
1426  T_rsc_success( sc );
1427
1428  ctx->send_status = rtems_signal_send( RTEMS_SELF, 0xdeadbeef );
1429
1430  sc = rtems_task_mode( mode, RTEMS_ALL_MODE_MASKS, &mode );
1431  T_rsc_success( sc );
1432}
1433
1434/**
1435 * @fn void T_case_body_RtemsSignalReqCatch( void )
1436 */
1437T_TEST_CASE_FIXTURE( RtemsSignalReqCatch, &RtemsSignalReqCatch_Fixture )
1438{
1439  RtemsSignalReqCatch_Context *ctx;
1440  size_t index;
1441
1442  ctx = T_fixture_context();
1443  ctx->in_action_loop = true;
1444  index = 0;
1445
1446  for (
1447    ctx->pcs[ 0 ] = RtemsSignalReqCatch_Pre_Pending_Yes;
1448    ctx->pcs[ 0 ] < RtemsSignalReqCatch_Pre_Pending_NA;
1449    ++ctx->pcs[ 0 ]
1450  ) {
1451    if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Pending_NA ) {
1452      ctx->pcs[ 0 ] = RtemsSignalReqCatch_Pre_Pending_NA;
1453      index += ( RtemsSignalReqCatch_Pre_Pending_NA - 1 )
1454        * RtemsSignalReqCatch_Pre_Handler_NA
1455        * RtemsSignalReqCatch_Pre_Preempt_NA
1456        * RtemsSignalReqCatch_Pre_Timeslice_NA
1457        * RtemsSignalReqCatch_Pre_ASR_NA
1458        * RtemsSignalReqCatch_Pre_IntLvl_NA;
1459    }
1460
1461    for (
1462      ctx->pcs[ 1 ] = RtemsSignalReqCatch_Pre_Handler_Invalid;
1463      ctx->pcs[ 1 ] < RtemsSignalReqCatch_Pre_Handler_NA;
1464      ++ctx->pcs[ 1 ]
1465    ) {
1466      if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Handler_NA ) {
1467        ctx->pcs[ 1 ] = RtemsSignalReqCatch_Pre_Handler_NA;
1468        index += ( RtemsSignalReqCatch_Pre_Handler_NA - 1 )
1469          * RtemsSignalReqCatch_Pre_Preempt_NA
1470          * RtemsSignalReqCatch_Pre_Timeslice_NA
1471          * RtemsSignalReqCatch_Pre_ASR_NA
1472          * RtemsSignalReqCatch_Pre_IntLvl_NA;
1473      }
1474
1475      for (
1476        ctx->pcs[ 2 ] = RtemsSignalReqCatch_Pre_Preempt_Yes;
1477        ctx->pcs[ 2 ] < RtemsSignalReqCatch_Pre_Preempt_NA;
1478        ++ctx->pcs[ 2 ]
1479      ) {
1480        if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Preempt_NA ) {
1481          ctx->pcs[ 2 ] = RtemsSignalReqCatch_Pre_Preempt_NA;
1482          index += ( RtemsSignalReqCatch_Pre_Preempt_NA - 1 )
1483            * RtemsSignalReqCatch_Pre_Timeslice_NA
1484            * RtemsSignalReqCatch_Pre_ASR_NA
1485            * RtemsSignalReqCatch_Pre_IntLvl_NA;
1486        }
1487
1488        for (
1489          ctx->pcs[ 3 ] = RtemsSignalReqCatch_Pre_Timeslice_Yes;
1490          ctx->pcs[ 3 ] < RtemsSignalReqCatch_Pre_Timeslice_NA;
1491          ++ctx->pcs[ 3 ]
1492        ) {
1493          if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_Timeslice_NA ) {
1494            ctx->pcs[ 3 ] = RtemsSignalReqCatch_Pre_Timeslice_NA;
1495            index += ( RtemsSignalReqCatch_Pre_Timeslice_NA - 1 )
1496              * RtemsSignalReqCatch_Pre_ASR_NA
1497              * RtemsSignalReqCatch_Pre_IntLvl_NA;
1498          }
1499
1500          for (
1501            ctx->pcs[ 4 ] = RtemsSignalReqCatch_Pre_ASR_Yes;
1502            ctx->pcs[ 4 ] < RtemsSignalReqCatch_Pre_ASR_NA;
1503            ++ctx->pcs[ 4 ]
1504          ) {
1505            if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_ASR_NA ) {
1506              ctx->pcs[ 4 ] = RtemsSignalReqCatch_Pre_ASR_NA;
1507              index += ( RtemsSignalReqCatch_Pre_ASR_NA - 1 )
1508                * RtemsSignalReqCatch_Pre_IntLvl_NA;
1509            }
1510
1511            for (
1512              ctx->pcs[ 5 ] = RtemsSignalReqCatch_Pre_IntLvl_Zero;
1513              ctx->pcs[ 5 ] < RtemsSignalReqCatch_Pre_IntLvl_NA;
1514              ++ctx->pcs[ 5 ]
1515            ) {
1516              if ( RtemsSignalReqCatch_TransitionInfo[ index ].Pre_IntLvl_NA ) {
1517                ctx->pcs[ 5 ] = RtemsSignalReqCatch_Pre_IntLvl_NA;
1518                index += ( RtemsSignalReqCatch_Pre_IntLvl_NA - 1 );
1519              }
1520
1521              if ( RtemsSignalReqCatch_TransitionInfo[ index ].Skip ) {
1522                ++index;
1523                continue;
1524              }
1525
1526              RtemsSignalReqCatch_Prepare( ctx );
1527              RtemsSignalReqCatch_Pre_Pending_Prepare( ctx, ctx->pcs[ 0 ] );
1528              RtemsSignalReqCatch_Pre_Handler_Prepare( ctx, ctx->pcs[ 1 ] );
1529              RtemsSignalReqCatch_Pre_Preempt_Prepare( ctx, ctx->pcs[ 2 ] );
1530              RtemsSignalReqCatch_Pre_Timeslice_Prepare( ctx, ctx->pcs[ 3 ] );
1531              RtemsSignalReqCatch_Pre_ASR_Prepare( ctx, ctx->pcs[ 4 ] );
1532              RtemsSignalReqCatch_Pre_IntLvl_Prepare( ctx, ctx->pcs[ 5 ] );
1533              RtemsSignalReqCatch_Action( ctx );
1534              RtemsSignalReqCatch_Post_Status_Check(
1535                ctx,
1536                RtemsSignalReqCatch_TransitionMap[ index ][ 0 ]
1537              );
1538              RtemsSignalReqCatch_Post_Send_Check(
1539                ctx,
1540                RtemsSignalReqCatch_TransitionMap[ index ][ 1 ]
1541              );
1542              RtemsSignalReqCatch_Post_Preempt_Check(
1543                ctx,
1544                RtemsSignalReqCatch_TransitionMap[ index ][ 2 ]
1545              );
1546              RtemsSignalReqCatch_Post_Timeslice_Check(
1547                ctx,
1548                RtemsSignalReqCatch_TransitionMap[ index ][ 3 ]
1549              );
1550              RtemsSignalReqCatch_Post_ASR_Check(
1551                ctx,
1552                RtemsSignalReqCatch_TransitionMap[ index ][ 4 ]
1553              );
1554              RtemsSignalReqCatch_Post_IntLvl_Check(
1555                ctx,
1556                RtemsSignalReqCatch_TransitionMap[ index ][ 5 ]
1557              );
1558              ++index;
1559            }
1560          }
1561        }
1562      }
1563    }
1564  }
1565}
1566
1567/** @} */
Note: See TracBrowser for help on using the repository browser.