Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:52

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RtemsSignalReqSend
0007  */
0008 
0009 /*
0010  * Copyright (C) 2021 embedded brains GmbH & Co. KG
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 /*
0035  * This file is part of the RTEMS quality process and was automatically
0036  * generated.  If you find something that needs to be fixed or
0037  * worded better please post a report or patch to an RTEMS mailing list
0038  * or raise a bug report:
0039  *
0040  * https://www.rtems.org/bugs.html
0041  *
0042  * For information on updating and regenerating please refer to the How-To
0043  * section in the Software Requirements Engineering chapter of the
0044  * RTEMS Software Engineering manual.  The manual is provided as a part of
0045  * a release.  For development sources please refer to the online
0046  * documentation at:
0047  *
0048  * https://docs.rtems.org
0049  */
0050 
0051 #ifdef HAVE_CONFIG_H
0052 #include "config.h"
0053 #endif
0054 
0055 #include <rtems.h>
0056 
0057 #include "tx-support.h"
0058 
0059 #include <rtems/test.h>
0060 
0061 /**
0062  * @defgroup RtemsSignalReqSend spec:/rtems/signal/req/send
0063  *
0064  * @ingroup TestsuitesValidationNoClock0
0065  * @ingroup TestsuitesValidationOneCpu0
0066  *
0067  * @{
0068  */
0069 
0070 typedef enum {
0071   RtemsSignalReqSend_Pre_Task_NoObj,
0072   RtemsSignalReqSend_Pre_Task_Self,
0073   RtemsSignalReqSend_Pre_Task_Other,
0074   RtemsSignalReqSend_Pre_Task_NA
0075 } RtemsSignalReqSend_Pre_Task;
0076 
0077 typedef enum {
0078   RtemsSignalReqSend_Pre_Set_Zero,
0079   RtemsSignalReqSend_Pre_Set_NonZero,
0080   RtemsSignalReqSend_Pre_Set_NA
0081 } RtemsSignalReqSend_Pre_Set;
0082 
0083 typedef enum {
0084   RtemsSignalReqSend_Pre_Handler_Invalid,
0085   RtemsSignalReqSend_Pre_Handler_Valid,
0086   RtemsSignalReqSend_Pre_Handler_NA
0087 } RtemsSignalReqSend_Pre_Handler;
0088 
0089 typedef enum {
0090   RtemsSignalReqSend_Pre_ASR_Enabled,
0091   RtemsSignalReqSend_Pre_ASR_Disabled,
0092   RtemsSignalReqSend_Pre_ASR_NA
0093 } RtemsSignalReqSend_Pre_ASR;
0094 
0095 typedef enum {
0096   RtemsSignalReqSend_Pre_Nested_Yes,
0097   RtemsSignalReqSend_Pre_Nested_No,
0098   RtemsSignalReqSend_Pre_Nested_NA
0099 } RtemsSignalReqSend_Pre_Nested;
0100 
0101 typedef enum {
0102   RtemsSignalReqSend_Post_Status_Ok,
0103   RtemsSignalReqSend_Post_Status_InvNum,
0104   RtemsSignalReqSend_Post_Status_InvId,
0105   RtemsSignalReqSend_Post_Status_NotDef,
0106   RtemsSignalReqSend_Post_Status_NA
0107 } RtemsSignalReqSend_Post_Status;
0108 
0109 typedef enum {
0110   RtemsSignalReqSend_Post_Handler_NoCall,
0111   RtemsSignalReqSend_Post_Handler_DuringSend,
0112   RtemsSignalReqSend_Post_Handler_AfterDispatch,
0113   RtemsSignalReqSend_Post_Handler_AfterEnable,
0114   RtemsSignalReqSend_Post_Handler_NA
0115 } RtemsSignalReqSend_Post_Handler;
0116 
0117 typedef enum {
0118   RtemsSignalReqSend_Post_Recursive_Yes,
0119   RtemsSignalReqSend_Post_Recursive_No,
0120   RtemsSignalReqSend_Post_Recursive_NA
0121 } RtemsSignalReqSend_Post_Recursive;
0122 
0123 typedef struct {
0124   uint16_t Skip : 1;
0125   uint16_t Pre_Task_NA : 1;
0126   uint16_t Pre_Set_NA : 1;
0127   uint16_t Pre_Handler_NA : 1;
0128   uint16_t Pre_ASR_NA : 1;
0129   uint16_t Pre_Nested_NA : 1;
0130   uint16_t Post_Status : 3;
0131   uint16_t Post_Handler : 3;
0132   uint16_t Post_Recursive : 2;
0133 } RtemsSignalReqSend_Entry;
0134 
0135 /**
0136  * @brief Test context for spec:/rtems/signal/req/send test case.
0137  */
0138 typedef struct {
0139   rtems_id runner_id;
0140 
0141   rtems_id worker_id;
0142 
0143   rtems_asr_entry handler;
0144 
0145   size_t nested;
0146 
0147   size_t handler_calls;
0148 
0149   size_t calls_after_send;
0150 
0151   size_t calls_after_dispatch;
0152 
0153   size_t calls_after_enable;
0154 
0155   rtems_signal_set processed_signal_sets[ 2 ];
0156 
0157   uintptr_t stack_pointers[ 2 ];
0158 
0159   rtems_mode mode;
0160 
0161   rtems_status_code status;
0162 
0163   rtems_id id;
0164 
0165   rtems_signal_set signal_set;
0166 
0167   struct {
0168     /**
0169      * @brief This member defines the pre-condition states for the next action.
0170      */
0171     size_t pcs[ 5 ];
0172 
0173     /**
0174      * @brief If this member is true, then the test action loop is executed.
0175      */
0176     bool in_action_loop;
0177 
0178     /**
0179      * @brief This member contains the next transition map index.
0180      */
0181     size_t index;
0182 
0183     /**
0184      * @brief This member contains the current transition map entry.
0185      */
0186     RtemsSignalReqSend_Entry entry;
0187 
0188     /**
0189      * @brief If this member is true, then the current transition variant
0190      *   should be skipped.
0191      */
0192     bool skip;
0193   } Map;
0194 } RtemsSignalReqSend_Context;
0195 
0196 static RtemsSignalReqSend_Context
0197   RtemsSignalReqSend_Instance;
0198 
0199 static const char * const RtemsSignalReqSend_PreDesc_Task[] = {
0200   "NoObj",
0201   "Self",
0202   "Other",
0203   "NA"
0204 };
0205 
0206 static const char * const RtemsSignalReqSend_PreDesc_Set[] = {
0207   "Zero",
0208   "NonZero",
0209   "NA"
0210 };
0211 
0212 static const char * const RtemsSignalReqSend_PreDesc_Handler[] = {
0213   "Invalid",
0214   "Valid",
0215   "NA"
0216 };
0217 
0218 static const char * const RtemsSignalReqSend_PreDesc_ASR[] = {
0219   "Enabled",
0220   "Disabled",
0221   "NA"
0222 };
0223 
0224 static const char * const RtemsSignalReqSend_PreDesc_Nested[] = {
0225   "Yes",
0226   "No",
0227   "NA"
0228 };
0229 
0230 static const char * const * const RtemsSignalReqSend_PreDesc[] = {
0231   RtemsSignalReqSend_PreDesc_Task,
0232   RtemsSignalReqSend_PreDesc_Set,
0233   RtemsSignalReqSend_PreDesc_Handler,
0234   RtemsSignalReqSend_PreDesc_ASR,
0235   RtemsSignalReqSend_PreDesc_Nested,
0236   NULL
0237 };
0238 
0239 #define EVENT_START RTEMS_EVENT_0
0240 
0241 #define EVENT_SEND_DONE RTEMS_EVENT_1
0242 
0243 #define EVENT_DO_ENABLE RTEMS_EVENT_2
0244 
0245 #define EVENT_END RTEMS_EVENT_3
0246 
0247 #define EVENT_WORKER_DONE RTEMS_EVENT_4
0248 
0249 typedef RtemsSignalReqSend_Context Context;
0250 
0251 static void WorkerDone( const Context *ctx )
0252 {
0253 #if defined(RTEMS_SMP)
0254   if ( rtems_scheduler_get_processor_maximum() > 1 ) {
0255     SendEvents( ctx->runner_id, EVENT_WORKER_DONE );
0256   }
0257 #endif
0258 }
0259 
0260 static void SendEventsToWorker( const Context *ctx, rtems_event_set events )
0261 {
0262   SendEvents( ctx->worker_id, events );
0263 
0264 #if defined(RTEMS_SMP)
0265   if ( rtems_scheduler_get_processor_maximum() > 1 ) {
0266     events = ReceiveAnyEvents();
0267     T_eq_u32( events, EVENT_WORKER_DONE );
0268   }
0269 #endif
0270 }
0271 
0272 static void SignalHandler( rtems_signal_set signal_set )
0273 {
0274   Context *ctx;
0275   size_t   i;
0276   size_t   n;
0277 
0278   ctx = T_fixture_context();
0279   i = ctx->handler_calls;
0280   n = RTEMS_ARRAY_SIZE( ctx->processed_signal_sets );
0281   ctx->processed_signal_sets[ i % n ] = signal_set;
0282   ctx->stack_pointers[ i % n ] = (uintptr_t) __builtin_frame_address( 0 );
0283   T_lt_sz( i, n );
0284   ctx->handler_calls = i + 1;
0285 
0286   if ( ctx->nested != 0 && i == 0 ) {
0287     rtems_status_code sc;
0288 
0289     if ( ctx->id == ctx->worker_id ) {
0290       rtems_event_set events;
0291 
0292       sc = rtems_signal_catch( ctx->handler, RTEMS_NO_ASR );
0293       T_rsc_success( sc );
0294 
0295       WorkerDone( ctx );
0296 
0297       events = ReceiveAnyEvents();
0298       T_eq_u32( events, EVENT_SEND_DONE );
0299 
0300       WorkerDone( ctx );
0301 
0302       events = ReceiveAnyEvents();
0303       T_eq_u32( events, EVENT_DO_ENABLE );
0304     } else {
0305       sc = rtems_signal_catch( ctx->handler, RTEMS_NO_ASR );
0306       T_rsc_success( sc );
0307 
0308       ctx->status = rtems_signal_send( ctx->id, ctx->signal_set );
0309       ctx->calls_after_send = ctx->handler_calls;
0310       ctx->calls_after_dispatch = ctx->handler_calls;
0311     }
0312   }
0313 }
0314 
0315 static void Worker( rtems_task_argument arg )
0316 {
0317   Context *ctx;
0318 
0319   ctx = (Context *) arg;
0320 
0321   while ( true ) {
0322     rtems_status_code sc;
0323     rtems_event_set   events;
0324 
0325     events = ReceiveAnyEvents();
0326     T_eq_u32( events, EVENT_START );
0327 
0328     if ( ctx->nested != 0 ) {
0329       sc = rtems_signal_catch( SignalHandler, ctx->mode );
0330       T_rsc_success( sc );
0331 
0332       sc = rtems_signal_send( RTEMS_SELF, 0x600df00d );
0333       T_rsc_success( sc );
0334 
0335       WorkerDone( ctx );
0336     } else {
0337       rtems_mode mode;
0338 
0339       sc = rtems_task_mode( ctx->mode, RTEMS_ASR_MASK, &mode );
0340       T_rsc_success( sc );
0341 
0342       sc = rtems_signal_catch( ctx->handler, RTEMS_NO_ASR );
0343       T_rsc_success( sc );
0344 
0345       WorkerDone( ctx );
0346 
0347       events = ReceiveAnyEvents();
0348       T_eq_u32( events, EVENT_SEND_DONE );
0349 
0350       WorkerDone( ctx );
0351 
0352       events = ReceiveAnyEvents();
0353       T_eq_u32( events, EVENT_DO_ENABLE );
0354 
0355       sc = rtems_task_mode( mode, RTEMS_ASR_MASK, &mode );
0356       T_rsc_success( sc );
0357 
0358       WorkerDone( ctx );
0359     }
0360 
0361     events = ReceiveAnyEvents();
0362     T_eq_u32( events, EVENT_END );
0363 
0364     WorkerDone( ctx );
0365   }
0366 }
0367 
0368 static void RtemsSignalReqSend_Pre_Task_Prepare(
0369   RtemsSignalReqSend_Context *ctx,
0370   RtemsSignalReqSend_Pre_Task state
0371 )
0372 {
0373   switch ( state ) {
0374     case RtemsSignalReqSend_Pre_Task_NoObj: {
0375       /*
0376        * While the ``id`` parameter is not associated with a task.
0377        */
0378       ctx->id = 0xffffffff;
0379       break;
0380     }
0381 
0382     case RtemsSignalReqSend_Pre_Task_Self: {
0383       /*
0384        * While the ``id`` parameter is associated with the calling task.
0385        */
0386       ctx->id = RTEMS_SELF;
0387       break;
0388     }
0389 
0390     case RtemsSignalReqSend_Pre_Task_Other: {
0391       /*
0392        * While the ``id`` parameter is associated with a task other than the
0393        * calling task.
0394        */
0395       ctx->id = ctx->worker_id;
0396       break;
0397     }
0398 
0399     case RtemsSignalReqSend_Pre_Task_NA:
0400       break;
0401   }
0402 }
0403 
0404 static void RtemsSignalReqSend_Pre_Set_Prepare(
0405   RtemsSignalReqSend_Context *ctx,
0406   RtemsSignalReqSend_Pre_Set  state
0407 )
0408 {
0409   switch ( state ) {
0410     case RtemsSignalReqSend_Pre_Set_Zero: {
0411       /*
0412        * While the ``signal_set`` parameter is zero.
0413        */
0414       ctx->signal_set = 0;
0415       break;
0416     }
0417 
0418     case RtemsSignalReqSend_Pre_Set_NonZero: {
0419       /*
0420        * While the ``signal_set`` parameter is non-zero.
0421        */
0422       ctx->signal_set = 0xdeadbeef;
0423       break;
0424     }
0425 
0426     case RtemsSignalReqSend_Pre_Set_NA:
0427       break;
0428   }
0429 }
0430 
0431 static void RtemsSignalReqSend_Pre_Handler_Prepare(
0432   RtemsSignalReqSend_Context    *ctx,
0433   RtemsSignalReqSend_Pre_Handler state
0434 )
0435 {
0436   switch ( state ) {
0437     case RtemsSignalReqSend_Pre_Handler_Invalid: {
0438       /*
0439        * While the target task has no valid ASR handler installed.
0440        */
0441       ctx->handler = NULL;
0442       break;
0443     }
0444 
0445     case RtemsSignalReqSend_Pre_Handler_Valid: {
0446       /*
0447        * While the target task has a valid ASR handler installed.
0448        */
0449       ctx->handler = SignalHandler;
0450       break;
0451     }
0452 
0453     case RtemsSignalReqSend_Pre_Handler_NA:
0454       break;
0455   }
0456 }
0457 
0458 static void RtemsSignalReqSend_Pre_ASR_Prepare(
0459   RtemsSignalReqSend_Context *ctx,
0460   RtemsSignalReqSend_Pre_ASR  state
0461 )
0462 {
0463   switch ( state ) {
0464     case RtemsSignalReqSend_Pre_ASR_Enabled: {
0465       /*
0466        * While the target task has ASR processing enabled.
0467        */
0468       ctx->mode = RTEMS_DEFAULT_MODES;
0469       break;
0470     }
0471 
0472     case RtemsSignalReqSend_Pre_ASR_Disabled: {
0473       /*
0474        * While the target task has ASR processing disabled.
0475        */
0476       ctx->mode = RTEMS_NO_ASR;
0477       break;
0478     }
0479 
0480     case RtemsSignalReqSend_Pre_ASR_NA:
0481       break;
0482   }
0483 }
0484 
0485 static void RtemsSignalReqSend_Pre_Nested_Prepare(
0486   RtemsSignalReqSend_Context   *ctx,
0487   RtemsSignalReqSend_Pre_Nested state
0488 )
0489 {
0490   switch ( state ) {
0491     case RtemsSignalReqSend_Pre_Nested_Yes: {
0492       /*
0493        * While the target task processes an asynchronous signal.
0494        */
0495       ctx->nested = 1;
0496       break;
0497     }
0498 
0499     case RtemsSignalReqSend_Pre_Nested_No: {
0500       /*
0501        * While the target task does not process an asynchronous signal.
0502        */
0503       ctx->nested = 0;
0504       break;
0505     }
0506 
0507     case RtemsSignalReqSend_Pre_Nested_NA:
0508       break;
0509   }
0510 }
0511 
0512 static void RtemsSignalReqSend_Post_Status_Check(
0513   RtemsSignalReqSend_Context    *ctx,
0514   RtemsSignalReqSend_Post_Status state
0515 )
0516 {
0517   switch ( state ) {
0518     case RtemsSignalReqSend_Post_Status_Ok: {
0519       /*
0520        * The return status of rtems_signal_send() shall be RTEMS_SUCCESSFUL.
0521        */
0522       T_rsc_success( ctx->status );
0523       break;
0524     }
0525 
0526     case RtemsSignalReqSend_Post_Status_InvNum: {
0527       /*
0528        * The return status of rtems_signal_send() shall be
0529        * RTEMS_INVALID_NUMBER.
0530        */
0531       T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
0532       break;
0533     }
0534 
0535     case RtemsSignalReqSend_Post_Status_InvId: {
0536       /*
0537        * The return status of rtems_signal_send() shall be RTEMS_INVALID_ID.
0538        */
0539       T_rsc( ctx->status, RTEMS_INVALID_ID );
0540       break;
0541     }
0542 
0543     case RtemsSignalReqSend_Post_Status_NotDef: {
0544       /*
0545        * The return status of rtems_signal_send() shall be RTEMS_NOT_DEFINED.
0546        */
0547       T_rsc( ctx->status, RTEMS_NOT_DEFINED );
0548       break;
0549     }
0550 
0551     case RtemsSignalReqSend_Post_Status_NA:
0552       break;
0553   }
0554 }
0555 
0556 static void RtemsSignalReqSend_Post_Handler_Check(
0557   RtemsSignalReqSend_Context     *ctx,
0558   RtemsSignalReqSend_Post_Handler state
0559 )
0560 {
0561   size_t expected_calls;
0562 
0563   expected_calls = ctx->nested;
0564 
0565   switch ( state ) {
0566     case RtemsSignalReqSend_Post_Handler_NoCall: {
0567       /*
0568        * While the ASR processing is disabled, the ASR handler shall not be
0569        * called.
0570        */
0571       T_eq_sz( ctx->calls_after_send, ctx->nested );
0572       T_eq_sz( ctx->calls_after_dispatch, ctx->nested );
0573       T_eq_sz( ctx->calls_after_enable, ctx->nested );
0574       break;
0575     }
0576 
0577     case RtemsSignalReqSend_Post_Handler_DuringSend: {
0578       /*
0579        * The ASR handler shall be called during the rtems_signal_send() call.
0580        */
0581       ++expected_calls;
0582       T_eq_sz( ctx->calls_after_send, ctx->nested + 1 );
0583       T_eq_sz( ctx->calls_after_dispatch, ctx->nested + 1 );
0584       T_eq_sz( ctx->calls_after_enable, ctx->nested + 1 );
0585       break;
0586     }
0587 
0588     case RtemsSignalReqSend_Post_Handler_AfterDispatch: {
0589       /*
0590        * When the next thread dispatch of the target task of the
0591        * rtems_signal_send() call takes place, the ASR handler shall be called.
0592        */
0593       ++expected_calls;
0594       T_eq_sz( ctx->calls_after_send, ctx->nested );
0595       T_eq_sz( ctx->calls_after_dispatch, ctx->nested + 1 );
0596       T_eq_sz( ctx->calls_after_enable, ctx->nested + 1 );
0597       break;
0598     }
0599 
0600     case RtemsSignalReqSend_Post_Handler_AfterEnable: {
0601       /*
0602        * When the target task of the rtems_signal_send() call re-enables ASR
0603        * processing, the ASR handler shall be called.
0604        */
0605       ++expected_calls;
0606       T_eq_sz( ctx->calls_after_send, ctx->nested );
0607       T_eq_sz( ctx->calls_after_dispatch, ctx->nested );
0608       T_eq_sz( ctx->calls_after_enable, ctx->nested + 1 );
0609       break;
0610     }
0611 
0612     case RtemsSignalReqSend_Post_Handler_NA:
0613       break;
0614   }
0615 
0616   T_eq_sz( ctx->handler_calls, expected_calls );
0617 
0618   if ( ctx->nested != 0 ) {
0619     T_eq_u32( ctx->processed_signal_sets[ 0 ], 0x600df00d );
0620   }
0621 
0622   if ( expected_calls > ctx->nested ) {
0623     T_eq_u32( ctx->processed_signal_sets[ ctx->nested ], 0xdeadbeef );
0624   }
0625 }
0626 
0627 static void RtemsSignalReqSend_Post_Recursive_Check(
0628   RtemsSignalReqSend_Context       *ctx,
0629   RtemsSignalReqSend_Post_Recursive state
0630 )
0631 {
0632   switch ( state ) {
0633     case RtemsSignalReqSend_Post_Recursive_Yes: {
0634       /*
0635        * The ASR handler shall be called recursively.
0636        */
0637       T_eq_sz( ctx->handler_calls, 2 );
0638       T_ne_uptr( ctx->stack_pointers[ 0 ], 0 );
0639       T_ne_uptr( ctx->stack_pointers[ 1 ], 0 );
0640       T_ne_uptr( ctx->stack_pointers[ 0 ], ctx->stack_pointers[ 1 ] );
0641       break;
0642     }
0643 
0644     case RtemsSignalReqSend_Post_Recursive_No: {
0645       /*
0646        * The ASR handler shall not be called recursively.
0647        */
0648       if ( ctx->handler_calls == 2 ) {
0649         T_ne_uptr( ctx->stack_pointers[ 0 ], 0 );
0650         T_ne_uptr( ctx->stack_pointers[ 1 ], 0 );
0651         T_eq_uptr( ctx->stack_pointers[ 0 ], ctx->stack_pointers[ 1 ] );
0652       }
0653       break;
0654     }
0655 
0656     case RtemsSignalReqSend_Post_Recursive_NA:
0657       break;
0658   }
0659 }
0660 
0661 static void RtemsSignalReqSend_Setup( RtemsSignalReqSend_Context *ctx )
0662 {
0663   memset( ctx, 0, sizeof( *ctx ) );
0664   ctx->runner_id = rtems_task_self();
0665   SetSelfPriority( PRIO_NORMAL );
0666 
0667   ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
0668 
0669   #if defined(RTEMS_SMP)
0670   if ( rtems_scheduler_get_processor_maximum() > 1 ) {
0671     rtems_status_code sc;
0672     rtems_id          scheduler_id;
0673 
0674     sc = rtems_scheduler_ident_by_processor( 1, &scheduler_id );
0675     T_assert_rsc_success( sc );
0676 
0677     sc = rtems_task_set_scheduler( ctx->worker_id, scheduler_id, PRIO_HIGH );
0678     T_assert_rsc_success( sc );
0679   }
0680   #endif
0681 
0682   StartTask( ctx->worker_id, Worker, ctx );
0683 }
0684 
0685 static void RtemsSignalReqSend_Setup_Wrap( void *arg )
0686 {
0687   RtemsSignalReqSend_Context *ctx;
0688 
0689   ctx = arg;
0690   ctx->Map.in_action_loop = false;
0691   RtemsSignalReqSend_Setup( ctx );
0692 }
0693 
0694 static void RtemsSignalReqSend_Teardown( RtemsSignalReqSend_Context *ctx )
0695 {
0696   DeleteTask( ctx->worker_id );
0697   RestoreRunnerPriority();
0698 }
0699 
0700 static void RtemsSignalReqSend_Teardown_Wrap( void *arg )
0701 {
0702   RtemsSignalReqSend_Context *ctx;
0703 
0704   ctx = arg;
0705   ctx->Map.in_action_loop = false;
0706   RtemsSignalReqSend_Teardown( ctx );
0707 }
0708 
0709 static void RtemsSignalReqSend_Prepare( RtemsSignalReqSend_Context *ctx )
0710 {
0711   ctx->handler_calls = 0;
0712   ctx->calls_after_send = 0;
0713   ctx->calls_after_dispatch = 0;
0714   ctx->calls_after_enable = 0;
0715   memset( &ctx->processed_signal_sets, 0, sizeof( ctx->processed_signal_sets ) );
0716   memset( &ctx->stack_pointers, 0, sizeof( ctx->stack_pointers ) );
0717 }
0718 
0719 static void RtemsSignalReqSend_Action( RtemsSignalReqSend_Context *ctx )
0720 {
0721   rtems_status_code sc;
0722 
0723   if ( ctx->id == ctx->worker_id ) {
0724     SendEventsToWorker( ctx, EVENT_START );
0725 
0726     StartDelayThreadDispatch( 1 );
0727     ctx->status = rtems_signal_send( ctx->id, ctx->signal_set );
0728     ctx->calls_after_send = ctx->handler_calls;
0729     StopDelayThreadDispatch( 1 );
0730 
0731     SendEventsToWorker( ctx, EVENT_SEND_DONE );
0732     ctx->calls_after_dispatch = ctx->handler_calls;
0733     SendEventsToWorker( ctx, EVENT_DO_ENABLE );
0734     ctx->calls_after_enable = ctx->handler_calls;
0735     SendEventsToWorker( ctx, EVENT_END );
0736   } else if ( ctx->nested != 0 ) {
0737     sc = rtems_signal_catch( SignalHandler, ctx->mode );
0738     T_rsc_success( sc );
0739 
0740     sc = rtems_signal_send( RTEMS_SELF, 0x600df00d );
0741     T_rsc_success( sc );
0742 
0743     ctx->calls_after_enable = ctx->handler_calls;
0744   } else {
0745     rtems_mode mode;
0746 
0747     sc = rtems_task_mode( ctx->mode, RTEMS_ASR_MASK, &mode );
0748     T_rsc_success( sc );
0749 
0750     sc = rtems_signal_catch( ctx->handler, RTEMS_NO_ASR );
0751     T_rsc_success( sc );
0752 
0753     ctx->status = rtems_signal_send( ctx->id, ctx->signal_set );
0754     ctx->calls_after_send = ctx->handler_calls;
0755     ctx->calls_after_dispatch = ctx->handler_calls;
0756 
0757     sc = rtems_task_mode( mode, RTEMS_ASR_MASK, &mode );
0758     T_rsc_success( sc );
0759 
0760     ctx->calls_after_enable = ctx->handler_calls;
0761   }
0762 }
0763 
0764 static const RtemsSignalReqSend_Entry
0765 RtemsSignalReqSend_Entries[] = {
0766   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_InvNum,
0767     RtemsSignalReqSend_Post_Handler_NoCall,
0768     RtemsSignalReqSend_Post_Recursive_No },
0769   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_InvId,
0770     RtemsSignalReqSend_Post_Handler_NoCall,
0771     RtemsSignalReqSend_Post_Recursive_No },
0772   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_NotDef,
0773     RtemsSignalReqSend_Post_Handler_NoCall,
0774     RtemsSignalReqSend_Post_Recursive_No },
0775   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_Ok,
0776     RtemsSignalReqSend_Post_Handler_AfterEnable,
0777     RtemsSignalReqSend_Post_Recursive_No },
0778   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_Ok,
0779     RtemsSignalReqSend_Post_Handler_DuringSend,
0780     RtemsSignalReqSend_Post_Recursive_Yes },
0781   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_Ok,
0782     RtemsSignalReqSend_Post_Handler_DuringSend,
0783     RtemsSignalReqSend_Post_Recursive_No },
0784   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_Ok,
0785     RtemsSignalReqSend_Post_Handler_AfterDispatch,
0786     RtemsSignalReqSend_Post_Recursive_Yes },
0787   { 0, 0, 0, 0, 0, 0, RtemsSignalReqSend_Post_Status_Ok,
0788     RtemsSignalReqSend_Post_Handler_AfterDispatch,
0789     RtemsSignalReqSend_Post_Recursive_No }
0790 };
0791 
0792 static const uint8_t
0793 RtemsSignalReqSend_Map[] = {
0794   0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
0795   2, 2, 4, 5, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 6, 7, 3, 3
0796 };
0797 
0798 static size_t RtemsSignalReqSend_Scope( void *arg, char *buf, size_t n )
0799 {
0800   RtemsSignalReqSend_Context *ctx;
0801 
0802   ctx = arg;
0803 
0804   if ( ctx->Map.in_action_loop ) {
0805     return T_get_scope( RtemsSignalReqSend_PreDesc, buf, n, ctx->Map.pcs );
0806   }
0807 
0808   return 0;
0809 }
0810 
0811 static T_fixture RtemsSignalReqSend_Fixture = {
0812   .setup = RtemsSignalReqSend_Setup_Wrap,
0813   .stop = NULL,
0814   .teardown = RtemsSignalReqSend_Teardown_Wrap,
0815   .scope = RtemsSignalReqSend_Scope,
0816   .initial_context = &RtemsSignalReqSend_Instance
0817 };
0818 
0819 static inline RtemsSignalReqSend_Entry RtemsSignalReqSend_PopEntry(
0820   RtemsSignalReqSend_Context *ctx
0821 )
0822 {
0823   size_t index;
0824 
0825   index = ctx->Map.index;
0826   ctx->Map.index = index + 1;
0827   return RtemsSignalReqSend_Entries[
0828     RtemsSignalReqSend_Map[ index ]
0829   ];
0830 }
0831 
0832 static void RtemsSignalReqSend_TestVariant( RtemsSignalReqSend_Context *ctx )
0833 {
0834   RtemsSignalReqSend_Pre_Task_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0835   RtemsSignalReqSend_Pre_Set_Prepare( ctx, ctx->Map.pcs[ 1 ] );
0836   RtemsSignalReqSend_Pre_Handler_Prepare( ctx, ctx->Map.pcs[ 2 ] );
0837   RtemsSignalReqSend_Pre_ASR_Prepare( ctx, ctx->Map.pcs[ 3 ] );
0838   RtemsSignalReqSend_Pre_Nested_Prepare( ctx, ctx->Map.pcs[ 4 ] );
0839   RtemsSignalReqSend_Action( ctx );
0840   RtemsSignalReqSend_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
0841   RtemsSignalReqSend_Post_Handler_Check( ctx, ctx->Map.entry.Post_Handler );
0842   RtemsSignalReqSend_Post_Recursive_Check(
0843     ctx,
0844     ctx->Map.entry.Post_Recursive
0845   );
0846 }
0847 
0848 /**
0849  * @fn void T_case_body_RtemsSignalReqSend( void )
0850  */
0851 T_TEST_CASE_FIXTURE( RtemsSignalReqSend, &RtemsSignalReqSend_Fixture )
0852 {
0853   RtemsSignalReqSend_Context *ctx;
0854 
0855   ctx = T_fixture_context();
0856   ctx->Map.in_action_loop = true;
0857   ctx->Map.index = 0;
0858 
0859   for (
0860     ctx->Map.pcs[ 0 ] = RtemsSignalReqSend_Pre_Task_NoObj;
0861     ctx->Map.pcs[ 0 ] < RtemsSignalReqSend_Pre_Task_NA;
0862     ++ctx->Map.pcs[ 0 ]
0863   ) {
0864     for (
0865       ctx->Map.pcs[ 1 ] = RtemsSignalReqSend_Pre_Set_Zero;
0866       ctx->Map.pcs[ 1 ] < RtemsSignalReqSend_Pre_Set_NA;
0867       ++ctx->Map.pcs[ 1 ]
0868     ) {
0869       for (
0870         ctx->Map.pcs[ 2 ] = RtemsSignalReqSend_Pre_Handler_Invalid;
0871         ctx->Map.pcs[ 2 ] < RtemsSignalReqSend_Pre_Handler_NA;
0872         ++ctx->Map.pcs[ 2 ]
0873       ) {
0874         for (
0875           ctx->Map.pcs[ 3 ] = RtemsSignalReqSend_Pre_ASR_Enabled;
0876           ctx->Map.pcs[ 3 ] < RtemsSignalReqSend_Pre_ASR_NA;
0877           ++ctx->Map.pcs[ 3 ]
0878         ) {
0879           for (
0880             ctx->Map.pcs[ 4 ] = RtemsSignalReqSend_Pre_Nested_Yes;
0881             ctx->Map.pcs[ 4 ] < RtemsSignalReqSend_Pre_Nested_NA;
0882             ++ctx->Map.pcs[ 4 ]
0883           ) {
0884             ctx->Map.entry = RtemsSignalReqSend_PopEntry( ctx );
0885             RtemsSignalReqSend_Prepare( ctx );
0886             RtemsSignalReqSend_TestVariant( ctx );
0887           }
0888         }
0889       }
0890     }
0891   }
0892 }
0893 
0894 /** @} */