Changeset 006c702 in rtems


Ignore:
Timestamp:
02/21/21 16:48:04 (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
e8284a34
Parents:
fd838603
git-author:
Sebastian Huber <sebastian.huber@…> (02/21/21 16:48:04)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/24/21 08:22:36)
Message:

validation: Simplify message queue construct tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/validation/tc-message-construct-errors.c

    rfd838603 r006c702  
    9696
    9797typedef enum {
    98   RtemsMessageReqConstructErrors_Pre_Queues_Avail,
    99   RtemsMessageReqConstructErrors_Pre_Queues_None,
    100   RtemsMessageReqConstructErrors_Pre_Queues_NA
    101 } RtemsMessageReqConstructErrors_Pre_Queues;
     98  RtemsMessageReqConstructErrors_Pre_Free_Yes,
     99  RtemsMessageReqConstructErrors_Pre_Free_No,
     100  RtemsMessageReqConstructErrors_Pre_Free_NA
     101} RtemsMessageReqConstructErrors_Pre_Free;
    102102
    103103typedef enum {
     
    136136  rtems_id id_value;
    137137
    138   Chain_Control message_queues;
     138  void *seized_objects;
    139139
    140140  /**
     
    179179};
    180180
    181 static const char * const RtemsMessageReqConstructErrors_PreDesc_Queues[] = {
    182   "Avail",
    183   "None",
     181static const char * const RtemsMessageReqConstructErrors_PreDesc_Free[] = {
     182  "Yes",
     183  "No",
    184184  "NA"
    185185};
     
    202202  RtemsMessageReqConstructErrors_PreDesc_MaxPending,
    203203  RtemsMessageReqConstructErrors_PreDesc_MaxSize,
    204   RtemsMessageReqConstructErrors_PreDesc_Queues,
     204  RtemsMessageReqConstructErrors_PreDesc_Free,
    205205  RtemsMessageReqConstructErrors_PreDesc_Area,
    206206  RtemsMessageReqConstructErrors_PreDesc_AreaSize,
     
    215215
    216216static RTEMS_MESSAGE_QUEUE_BUFFER( MAX_MESSAGE_SIZE )
    217   exhaust_buffers[ MAX_MESSAGE_QUEUES ][ MAX_PENDING_MESSAGES ];
     217  buffers_to_seize[ MAX_MESSAGE_QUEUES ][ MAX_PENDING_MESSAGES ];
    218218
    219219static RTEMS_MESSAGE_QUEUE_BUFFER( MAX_MESSAGE_SIZE )
    220220  buffers[ MAX_PENDING_MESSAGES ];
     221
     222static rtems_status_code Create( void *arg, uint32_t *id )
     223{
     224  rtems_message_queue_config config;
     225  size_t                    *i;
     226
     227  i = arg;
     228  T_quiet_lt_sz( *i, MAX_MESSAGE_QUEUES );
     229
     230  memset( &config, 0, sizeof( config ) );
     231  config.name = rtems_build_name( 'S', 'I', 'Z', 'E' );
     232  config.maximum_pending_messages = MAX_PENDING_MESSAGES;
     233  config.maximum_message_size = MAX_MESSAGE_SIZE;
     234  config.storage_size = sizeof( buffers_to_seize[ *i ] );
     235  config.storage_area = buffers_to_seize[ *i ];
     236  config.attributes = RTEMS_DEFAULT_ATTRIBUTES;
     237
     238  ++(*i);
     239
     240  return rtems_message_queue_construct( &config, id );
     241}
    221242
    222243static void RtemsMessageReqConstructErrors_Pre_Id_Prepare(
     
    314335}
    315336
    316 static void RtemsMessageReqConstructErrors_Pre_Queues_Prepare(
    317   RtemsMessageReqConstructErrors_Context   *ctx,
    318   RtemsMessageReqConstructErrors_Pre_Queues state
     337static void RtemsMessageReqConstructErrors_Pre_Free_Prepare(
     338  RtemsMessageReqConstructErrors_Context *ctx,
     339  RtemsMessageReqConstructErrors_Pre_Free state
    319340)
    320341{
    321   rtems_message_queue_config config;
    322   size_t                     i;
     342  size_t i;
    323343
    324344  switch ( state ) {
    325     case RtemsMessageReqConstructErrors_Pre_Queues_Avail: {
     345    case RtemsMessageReqConstructErrors_Pre_Free_Yes: {
    326346      /* Nothing to do */
    327347      break;
    328348    }
    329349
    330     case RtemsMessageReqConstructErrors_Pre_Queues_None: {
    331       memset( &config, 0, sizeof( config ) );
    332       config.name = rtems_build_name( 'M', 'S', 'G', 'Q' );
    333       config.maximum_pending_messages = MAX_PENDING_MESSAGES;
    334       config.maximum_message_size = MAX_MESSAGE_SIZE;
    335       config.storage_size = sizeof( exhaust_buffers[ 0 ] );
    336       config.attributes = RTEMS_DEFAULT_ATTRIBUTES;
    337 
     350    case RtemsMessageReqConstructErrors_Pre_Free_No: {
    338351      i = 0;
    339 
    340       while ( i < MAX_MESSAGE_QUEUES ) {
    341         rtems_status_code sc;
    342         rtems_id          id;
    343 
    344         config.storage_area = exhaust_buffers[ i ];
    345 
    346         sc = rtems_message_queue_construct( &config, &id );
    347 
    348         if ( sc == RTEMS_SUCCESSFUL ) {
    349           Objects_Control           *obj;
    350           const Objects_Information *info;
    351 
    352           info = _Objects_Get_information_id( id );
    353           T_quiet_assert_not_null( info );
    354           obj = _Objects_Get_no_protection( id, info );
    355           T_quiet_assert_not_null( obj );
    356           _Chain_Append_unprotected( &ctx->message_queues, &obj->Node );
    357         } else {
    358           T_quiet_rsc( sc, RTEMS_TOO_MANY );
    359           break;
    360         }
    361 
    362         ++i;
    363       }
    364       break;
    365     }
    366 
    367     case RtemsMessageReqConstructErrors_Pre_Queues_NA:
     352      ctx->seized_objects = T_seize_objects( Create, &i );
     353      break;
     354    }
     355
     356    case RtemsMessageReqConstructErrors_Pre_Free_NA:
    368357      break;
    369358  }
     
    472461}
    473462
    474 static void RtemsMessageReqConstructErrors_Setup(
    475   RtemsMessageReqConstructErrors_Context *ctx
    476 )
    477 {
    478   _Chain_Initialize_empty( &ctx->message_queues );
    479 }
    480 
    481 static void RtemsMessageReqConstructErrors_Setup_Wrap( void *arg )
    482 {
    483   RtemsMessageReqConstructErrors_Context *ctx;
    484 
    485   ctx = arg;
    486   ctx->in_action_loop = false;
    487   RtemsMessageReqConstructErrors_Setup( ctx );
    488 }
    489 
    490463static size_t RtemsMessageReqConstructErrors_Scope(
    491464  void  *arg,
     
    511484
    512485static T_fixture RtemsMessageReqConstructErrors_Fixture = {
    513   .setup = RtemsMessageReqConstructErrors_Setup_Wrap,
     486  .setup = NULL,
    514487  .stop = NULL,
    515488  .teardown = NULL,
     
    11041077  uint8_t Pre_MaxPending_NA : 1;
    11051078  uint8_t Pre_MaxSize_NA : 1;
    1106   uint8_t Pre_Queues_NA : 1;
     1079  uint8_t Pre_Free_NA : 1;
    11071080  uint8_t Pre_Area_NA : 1;
    11081081  uint8_t Pre_AreaSize_NA : 1;
     
    17061679)
    17071680{
    1708   Chain_Node *node;
    1709 
    1710   while ( ( node = _Chain_Get_unprotected( &ctx->message_queues ) ) ) {
    1711     Objects_Control   *obj;
    1712     rtems_status_code  sc;
    1713 
    1714     obj = (Objects_Control *) node;
    1715     sc = rtems_message_queue_delete( obj->id );
    1716     T_quiet_rsc_success( sc );
    1717   }
     1681  T_surrender_objects( &ctx->seized_objects, rtems_message_queue_delete );
    17181682}
    17191683
     
    17441708        * RtemsMessageReqConstructErrors_Pre_MaxPending_NA
    17451709        * RtemsMessageReqConstructErrors_Pre_MaxSize_NA
    1746         * RtemsMessageReqConstructErrors_Pre_Queues_NA
     1710        * RtemsMessageReqConstructErrors_Pre_Free_NA
    17471711        * RtemsMessageReqConstructErrors_Pre_Area_NA
    17481712        * RtemsMessageReqConstructErrors_Pre_AreaSize_NA;
     
    17591723          * RtemsMessageReqConstructErrors_Pre_MaxPending_NA
    17601724          * RtemsMessageReqConstructErrors_Pre_MaxSize_NA
    1761           * RtemsMessageReqConstructErrors_Pre_Queues_NA
     1725          * RtemsMessageReqConstructErrors_Pre_Free_NA
    17621726          * RtemsMessageReqConstructErrors_Pre_Area_NA
    17631727          * RtemsMessageReqConstructErrors_Pre_AreaSize_NA;
     
    17731737          index += ( RtemsMessageReqConstructErrors_Pre_MaxPending_NA - 1 )
    17741738            * RtemsMessageReqConstructErrors_Pre_MaxSize_NA
    1775             * RtemsMessageReqConstructErrors_Pre_Queues_NA
     1739            * RtemsMessageReqConstructErrors_Pre_Free_NA
    17761740            * RtemsMessageReqConstructErrors_Pre_Area_NA
    17771741            * RtemsMessageReqConstructErrors_Pre_AreaSize_NA;
     
    17861750            ctx->pcs[ 3 ] = RtemsMessageReqConstructErrors_Pre_MaxSize_NA;
    17871751            index += ( RtemsMessageReqConstructErrors_Pre_MaxSize_NA - 1 )
    1788               * RtemsMessageReqConstructErrors_Pre_Queues_NA
     1752              * RtemsMessageReqConstructErrors_Pre_Free_NA
    17891753              * RtemsMessageReqConstructErrors_Pre_Area_NA
    17901754              * RtemsMessageReqConstructErrors_Pre_AreaSize_NA;
     
    17921756
    17931757          for (
    1794             ctx->pcs[ 4 ] = RtemsMessageReqConstructErrors_Pre_Queues_Avail;
    1795             ctx->pcs[ 4 ] < RtemsMessageReqConstructErrors_Pre_Queues_NA;
     1758            ctx->pcs[ 4 ] = RtemsMessageReqConstructErrors_Pre_Free_Yes;
     1759            ctx->pcs[ 4 ] < RtemsMessageReqConstructErrors_Pre_Free_NA;
    17961760            ++ctx->pcs[ 4 ]
    17971761          ) {
    1798             if ( RtemsMessageReqConstructErrors_TransitionInfo[ index ].Pre_Queues_NA ) {
    1799               ctx->pcs[ 4 ] = RtemsMessageReqConstructErrors_Pre_Queues_NA;
    1800               index += ( RtemsMessageReqConstructErrors_Pre_Queues_NA - 1 )
     1762            if ( RtemsMessageReqConstructErrors_TransitionInfo[ index ].Pre_Free_NA ) {
     1763              ctx->pcs[ 4 ] = RtemsMessageReqConstructErrors_Pre_Free_NA;
     1764              index += ( RtemsMessageReqConstructErrors_Pre_Free_NA - 1 )
    18011765                * RtemsMessageReqConstructErrors_Pre_Area_NA
    18021766                * RtemsMessageReqConstructErrors_Pre_AreaSize_NA;
     
    18461810                  ctx->pcs[ 3 ]
    18471811                );
    1848                 RtemsMessageReqConstructErrors_Pre_Queues_Prepare(
     1812                RtemsMessageReqConstructErrors_Pre_Free_Prepare(
    18491813                  ctx,
    18501814                  ctx->pcs[ 4 ]
Note: See TracChangeset for help on using the changeset viewer.