Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RtemsMessageReqReceive
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 #include <rtems/score/statesimpl.h>
0057 
0058 #include "tr-tq-enqueue-fifo.h"
0059 #include "tr-tq-enqueue-priority.h"
0060 #include "tx-support.h"
0061 #include "tx-thread-queue.h"
0062 
0063 #include <rtems/test.h>
0064 
0065 /**
0066  * @defgroup RtemsMessageReqReceive spec:/rtems/message/req/receive
0067  *
0068  * @ingroup TestsuitesValidationNoClock0
0069  *
0070  * @{
0071  */
0072 
0073 typedef enum {
0074   RtemsMessageReqReceive_Pre_Buffer_Valid,
0075   RtemsMessageReqReceive_Pre_Buffer_Null,
0076   RtemsMessageReqReceive_Pre_Buffer_NA
0077 } RtemsMessageReqReceive_Pre_Buffer;
0078 
0079 typedef enum {
0080   RtemsMessageReqReceive_Pre_Size_Valid,
0081   RtemsMessageReqReceive_Pre_Size_Null,
0082   RtemsMessageReqReceive_Pre_Size_NA
0083 } RtemsMessageReqReceive_Pre_Size;
0084 
0085 typedef enum {
0086   RtemsMessageReqReceive_Pre_Id_Valid,
0087   RtemsMessageReqReceive_Pre_Id_Invalid,
0088   RtemsMessageReqReceive_Pre_Id_NA
0089 } RtemsMessageReqReceive_Pre_Id;
0090 
0091 typedef enum {
0092   RtemsMessageReqReceive_Pre_DuringWait_Nop,
0093   RtemsMessageReqReceive_Pre_DuringWait_Deleted,
0094   RtemsMessageReqReceive_Pre_DuringWait_NA
0095 } RtemsMessageReqReceive_Pre_DuringWait;
0096 
0097 typedef enum {
0098   RtemsMessageReqReceive_Pre_TaskQueue_Fifo,
0099   RtemsMessageReqReceive_Pre_TaskQueue_Priority,
0100   RtemsMessageReqReceive_Pre_TaskQueue_NA
0101 } RtemsMessageReqReceive_Pre_TaskQueue;
0102 
0103 typedef enum {
0104   RtemsMessageReqReceive_Pre_Wait_No,
0105   RtemsMessageReqReceive_Pre_Wait_Timeout,
0106   RtemsMessageReqReceive_Pre_Wait_Forever,
0107   RtemsMessageReqReceive_Pre_Wait_NA
0108 } RtemsMessageReqReceive_Pre_Wait;
0109 
0110 typedef enum {
0111   RtemsMessageReqReceive_Pre_MsgQueue_Empty,
0112   RtemsMessageReqReceive_Pre_MsgQueue_One,
0113   RtemsMessageReqReceive_Pre_MsgQueue_Several,
0114   RtemsMessageReqReceive_Pre_MsgQueue_NA
0115 } RtemsMessageReqReceive_Pre_MsgQueue;
0116 
0117 typedef enum {
0118   RtemsMessageReqReceive_Pre_Storage_Nop,
0119   RtemsMessageReqReceive_Pre_Storage_NA
0120 } RtemsMessageReqReceive_Pre_Storage;
0121 
0122 typedef enum {
0123   RtemsMessageReqReceive_Post_Status_Ok,
0124   RtemsMessageReqReceive_Post_Status_InvId,
0125   RtemsMessageReqReceive_Post_Status_InvAddr,
0126   RtemsMessageReqReceive_Post_Status_Unsat,
0127   RtemsMessageReqReceive_Post_Status_Timeout,
0128   RtemsMessageReqReceive_Post_Status_Deleted,
0129   RtemsMessageReqReceive_Post_Status_NA
0130 } RtemsMessageReqReceive_Post_Status;
0131 
0132 typedef enum {
0133   RtemsMessageReqReceive_Post_Delay_None,
0134   RtemsMessageReqReceive_Post_Delay_Ticks,
0135   RtemsMessageReqReceive_Post_Delay_Forever,
0136   RtemsMessageReqReceive_Post_Delay_NA
0137 } RtemsMessageReqReceive_Post_Delay;
0138 
0139 typedef enum {
0140   RtemsMessageReqReceive_Post_Size_First,
0141   RtemsMessageReqReceive_Post_Size_Nop,
0142   RtemsMessageReqReceive_Post_Size_NA
0143 } RtemsMessageReqReceive_Post_Size;
0144 
0145 typedef enum {
0146   RtemsMessageReqReceive_Post_Msg_First,
0147   RtemsMessageReqReceive_Post_Msg_Nop,
0148   RtemsMessageReqReceive_Post_Msg_NA
0149 } RtemsMessageReqReceive_Post_Msg;
0150 
0151 typedef enum {
0152   RtemsMessageReqReceive_Post_MsgQueue_Empty,
0153   RtemsMessageReqReceive_Post_MsgQueue_OneLess,
0154   RtemsMessageReqReceive_Post_MsgQueue_Nop,
0155   RtemsMessageReqReceive_Post_MsgQueue_NA
0156 } RtemsMessageReqReceive_Post_MsgQueue;
0157 
0158 typedef enum {
0159   RtemsMessageReqReceive_Post_Tasks_Fifo,
0160   RtemsMessageReqReceive_Post_Tasks_Priority,
0161   RtemsMessageReqReceive_Post_Tasks_NA
0162 } RtemsMessageReqReceive_Post_Tasks;
0163 
0164 typedef struct {
0165   uint32_t Skip : 1;
0166   uint32_t Pre_Buffer_NA : 1;
0167   uint32_t Pre_Size_NA : 1;
0168   uint32_t Pre_Id_NA : 1;
0169   uint32_t Pre_DuringWait_NA : 1;
0170   uint32_t Pre_TaskQueue_NA : 1;
0171   uint32_t Pre_Wait_NA : 1;
0172   uint32_t Pre_MsgQueue_NA : 1;
0173   uint32_t Pre_Storage_NA : 1;
0174   uint32_t Post_Status : 3;
0175   uint32_t Post_Delay : 2;
0176   uint32_t Post_Size : 2;
0177   uint32_t Post_Msg : 2;
0178   uint32_t Post_MsgQueue : 2;
0179   uint32_t Post_Tasks : 2;
0180 } RtemsMessageReqReceive_Entry;
0181 
0182 #define MAXIMUM_PENDING_MESSAGES 3
0183 #define MAXIMUM_MESSAGE_SIZE 5
0184 
0185 /**
0186  * @brief Test context for spec:/rtems/message/req/receive test case.
0187  */
0188 typedef struct {
0189   /**
0190    * @brief This member contains the thread queue test context.
0191    */
0192   TQContext tq_ctx;
0193 
0194   /**
0195    * @brief This member specifies the attribute set of the message queue.
0196    */
0197   rtems_attribute attribute_set;
0198 
0199   /**
0200    * @brief This member is used as storage area for the message queue.
0201    */
0202   RTEMS_MESSAGE_QUEUE_BUFFER( MAXIMUM_MESSAGE_SIZE )
0203     storage_area[ MAXIMUM_PENDING_MESSAGES];
0204 
0205   /**
0206    * @brief This member contains always the same arbitrary number ``magic``.
0207    *
0208    * It is used for run-time type checking.
0209    */
0210   uint32_t magic;
0211 
0212   /**
0213    * @brief This member contains a number which is sent as next message.
0214    */
0215   uint8_t send_msg_counter;
0216 
0217   /**
0218    * @brief This member contains a buffer to receive messages from the queue.
0219    */
0220   uint8_t receive_buffer[ MAXIMUM_MESSAGE_SIZE ];
0221 
0222   /**
0223    * @brief This member contains a buffer to receive the messages size.
0224    */
0225   size_t receive_size;
0226 
0227   /**
0228    * @brief This member specifies the ``id`` parameter for the action.
0229    */
0230   rtems_id id_param;
0231 
0232   /**
0233    * @brief This member specifies the ``buffer`` parameter for the action.
0234    */
0235   void *buffer_param;
0236 
0237   /**
0238    * @brief This member specifies the ``size`` parameter for the action.
0239    */
0240   size_t *size_param;
0241 
0242   /**
0243    * @brief This member specifies the ``option_set`` parameter for the action.
0244    */
0245   rtems_option option_set_param;
0246 
0247   /**
0248    * @brief This member specifies the ``timeout`` parameter for the action.
0249    */
0250   rtems_interval timeout_param;
0251 
0252   /**
0253    * @brief This member contains the returned status code of the action.
0254    */
0255   rtems_status_code status;
0256 
0257   /**
0258    * @brief This member contains the duration of the action in ticks.
0259    */
0260   uint32_t action_duration;
0261 
0262   /**
0263    * @brief This member contains the task identifier of the main task.
0264    */
0265   rtems_id task_id;
0266 
0267   /**
0268    * @brief This member contains the task identifier of the worker task.
0269    */
0270   rtems_id worker_id;
0271 
0272   /**
0273    * @brief This member contains a pointer to a function which is executed
0274    *   while the worker is waiting to receive a message (`delete(), nop()``).
0275    */
0276   void (*concurrent_activity)( void *ctx_in );
0277 
0278   /**
0279    * @brief This member contains a pointer to a function which is executed to
0280    *   check that the action has not changed the content of the message queue.
0281    */
0282   void (*check_msgq_unchanged)( void *ctx_in );
0283 
0284   struct {
0285     /**
0286      * @brief This member defines the pre-condition states for the next action.
0287      */
0288     size_t pcs[ 8 ];
0289 
0290     /**
0291      * @brief If this member is true, then the test action loop is executed.
0292      */
0293     bool in_action_loop;
0294 
0295     /**
0296      * @brief This member contains the next transition map index.
0297      */
0298     size_t index;
0299 
0300     /**
0301      * @brief This member contains the current transition map entry.
0302      */
0303     RtemsMessageReqReceive_Entry entry;
0304 
0305     /**
0306      * @brief If this member is true, then the current transition variant
0307      *   should be skipped.
0308      */
0309     bool skip;
0310   } Map;
0311 } RtemsMessageReqReceive_Context;
0312 
0313 static RtemsMessageReqReceive_Context
0314   RtemsMessageReqReceive_Instance;
0315 
0316 static const char * const RtemsMessageReqReceive_PreDesc_Buffer[] = {
0317   "Valid",
0318   "Null",
0319   "NA"
0320 };
0321 
0322 static const char * const RtemsMessageReqReceive_PreDesc_Size[] = {
0323   "Valid",
0324   "Null",
0325   "NA"
0326 };
0327 
0328 static const char * const RtemsMessageReqReceive_PreDesc_Id[] = {
0329   "Valid",
0330   "Invalid",
0331   "NA"
0332 };
0333 
0334 static const char * const RtemsMessageReqReceive_PreDesc_DuringWait[] = {
0335   "Nop",
0336   "Deleted",
0337   "NA"
0338 };
0339 
0340 static const char * const RtemsMessageReqReceive_PreDesc_TaskQueue[] = {
0341   "Fifo",
0342   "Priority",
0343   "NA"
0344 };
0345 
0346 static const char * const RtemsMessageReqReceive_PreDesc_Wait[] = {
0347   "No",
0348   "Timeout",
0349   "Forever",
0350   "NA"
0351 };
0352 
0353 static const char * const RtemsMessageReqReceive_PreDesc_MsgQueue[] = {
0354   "Empty",
0355   "One",
0356   "Several",
0357   "NA"
0358 };
0359 
0360 static const char * const RtemsMessageReqReceive_PreDesc_Storage[] = {
0361   "Nop",
0362   "NA"
0363 };
0364 
0365 static const char * const * const RtemsMessageReqReceive_PreDesc[] = {
0366   RtemsMessageReqReceive_PreDesc_Buffer,
0367   RtemsMessageReqReceive_PreDesc_Size,
0368   RtemsMessageReqReceive_PreDesc_Id,
0369   RtemsMessageReqReceive_PreDesc_DuringWait,
0370   RtemsMessageReqReceive_PreDesc_TaskQueue,
0371   RtemsMessageReqReceive_PreDesc_Wait,
0372   RtemsMessageReqReceive_PreDesc_MsgQueue,
0373   RtemsMessageReqReceive_PreDesc_Storage,
0374   NULL
0375 };
0376 
0377 typedef RtemsMessageReqReceive_Context Context;
0378 static const uint32_t        magic = 0xA55CA3D1; /* an arbitrary number */
0379 static const rtems_interval  timeout_ticks = 3;
0380 static const rtems_event_set wake_main_task_event = RTEMS_EVENT_17;
0381 
0382 static void DoAction( void *ctx_in )
0383 {
0384   Context *ctx = ctx_in;
0385   ctx->status = rtems_message_queue_receive(
0386     ctx->id_param,
0387     ctx->buffer_param,
0388     ctx->size_param,
0389     ctx->option_set_param,
0390     ctx->timeout_param
0391   );
0392 }
0393 
0394 static void WorkerTask( rtems_task_argument argument )
0395 {
0396   Context *ctx = (Context *) argument;
0397   if ( ctx != NULL ) {
0398     T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0399     DoAction( ctx );
0400     T_rsc_success( rtems_event_send( ctx->task_id, wake_main_task_event ) );
0401   }
0402   T_rsc_success( rtems_task_suspend( RTEMS_SELF ) );
0403 }
0404 
0405 static void WorkerDoAction( void *ctx_in )
0406 {
0407   rtems_status_code status;
0408   Context *ctx = ctx_in;
0409   T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0410   status = rtems_task_restart( ctx->worker_id, (rtems_task_argument) ctx );
0411   T_rsc_success( status );
0412 }
0413 
0414 static uint32_t WaitForWorker( Context *ctx )
0415 {
0416   uint32_t ticks_to_wait = timeout_ticks + 1;
0417   rtems_status_code status;
0418   rtems_event_set event_set;
0419 
0420    for ( ; ticks_to_wait > 0; --ticks_to_wait ) {
0421     /* Check whether the worker finished executing the action */
0422     status = rtems_event_receive(
0423       RTEMS_PENDING_EVENTS,
0424       RTEMS_NO_WAIT | RTEMS_EVENT_ANY,
0425       RTEMS_NO_TIMEOUT,
0426       &event_set
0427     );
0428     T_rsc_success( status );
0429 
0430     if ( ( event_set & wake_main_task_event ) == wake_main_task_event ) {
0431       break;
0432     }
0433     TimecounterTick();
0434   }
0435 
0436   if ( ctx->timeout_param != RTEMS_NO_TIMEOUT ) {
0437     /* Wait till the worker task finishes */
0438     status = rtems_event_receive(
0439       wake_main_task_event,
0440       RTEMS_DEFAULT_OPTIONS,
0441       RTEMS_NO_TIMEOUT,
0442       &event_set
0443     );
0444   T_rsc_success( status );
0445   }
0446 
0447   return timeout_ticks + 1 - ticks_to_wait;
0448 }
0449 
0450 static void MessageQueueSetup( Context *ctx )
0451 {
0452   rtems_status_code status;
0453   /* Sanity check: Make sure the message queue does not exist, yet. */
0454   T_assert_eq_u32( ctx->tq_ctx.thread_queue_id, RTEMS_ID_NONE );
0455   rtems_message_queue_config config = {
0456     .name = rtems_build_name( 'M', 'S', 'G', 'Q' ),
0457     .maximum_pending_messages = MAXIMUM_PENDING_MESSAGES,
0458     .maximum_message_size = MAXIMUM_MESSAGE_SIZE,
0459     .storage_area = ctx->storage_area,
0460     .storage_size = sizeof( ctx->storage_area ),
0461     .storage_free = NULL,
0462     .attributes = ctx->attribute_set
0463   };
0464 
0465   status = rtems_message_queue_construct(
0466     &config,
0467     &ctx->tq_ctx.thread_queue_id
0468   );
0469   T_rsc_success( status );
0470 
0471   if ( ctx->id_param != RTEMS_ID_NONE ) {
0472     ctx->id_param = ctx->tq_ctx.thread_queue_id;
0473   }
0474 }
0475 
0476 static void MessageQueueTeardown( Context *ctx )
0477 {
0478   rtems_status_code status;
0479   if ( ctx->tq_ctx.thread_queue_id != RTEMS_ID_NONE ) {
0480     status = rtems_message_queue_delete( ctx->tq_ctx.thread_queue_id );
0481     T_rsc_success( status );
0482     ctx->tq_ctx.thread_queue_id = RTEMS_ID_NONE;
0483   }
0484 }
0485 
0486 static void CheckForNoMessage(
0487   rtems_status_code status,
0488   uint8_t *message_buffer,
0489   size_t message_size
0490 )
0491 {
0492   (void) message_buffer;
0493   (void) message_size;
0494   T_rsc( status, RTEMS_UNSATISFIED  );
0495 }
0496 
0497 static void CheckForFirstMessage(
0498   rtems_status_code status,
0499   uint8_t *message_buffer,
0500   size_t message_size
0501 )
0502 {
0503   T_rsc_success( status );
0504   T_eq_u32( message_size, 1 );
0505   T_eq_u8( message_buffer[0], 0 );
0506 }
0507 
0508 static void CheckForSecondMessage(
0509   rtems_status_code status,
0510   uint8_t *message_buffer,
0511   size_t message_size
0512 )
0513 {
0514   T_rsc_success( status );
0515   T_eq_u32( message_size, 3 );
0516   T_eq_u8( message_buffer[0], 1 );
0517   T_eq_u8( message_buffer[1], 1 );
0518   T_eq_u8( message_buffer[2], 1 );
0519 }
0520 
0521 static void CheckForThirdMessage(
0522   rtems_status_code status,
0523   uint8_t *message_buffer,
0524   size_t message_size
0525 )
0526 {
0527   T_rsc_success( status );
0528   T_eq_u32( message_size, 5 );
0529   T_eq_u8( message_buffer[0], 2 );
0530   T_eq_u8( message_buffer[1], 2 );
0531   T_eq_u8( message_buffer[2], 2 );
0532   T_eq_u8( message_buffer[3], 2 );
0533   T_eq_u8( message_buffer[4], 2 );
0534 }
0535 
0536 static void PopMessage(
0537   Context *ctx,
0538   void (*check_fn)(
0539     rtems_status_code status,
0540     uint8_t *message_buffer,
0541     size_t message_size
0542   )
0543 )
0544 {
0545   rtems_status_code status;
0546   uint8_t message_buffer[ MAXIMUM_MESSAGE_SIZE ];
0547   size_t message_size;
0548 
0549   status = rtems_message_queue_receive(
0550     ctx->tq_ctx.thread_queue_id,
0551     &message_buffer,
0552     &message_size,
0553     RTEMS_LOCAL | RTEMS_NO_WAIT,
0554     RTEMS_NO_TIMEOUT
0555   );
0556 
0557  check_fn( status, message_buffer, message_size );
0558 }
0559 
0560 static void CheckForNoMessageInQueue( void *ctx_in )
0561 {
0562   Context *ctx = ctx_in;
0563   T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0564   PopMessage( ctx, CheckForNoMessage );
0565 }
0566 
0567 static void CheckForOneMessageInQueue( void *ctx_in )
0568 {
0569   Context *ctx = ctx_in;
0570   T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0571   PopMessage( ctx, CheckForFirstMessage );
0572   PopMessage( ctx, CheckForNoMessage );
0573 }
0574 
0575 static void CheckForSeveralMessagesInQueue( void *ctx_in )
0576 {
0577   Context *ctx = ctx_in;
0578   T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0579   PopMessage( ctx, CheckForFirstMessage );
0580   PopMessage( ctx, CheckForSecondMessage );
0581   PopMessage( ctx, CheckForThirdMessage );
0582   PopMessage( ctx, CheckForNoMessage );
0583 }
0584 
0585 static void MessageQueueNop( void *ctx_in )
0586 {
0587   (void) ctx_in;
0588 }
0589 
0590 static void MessageQueueDelete( void *ctx_in )
0591 {
0592   Context *ctx = ctx_in;
0593   T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0594   MessageQueueTeardown( ctx );
0595 }
0596 
0597 static Context *ToContext( TQContext *tqctx )
0598 {
0599   Context *ctx = RTEMS_CONTAINER_OF( tqctx, Context, tq_ctx );
0600   T_assert_eq_u32( ctx->magic, magic ); /* Run-time type check */
0601   return ctx;
0602 }
0603 
0604 static Status_Control ReceiveMsg( TQContext *tqctx, TQWait wait )
0605 {
0606   Context *ctx = ToContext( tqctx );
0607   rtems_status_code status;
0608   rtems_option option_set;
0609   rtems_interval timeout;
0610 
0611   switch ( wait ) {
0612     case TQ_WAIT_FOREVER:
0613       option_set = RTEMS_WAIT;
0614       timeout = RTEMS_NO_TIMEOUT;
0615       break;
0616     case TQ_WAIT_TIMED:
0617       option_set = RTEMS_WAIT;
0618       timeout = UINT32_MAX;
0619       break;
0620     default:
0621       option_set = RTEMS_NO_WAIT;
0622       timeout = 0;
0623       break;
0624   }
0625 
0626   status = rtems_message_queue_receive(
0627     ctx->tq_ctx.thread_queue_id,
0628     ctx->receive_buffer,
0629     &ctx->receive_size,
0630     option_set,
0631     timeout
0632   );
0633 
0634   return STATUS_BUILD( status, 0 );
0635 }
0636 
0637 static void SendMsg( TQContext *tqctx )
0638 {
0639   Context *ctx = ToContext( tqctx );
0640   rtems_status_code status;
0641   uint8_t msg[ MAXIMUM_MESSAGE_SIZE ];
0642 
0643   memset( msg, ctx->send_msg_counter, MAXIMUM_MESSAGE_SIZE );
0644   status = rtems_message_queue_send(
0645     ctx->tq_ctx.thread_queue_id,
0646     msg,
0647     ( ctx->send_msg_counter * 2 ) % MAXIMUM_MESSAGE_SIZE + 1
0648   );
0649   T_rsc_success( status );
0650   ++ctx->send_msg_counter;
0651 }
0652 
0653 static void EnqueuePrepare( TQContext *tqctx )
0654 {
0655   Status_Control status;
0656 
0657   /* Check that the message queue is empty */
0658   status = TQEnqueue( tqctx, TQ_NO_WAIT );
0659   T_eq_int( status, STATUS_BUILD( RTEMS_UNSATISFIED, 0 ) );
0660 }
0661 
0662 static void EnqueueDone( TQContext *tqctx )
0663 {
0664   uint32_t i;
0665 
0666   for ( i = 0; i < tqctx->how_many; ++i ) {
0667     SendMsg( tqctx );
0668   }
0669 }
0670 
0671 static void RtemsMessageReqReceive_Pre_Buffer_Prepare(
0672   RtemsMessageReqReceive_Context   *ctx,
0673   RtemsMessageReqReceive_Pre_Buffer state
0674 )
0675 {
0676   switch ( state ) {
0677     case RtemsMessageReqReceive_Pre_Buffer_Valid: {
0678       /*
0679        * While the ``buffer`` parameter references a memory area able to store
0680        * a message up to the maximum size permitted in this message queue.
0681        */
0682       ctx->buffer_param = ctx->receive_buffer;
0683       break;
0684     }
0685 
0686     case RtemsMessageReqReceive_Pre_Buffer_Null: {
0687       /*
0688        * While the ``buffer`` parameter is NULL.
0689        */
0690       ctx->buffer_param = NULL;
0691       break;
0692     }
0693 
0694     case RtemsMessageReqReceive_Pre_Buffer_NA:
0695       break;
0696   }
0697 }
0698 
0699 static void RtemsMessageReqReceive_Pre_Size_Prepare(
0700   RtemsMessageReqReceive_Context *ctx,
0701   RtemsMessageReqReceive_Pre_Size state
0702 )
0703 {
0704   switch ( state ) {
0705     case RtemsMessageReqReceive_Pre_Size_Valid: {
0706       /*
0707        * While the ``size`` parameter references an object of type ``size_t``.
0708        */
0709       ctx->size_param = &ctx->receive_size;
0710       break;
0711     }
0712 
0713     case RtemsMessageReqReceive_Pre_Size_Null: {
0714       /*
0715        * While the ``size`` parameter is NULL.
0716        */
0717       ctx->size_param = NULL;
0718       break;
0719     }
0720 
0721     case RtemsMessageReqReceive_Pre_Size_NA:
0722       break;
0723   }
0724 }
0725 
0726 static void RtemsMessageReqReceive_Pre_Id_Prepare(
0727   RtemsMessageReqReceive_Context *ctx,
0728   RtemsMessageReqReceive_Pre_Id   state
0729 )
0730 {
0731   switch ( state ) {
0732     case RtemsMessageReqReceive_Pre_Id_Valid: {
0733       /*
0734        * While the ``id`` parameter is valid.
0735        */
0736       ctx->id_param = 1;
0737       break;
0738     }
0739 
0740     case RtemsMessageReqReceive_Pre_Id_Invalid: {
0741       /*
0742        * While the ``id`` parameter is invalid.
0743        */
0744       ctx->id_param = RTEMS_ID_NONE;
0745       break;
0746     }
0747 
0748     case RtemsMessageReqReceive_Pre_Id_NA:
0749       break;
0750   }
0751 }
0752 
0753 static void RtemsMessageReqReceive_Pre_DuringWait_Prepare(
0754   RtemsMessageReqReceive_Context       *ctx,
0755   RtemsMessageReqReceive_Pre_DuringWait state
0756 )
0757 {
0758   switch ( state ) {
0759     case RtemsMessageReqReceive_Pre_DuringWait_Nop: {
0760       /*
0761        * While no rtems_message_queue_delete() directive is called successfully
0762        * on the message queue during the time one or more tasks are waiting to
0763        * receive messages.
0764        */
0765       ctx->concurrent_activity = MessageQueueNop;
0766       break;
0767     }
0768 
0769     case RtemsMessageReqReceive_Pre_DuringWait_Deleted: {
0770       /*
0771        * While rtems_message_queue_delete() is called successfully on the
0772        * message queue while one or more tasks are waiting to receive messages.
0773        */
0774       ctx->concurrent_activity = MessageQueueDelete;
0775       break;
0776     }
0777 
0778     case RtemsMessageReqReceive_Pre_DuringWait_NA:
0779       break;
0780   }
0781 }
0782 
0783 static void RtemsMessageReqReceive_Pre_TaskQueue_Prepare(
0784   RtemsMessageReqReceive_Context      *ctx,
0785   RtemsMessageReqReceive_Pre_TaskQueue state
0786 )
0787 {
0788   switch ( state ) {
0789     case RtemsMessageReqReceive_Pre_TaskQueue_Fifo: {
0790       /*
0791        * While the member attributes of type rtems_message_queue_config
0792        * contains value RTEMS_FIFO when the message queue is constructed.
0793        *
0794        * Note: RTEMS_GLOBAL is not part of the space profile because no remote
0795        * nodes are supported.
0796        */
0797       ctx->attribute_set = RTEMS_LOCAL | RTEMS_FIFO;
0798       break;
0799     }
0800 
0801     case RtemsMessageReqReceive_Pre_TaskQueue_Priority: {
0802       /*
0803        * While the member attributes of type rtems_message_queue_config
0804        * contains value RTEMS_PRIORITY when the message queue is constructed.
0805        *
0806        * Note: RTEMS_GLOBAL is not part of the space profile because no remote
0807        * nodes are supported.
0808        */
0809       ctx->attribute_set = RTEMS_LOCAL | RTEMS_PRIORITY;
0810       break;
0811     }
0812 
0813     case RtemsMessageReqReceive_Pre_TaskQueue_NA:
0814       break;
0815   }
0816 
0817   MessageQueueSetup( ctx );
0818 }
0819 
0820 static void RtemsMessageReqReceive_Pre_Wait_Prepare(
0821   RtemsMessageReqReceive_Context *ctx,
0822   RtemsMessageReqReceive_Pre_Wait state
0823 )
0824 {
0825   switch ( state ) {
0826     case RtemsMessageReqReceive_Pre_Wait_No: {
0827       /*
0828        * While the ``option_set`` parameter indicates the RTEMS_NO_WAIT option.
0829        */
0830       ctx->tq_ctx.wait =      TQ_NO_WAIT;
0831       ctx->option_set_param = RTEMS_NO_WAIT;
0832       ctx->timeout_param =    1; /* 0 would be RTEMS_NO_TIMEOUT */
0833       break;
0834     }
0835 
0836     case RtemsMessageReqReceive_Pre_Wait_Timeout: {
0837       /*
0838        * While the ``option_set`` parameter indicates the RTEMS_WAIT option,
0839        * while the ``timeout`` parameter is not equal to RTEMS_NO_TIMEOUT.
0840        */
0841       ctx->tq_ctx.wait =      TQ_WAIT_TIMED;
0842       ctx->option_set_param = RTEMS_WAIT;
0843       ctx->timeout_param =    timeout_ticks;
0844       break;
0845     }
0846 
0847     case RtemsMessageReqReceive_Pre_Wait_Forever: {
0848       /*
0849        * While the ``option_set`` parameter indicates the RTEMS_WAIT option,
0850        * while the ``timeout`` parameter is equal to RTEMS_NO_TIMEOUT.
0851        */
0852       ctx->tq_ctx.wait =      TQ_WAIT_FOREVER;
0853       ctx->option_set_param = RTEMS_WAIT;
0854       ctx->timeout_param =    RTEMS_NO_TIMEOUT;
0855       break;
0856     }
0857 
0858     case RtemsMessageReqReceive_Pre_Wait_NA:
0859       break;
0860   }
0861 }
0862 
0863 static void RtemsMessageReqReceive_Pre_MsgQueue_Prepare(
0864   RtemsMessageReqReceive_Context     *ctx,
0865   RtemsMessageReqReceive_Pre_MsgQueue state
0866 )
0867 {
0868   switch ( state ) {
0869     case RtemsMessageReqReceive_Pre_MsgQueue_Empty: {
0870       /*
0871        * While there is no message in the message queue.
0872        */
0873       /* Message queue is already empty. */
0874       ctx->check_msgq_unchanged = CheckForNoMessageInQueue;
0875       break;
0876     }
0877 
0878     case RtemsMessageReqReceive_Pre_MsgQueue_One: {
0879       /*
0880        * While there is exactly one message in the message queue.
0881        */
0882       SendMsg( &( ctx->tq_ctx ) );
0883       ctx->check_msgq_unchanged = CheckForOneMessageInQueue;
0884       break;
0885     }
0886 
0887     case RtemsMessageReqReceive_Pre_MsgQueue_Several: {
0888       /*
0889        * While there are more than one message in the message queue.
0890        */
0891       SendMsg( &( ctx->tq_ctx ) );
0892       SendMsg( &( ctx->tq_ctx ) );
0893       SendMsg( &( ctx->tq_ctx ) );
0894       ctx->check_msgq_unchanged = CheckForSeveralMessagesInQueue;
0895       break;
0896     }
0897 
0898     case RtemsMessageReqReceive_Pre_MsgQueue_NA:
0899       break;
0900   }
0901 }
0902 
0903 static void RtemsMessageReqReceive_Pre_Storage_Prepare(
0904   RtemsMessageReqReceive_Context    *ctx,
0905   RtemsMessageReqReceive_Pre_Storage state
0906 )
0907 {
0908   switch ( state ) {
0909     case RtemsMessageReqReceive_Pre_Storage_Nop: {
0910       /*
0911        * While the memory area to which a pointer is provided as member
0912        * storage_area of type rtems_message_queue_config when the message queue
0913        * is constructed by rtems_message_queue_construct() is altered only by
0914        * the RTEMS operating system.
0915        */
0916       /* Only a requirement text. */
0917       break;
0918     }
0919 
0920     case RtemsMessageReqReceive_Pre_Storage_NA:
0921       break;
0922   }
0923 }
0924 
0925 static void RtemsMessageReqReceive_Post_Status_Check(
0926   RtemsMessageReqReceive_Context    *ctx,
0927   RtemsMessageReqReceive_Post_Status state
0928 )
0929 {
0930   switch ( state ) {
0931     case RtemsMessageReqReceive_Post_Status_Ok: {
0932       /*
0933        * The return status of rtems_message_queue_receive() shall be
0934        * RTEMS_SUCCESSFUL
0935        */
0936       T_rsc_success( ctx->status );
0937       break;
0938     }
0939 
0940     case RtemsMessageReqReceive_Post_Status_InvId: {
0941       /*
0942        * The return status of rtems_message_queue_receive() shall be
0943        * RTEMS_INVALID_ID.
0944        */
0945       T_rsc( ctx->status, RTEMS_INVALID_ID );
0946       break;
0947     }
0948 
0949     case RtemsMessageReqReceive_Post_Status_InvAddr: {
0950       /*
0951        * The return status of rtems_message_queue_receive() shall be
0952        * RTEMS_INVALID_ADDRESS.
0953        */
0954       T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
0955       break;
0956     }
0957 
0958     case RtemsMessageReqReceive_Post_Status_Unsat: {
0959       /*
0960        * The return status of rtems_message_queue_receive() shall be
0961        * RTEMS_UNSATISFIED.
0962        */
0963       T_rsc( ctx->status, RTEMS_UNSATISFIED  );
0964       break;
0965     }
0966 
0967     case RtemsMessageReqReceive_Post_Status_Timeout: {
0968       /*
0969        * The return status of rtems_message_queue_receive() shall be
0970        * RTEMS_TIMEOUT.
0971        */
0972       T_rsc( ctx->status, RTEMS_TIMEOUT );
0973       break;
0974     }
0975 
0976     case RtemsMessageReqReceive_Post_Status_Deleted: {
0977       /*
0978        * The return status of rtems_message_queue_receive() shall be
0979        * RTEMS_OBJECT_WAS_DELETED.
0980        */
0981       T_rsc( ctx->status, RTEMS_OBJECT_WAS_DELETED );
0982       break;
0983     }
0984 
0985     case RtemsMessageReqReceive_Post_Status_NA:
0986       break;
0987   }
0988 }
0989 
0990 static void RtemsMessageReqReceive_Post_Delay_Check(
0991   RtemsMessageReqReceive_Context   *ctx,
0992   RtemsMessageReqReceive_Post_Delay state
0993 )
0994 {
0995   switch ( state ) {
0996     case RtemsMessageReqReceive_Post_Delay_None: {
0997       /*
0998        * The rtems_message_queue_receive() call shall return immediately.
0999        */
1000       T_eq_u32( ctx->action_duration, 0 );
1001       break;
1002     }
1003 
1004     case RtemsMessageReqReceive_Post_Delay_Ticks: {
1005       /*
1006        * The rtems_message_queue_receive() call shall return after the timeout
1007        * period in ticks.
1008        */
1009       T_eq_u32( ctx->action_duration, timeout_ticks );
1010       break;
1011     }
1012 
1013     case RtemsMessageReqReceive_Post_Delay_Forever: {
1014       /*
1015        * The rtems_message_queue_receive() call shall not return.
1016        */
1017       T_gt_u32( ctx->action_duration, timeout_ticks );
1018       break;
1019     }
1020 
1021     case RtemsMessageReqReceive_Post_Delay_NA:
1022       break;
1023   }
1024 }
1025 
1026 static void RtemsMessageReqReceive_Post_Size_Check(
1027   RtemsMessageReqReceive_Context  *ctx,
1028   RtemsMessageReqReceive_Post_Size state
1029 )
1030 {
1031   switch ( state ) {
1032     case RtemsMessageReqReceive_Post_Size_First: {
1033       /*
1034        * The value of the object referenced by the ``size`` parameter shall be
1035        * set to the size of the first message (the same value as provided by
1036        * parameter ``size`` of the rtems_message_queue_send() or
1037        * rtems_message_queue_urgent() directive which added the message to the
1038        * queue) after the return of the rtems_message_queue_receive() call.
1039        */
1040       CheckForFirstMessage(
1041         ctx->status,
1042         ctx->receive_buffer,
1043         ctx->receive_size
1044       );
1045       break;
1046     }
1047 
1048     case RtemsMessageReqReceive_Post_Size_Nop: {
1049       /*
1050        * Objects referenced by the ``size`` parameter in past calls to
1051        * rtems_message_queue_receive() shall not be accessed by the
1052        * rtems_message_queue_receive() call (see also Nop).
1053        */
1054       T_eq_sz( ctx->receive_size, SIZE_MAX );
1055       break;
1056     }
1057 
1058     case RtemsMessageReqReceive_Post_Size_NA:
1059       break;
1060   }
1061 }
1062 
1063 static void RtemsMessageReqReceive_Post_Msg_Check(
1064   RtemsMessageReqReceive_Context *ctx,
1065   RtemsMessageReqReceive_Post_Msg state
1066 )
1067 {
1068   switch ( state ) {
1069     case RtemsMessageReqReceive_Post_Msg_First: {
1070       /*
1071        * The bytes 0 till ``size`` - 1 of the object referenced by the
1072        * ``option_set`` parameter shall contain a copy of the content of the
1073        * first message (all bytes unchanged and in the same order as provided
1074        * by parameter ``buffer`` of the rtems_message_queue_send() or
1075        * rtems_message_queue_urgent() directive which added the message to the
1076        * queue) after the return of the rtems_message_queue_receive() call.
1077        */
1078       CheckForFirstMessage(
1079         ctx->status,
1080         ctx->receive_buffer,
1081         ctx->receive_size
1082       );
1083       break;
1084     }
1085 
1086     case RtemsMessageReqReceive_Post_Msg_Nop: {
1087       /*
1088        * Objects referenced by the ``option_set`` parameter in past calls to
1089        * rtems_message_queue_receive() shall not be accessed by the
1090        * rtems_message_queue_receive() call (see also Nop).
1091        */
1092       int i;
1093       for ( i = 0; i < MAXIMUM_MESSAGE_SIZE; ++i ) {
1094         T_eq_u8( ctx->receive_buffer[i], UINT8_MAX );
1095       }
1096       break;
1097     }
1098 
1099     case RtemsMessageReqReceive_Post_Msg_NA:
1100       break;
1101   }
1102 }
1103 
1104 static void RtemsMessageReqReceive_Post_MsgQueue_Check(
1105   RtemsMessageReqReceive_Context      *ctx,
1106   RtemsMessageReqReceive_Post_MsgQueue state
1107 )
1108 {
1109   switch ( state ) {
1110     case RtemsMessageReqReceive_Post_MsgQueue_Empty: {
1111       /*
1112        * The message queue shall be empty after the return of the
1113        * rtems_message_queue_receive() call.
1114        */
1115       PopMessage( ctx, CheckForNoMessage );
1116       break;
1117     }
1118 
1119     case RtemsMessageReqReceive_Post_MsgQueue_OneLess: {
1120       /*
1121        * The first message shall be removed from the message queue after the
1122        * return of the rtems_message_queue_receive() call.
1123        */
1124       PopMessage( ctx, CheckForSecondMessage );
1125       PopMessage( ctx, CheckForThirdMessage );
1126       PopMessage( ctx, CheckForNoMessage );
1127       break;
1128     }
1129 
1130     case RtemsMessageReqReceive_Post_MsgQueue_Nop: {
1131       /*
1132        * Objects referenced by the ``id`` parameter in past calls to
1133        * rtems_message_queue_receive() shall not be accessed by the
1134        * rtems_message_queue_receive() call (see also Nop).
1135        */
1136       ctx->check_msgq_unchanged( ctx );
1137       break;
1138     }
1139 
1140     case RtemsMessageReqReceive_Post_MsgQueue_NA:
1141       break;
1142   }
1143 
1144   MessageQueueTeardown( ctx );
1145 }
1146 
1147 static void RtemsMessageReqReceive_Post_Tasks_Check(
1148   RtemsMessageReqReceive_Context   *ctx,
1149   RtemsMessageReqReceive_Post_Tasks state
1150 )
1151 {
1152   MessageQueueSetup( ctx );
1153 
1154   switch ( state ) {
1155     case RtemsMessageReqReceive_Post_Tasks_Fifo: {
1156       /*
1157        * Where the thread queue uses the FIFO discipline, the calling thread
1158        * shall be enqueued in FIFO order.
1159        */
1160       ScoreTqReqEnqueueFifo_Run( &ctx->tq_ctx );
1161       break;
1162     }
1163 
1164     case RtemsMessageReqReceive_Post_Tasks_Priority: {
1165       /*
1166        * Where the thread queue uses the priority discipline, the calling
1167        * thread shall be enqueued in priority order.
1168        */
1169       ScoreTqReqEnqueuePriority_Run( &ctx->tq_ctx );
1170       break;
1171     }
1172 
1173     case RtemsMessageReqReceive_Post_Tasks_NA:
1174       break;
1175   }
1176 
1177   MessageQueueTeardown( ctx );
1178 }
1179 
1180 static void RtemsMessageReqReceive_Setup( RtemsMessageReqReceive_Context *ctx )
1181 {
1182   memset( ctx, 0, sizeof( *ctx ) );
1183   ctx->magic                  = magic;
1184   ctx->tq_ctx.enqueue         = ReceiveMsg;
1185   ctx->tq_ctx.surrender       = TQDoNothingSuccessfully;
1186   ctx->tq_ctx.convert_status  = TQConvertStatusClassic;
1187   ctx->tq_ctx.enqueue_prepare = EnqueuePrepare;
1188   ctx->tq_ctx.enqueue_done    = EnqueueDone;
1189   TQInitialize( &ctx->tq_ctx );
1190 
1191   /*
1192    * ctx->tq_ctx.thread_queue_id = RTEMS_ID_NONE indicates that the message
1193    * queue does currently not exist. A message queue is created
1194    * two times in a row in a single test cycle. First after the attributes
1195    * are set in the preconditions. That queue is used for all tests of
1196    * usual message queue requirements. Second a message queue is recreated
1197    * in the tasks post-conditions for the tests of the task queue.
1198    * To avoid an accidentally creation of a second
1199    * message queue without the first being deleted prior,
1200    * ctx->tq_ctx.thread_queue_id is checked for being RTEMS_ID_NONE before
1201    * any message queue is created - a run-time sanity check.
1202    */
1203   ctx->tq_ctx.thread_queue_id = RTEMS_ID_NONE;
1204   ctx->task_id                = rtems_task_self();
1205 
1206   /* Note: TQInitialize() will assign the "main" task priority PRIO_NORMAL */
1207   ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
1208   StartTask( ctx->worker_id, WorkerTask, NULL );
1209 }
1210 
1211 static void RtemsMessageReqReceive_Setup_Wrap( void *arg )
1212 {
1213   RtemsMessageReqReceive_Context *ctx;
1214 
1215   ctx = arg;
1216   ctx->Map.in_action_loop = false;
1217   RtemsMessageReqReceive_Setup( ctx );
1218 }
1219 
1220 static void RtemsMessageReqReceive_Teardown(
1221   RtemsMessageReqReceive_Context *ctx
1222 )
1223 {
1224   DeleteTask( ctx->worker_id );
1225   TQDestroy( &ctx->tq_ctx );
1226   (void) PollAnyEvents();
1227 }
1228 
1229 static void RtemsMessageReqReceive_Teardown_Wrap( void *arg )
1230 {
1231   RtemsMessageReqReceive_Context *ctx;
1232 
1233   ctx = arg;
1234   ctx->Map.in_action_loop = false;
1235   RtemsMessageReqReceive_Teardown( ctx );
1236 }
1237 
1238 static void RtemsMessageReqReceive_Prepare(
1239   RtemsMessageReqReceive_Context *ctx
1240 )
1241 {
1242   /* Clean away pending events - happens after RTEMS_WAIT + RTEMS_NO_TIMEOUT */
1243   (void) PollAnyEvents();
1244 
1245   ctx->send_msg_counter = 0;
1246   ctx->receive_size     = SIZE_MAX;
1247   memset( ctx->receive_buffer, UINT8_MAX, MAXIMUM_MESSAGE_SIZE );
1248 }
1249 
1250 static void RtemsMessageReqReceive_Action(
1251   RtemsMessageReqReceive_Context *ctx
1252 )
1253 {
1254   WorkerDoAction( ctx );
1255   ctx->concurrent_activity( ctx );
1256   ctx->action_duration = WaitForWorker( ctx );
1257 }
1258 
1259 static const RtemsMessageReqReceive_Entry
1260 RtemsMessageReqReceive_Entries[] = {
1261   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_InvAddr,
1262     RtemsMessageReqReceive_Post_Delay_None,
1263     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1264     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1265     RtemsMessageReqReceive_Post_Tasks_NA },
1266   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_InvAddr,
1267     RtemsMessageReqReceive_Post_Delay_None,
1268     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1269     RtemsMessageReqReceive_Post_MsgQueue_NA,
1270     RtemsMessageReqReceive_Post_Tasks_NA },
1271   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_InvId,
1272     RtemsMessageReqReceive_Post_Delay_None,
1273     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1274     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1275     RtemsMessageReqReceive_Post_Tasks_NA },
1276   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_InvId,
1277     RtemsMessageReqReceive_Post_Delay_None,
1278     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1279     RtemsMessageReqReceive_Post_MsgQueue_NA,
1280     RtemsMessageReqReceive_Post_Tasks_NA },
1281   { 1, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_NA,
1282     RtemsMessageReqReceive_Post_Delay_NA, RtemsMessageReqReceive_Post_Size_NA,
1283     RtemsMessageReqReceive_Post_Msg_NA,
1284     RtemsMessageReqReceive_Post_MsgQueue_NA,
1285     RtemsMessageReqReceive_Post_Tasks_NA },
1286   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_Ok,
1287     RtemsMessageReqReceive_Post_Delay_None,
1288     RtemsMessageReqReceive_Post_Size_First,
1289     RtemsMessageReqReceive_Post_Msg_First,
1290     RtemsMessageReqReceive_Post_MsgQueue_Empty,
1291     RtemsMessageReqReceive_Post_Tasks_NA },
1292   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_Ok,
1293     RtemsMessageReqReceive_Post_Delay_None,
1294     RtemsMessageReqReceive_Post_Size_First,
1295     RtemsMessageReqReceive_Post_Msg_First,
1296     RtemsMessageReqReceive_Post_MsgQueue_OneLess,
1297     RtemsMessageReqReceive_Post_Tasks_NA },
1298   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_Deleted,
1299     RtemsMessageReqReceive_Post_Delay_None,
1300     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1301     RtemsMessageReqReceive_Post_MsgQueue_NA,
1302     RtemsMessageReqReceive_Post_Tasks_NA },
1303   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_Unsat,
1304     RtemsMessageReqReceive_Post_Delay_None,
1305     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1306     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1307     RtemsMessageReqReceive_Post_Tasks_NA },
1308   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_Timeout,
1309     RtemsMessageReqReceive_Post_Delay_Ticks,
1310     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1311     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1312     RtemsMessageReqReceive_Post_Tasks_Fifo },
1313   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_NA,
1314     RtemsMessageReqReceive_Post_Delay_Forever,
1315     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1316     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1317     RtemsMessageReqReceive_Post_Tasks_Fifo },
1318   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_Timeout,
1319     RtemsMessageReqReceive_Post_Delay_Ticks,
1320     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1321     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1322     RtemsMessageReqReceive_Post_Tasks_Priority },
1323   { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqReceive_Post_Status_NA,
1324     RtemsMessageReqReceive_Post_Delay_Forever,
1325     RtemsMessageReqReceive_Post_Size_Nop, RtemsMessageReqReceive_Post_Msg_Nop,
1326     RtemsMessageReqReceive_Post_MsgQueue_Nop,
1327     RtemsMessageReqReceive_Post_Tasks_Priority }
1328 };
1329 
1330 static const uint8_t
1331 RtemsMessageReqReceive_Map[] = {
1332   8, 5, 6, 9, 5, 6, 10, 5, 6, 8, 5, 6, 11, 5, 6, 12, 5, 6, 4, 4, 4, 7, 4, 4, 7,
1333   4, 4, 4, 4, 4, 7, 4, 4, 7, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1334   2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0,
1335   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1336   1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1337   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1338   0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1339   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1340   1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1341   0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
1342   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1343   1, 1, 1
1344 };
1345 
1346 static size_t RtemsMessageReqReceive_Scope( void *arg, char *buf, size_t n )
1347 {
1348   RtemsMessageReqReceive_Context *ctx;
1349 
1350   ctx = arg;
1351 
1352   if ( ctx->Map.in_action_loop ) {
1353     return T_get_scope( RtemsMessageReqReceive_PreDesc, buf, n, ctx->Map.pcs );
1354   }
1355 
1356   return 0;
1357 }
1358 
1359 static T_fixture RtemsMessageReqReceive_Fixture = {
1360   .setup = RtemsMessageReqReceive_Setup_Wrap,
1361   .stop = NULL,
1362   .teardown = RtemsMessageReqReceive_Teardown_Wrap,
1363   .scope = RtemsMessageReqReceive_Scope,
1364   .initial_context = &RtemsMessageReqReceive_Instance
1365 };
1366 
1367 static inline RtemsMessageReqReceive_Entry RtemsMessageReqReceive_PopEntry(
1368   RtemsMessageReqReceive_Context *ctx
1369 )
1370 {
1371   size_t index;
1372 
1373   index = ctx->Map.index;
1374   ctx->Map.index = index + 1;
1375   return RtemsMessageReqReceive_Entries[
1376     RtemsMessageReqReceive_Map[ index ]
1377   ];
1378 }
1379 
1380 static void RtemsMessageReqReceive_TestVariant(
1381   RtemsMessageReqReceive_Context *ctx
1382 )
1383 {
1384   RtemsMessageReqReceive_Pre_Buffer_Prepare( ctx, ctx->Map.pcs[ 0 ] );
1385   RtemsMessageReqReceive_Pre_Size_Prepare( ctx, ctx->Map.pcs[ 1 ] );
1386   RtemsMessageReqReceive_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 2 ] );
1387   RtemsMessageReqReceive_Pre_DuringWait_Prepare( ctx, ctx->Map.pcs[ 3 ] );
1388   RtemsMessageReqReceive_Pre_TaskQueue_Prepare( ctx, ctx->Map.pcs[ 4 ] );
1389   RtemsMessageReqReceive_Pre_Wait_Prepare( ctx, ctx->Map.pcs[ 5 ] );
1390   RtemsMessageReqReceive_Pre_MsgQueue_Prepare( ctx, ctx->Map.pcs[ 6 ] );
1391   RtemsMessageReqReceive_Pre_Storage_Prepare( ctx, ctx->Map.pcs[ 7 ] );
1392   RtemsMessageReqReceive_Action( ctx );
1393   RtemsMessageReqReceive_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
1394   RtemsMessageReqReceive_Post_Delay_Check( ctx, ctx->Map.entry.Post_Delay );
1395   RtemsMessageReqReceive_Post_Size_Check( ctx, ctx->Map.entry.Post_Size );
1396   RtemsMessageReqReceive_Post_Msg_Check( ctx, ctx->Map.entry.Post_Msg );
1397   RtemsMessageReqReceive_Post_MsgQueue_Check(
1398     ctx,
1399     ctx->Map.entry.Post_MsgQueue
1400   );
1401   RtemsMessageReqReceive_Post_Tasks_Check( ctx, ctx->Map.entry.Post_Tasks );
1402 }
1403 
1404 /**
1405  * @fn void T_case_body_RtemsMessageReqReceive( void )
1406  */
1407 T_TEST_CASE_FIXTURE( RtemsMessageReqReceive, &RtemsMessageReqReceive_Fixture )
1408 {
1409   RtemsMessageReqReceive_Context *ctx;
1410 
1411   ctx = T_fixture_context();
1412   ctx->Map.in_action_loop = true;
1413   ctx->Map.index = 0;
1414 
1415   for (
1416     ctx->Map.pcs[ 0 ] = RtemsMessageReqReceive_Pre_Buffer_Valid;
1417     ctx->Map.pcs[ 0 ] < RtemsMessageReqReceive_Pre_Buffer_NA;
1418     ++ctx->Map.pcs[ 0 ]
1419   ) {
1420     for (
1421       ctx->Map.pcs[ 1 ] = RtemsMessageReqReceive_Pre_Size_Valid;
1422       ctx->Map.pcs[ 1 ] < RtemsMessageReqReceive_Pre_Size_NA;
1423       ++ctx->Map.pcs[ 1 ]
1424     ) {
1425       for (
1426         ctx->Map.pcs[ 2 ] = RtemsMessageReqReceive_Pre_Id_Valid;
1427         ctx->Map.pcs[ 2 ] < RtemsMessageReqReceive_Pre_Id_NA;
1428         ++ctx->Map.pcs[ 2 ]
1429       ) {
1430         for (
1431           ctx->Map.pcs[ 3 ] = RtemsMessageReqReceive_Pre_DuringWait_Nop;
1432           ctx->Map.pcs[ 3 ] < RtemsMessageReqReceive_Pre_DuringWait_NA;
1433           ++ctx->Map.pcs[ 3 ]
1434         ) {
1435           for (
1436             ctx->Map.pcs[ 4 ] = RtemsMessageReqReceive_Pre_TaskQueue_Fifo;
1437             ctx->Map.pcs[ 4 ] < RtemsMessageReqReceive_Pre_TaskQueue_NA;
1438             ++ctx->Map.pcs[ 4 ]
1439           ) {
1440             for (
1441               ctx->Map.pcs[ 5 ] = RtemsMessageReqReceive_Pre_Wait_No;
1442               ctx->Map.pcs[ 5 ] < RtemsMessageReqReceive_Pre_Wait_NA;
1443               ++ctx->Map.pcs[ 5 ]
1444             ) {
1445               for (
1446                 ctx->Map.pcs[ 6 ] = RtemsMessageReqReceive_Pre_MsgQueue_Empty;
1447                 ctx->Map.pcs[ 6 ] < RtemsMessageReqReceive_Pre_MsgQueue_NA;
1448                 ++ctx->Map.pcs[ 6 ]
1449               ) {
1450                 for (
1451                   ctx->Map.pcs[ 7 ] = RtemsMessageReqReceive_Pre_Storage_Nop;
1452                   ctx->Map.pcs[ 7 ] < RtemsMessageReqReceive_Pre_Storage_NA;
1453                   ++ctx->Map.pcs[ 7 ]
1454                 ) {
1455                   ctx->Map.entry = RtemsMessageReqReceive_PopEntry( ctx );
1456 
1457                   if ( ctx->Map.entry.Skip ) {
1458                     continue;
1459                   }
1460 
1461                   RtemsMessageReqReceive_Prepare( ctx );
1462                   RtemsMessageReqReceive_TestVariant( ctx );
1463                 }
1464               }
1465             }
1466           }
1467         }
1468       }
1469     }
1470   }
1471 }
1472 
1473 /** @} */