diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-09-07 09:04:09 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-09-30 12:43:48 +0200 |
commit | a052bd48bf1c0f9dcbb5a50b525237a89b4b0466 (patch) | |
tree | 7fd0a6f686c14009666b8259fb71d1194fe2471a | |
parent | 630c24dbe97ba81443bd49afb17b427a9419395a (diff) |
validation: Test message storage free handler
-rw-r--r-- | spec/build/testsuites/validation/validation-0.yml | 2 | ||||
-rw-r--r-- | testsuites/validation/tc-message-construct-errors.c | 941 | ||||
-rw-r--r-- | testsuites/validation/tc-message-construct.c | 1059 |
3 files changed, 1060 insertions, 942 deletions
diff --git a/spec/build/testsuites/validation/validation-0.yml b/spec/build/testsuites/validation/validation-0.yml index 340b9a553f..d4342b31e1 100644 --- a/spec/build/testsuites/validation/validation-0.yml +++ b/spec/build/testsuites/validation/validation-0.yml @@ -46,7 +46,7 @@ source: - testsuites/validation/tc-mem-rtems-calloc.c - testsuites/validation/tc-mem-rtems-malloc.c - testsuites/validation/tc-mem-posix-memalign.c -- testsuites/validation/tc-message-construct-errors.c +- testsuites/validation/tc-message-construct.c - testsuites/validation/tc-message-delete.c - testsuites/validation/tc-message-ident.c - testsuites/validation/tc-modes.c diff --git a/testsuites/validation/tc-message-construct-errors.c b/testsuites/validation/tc-message-construct-errors.c deleted file mode 100644 index f64ceb4626..0000000000 --- a/testsuites/validation/tc-message-construct-errors.c +++ /dev/null @@ -1,941 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSTestCaseRtemsMessageReqConstructErrors - */ - -/* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This file is part of the RTEMS quality process and was automatically - * generated. If you find something that needs to be fixed or - * worded better please post a report or patch to an RTEMS mailing list - * or raise a bug report: - * - * https://www.rtems.org/bugs.html - * - * For information on updating and regenerating please refer to the How-To - * section in the Software Requirements Engineering chapter of the - * RTEMS Software Engineering manual. The manual is provided as a part of - * a release. For development sources please refer to the online - * documentation at: - * - * https://docs.rtems.org - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems.h> -#include <string.h> - -#include "tx-support.h" - -#include <rtems/test.h> - -/** - * @defgroup RTEMSTestCaseRtemsMessageReqConstructErrors \ - * spec:/rtems/message/req/construct-errors - * - * @ingroup RTEMSTestSuiteTestsuitesValidation0 - * - * @{ - */ - -typedef enum { - RtemsMessageReqConstructErrors_Pre_Config_Valid, - RtemsMessageReqConstructErrors_Pre_Config_Null, - RtemsMessageReqConstructErrors_Pre_Config_NA -} RtemsMessageReqConstructErrors_Pre_Config; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_Name_Valid, - RtemsMessageReqConstructErrors_Pre_Name_Invalid, - RtemsMessageReqConstructErrors_Pre_Name_NA -} RtemsMessageReqConstructErrors_Pre_Name; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_Id_Id, - RtemsMessageReqConstructErrors_Pre_Id_Null, - RtemsMessageReqConstructErrors_Pre_Id_NA -} RtemsMessageReqConstructErrors_Pre_Id; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_MaxPending_Valid, - RtemsMessageReqConstructErrors_Pre_MaxPending_Zero, - RtemsMessageReqConstructErrors_Pre_MaxPending_Big, - RtemsMessageReqConstructErrors_Pre_MaxPending_NA -} RtemsMessageReqConstructErrors_Pre_MaxPending; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_MaxSize_Valid, - RtemsMessageReqConstructErrors_Pre_MaxSize_Zero, - RtemsMessageReqConstructErrors_Pre_MaxSize_Big, - RtemsMessageReqConstructErrors_Pre_MaxSize_NA -} RtemsMessageReqConstructErrors_Pre_MaxSize; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_Free_Yes, - RtemsMessageReqConstructErrors_Pre_Free_No, - RtemsMessageReqConstructErrors_Pre_Free_NA -} RtemsMessageReqConstructErrors_Pre_Free; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_Area_Valid, - RtemsMessageReqConstructErrors_Pre_Area_Null, - RtemsMessageReqConstructErrors_Pre_Area_NA -} RtemsMessageReqConstructErrors_Pre_Area; - -typedef enum { - RtemsMessageReqConstructErrors_Pre_AreaSize_Valid, - RtemsMessageReqConstructErrors_Pre_AreaSize_Invalid, - RtemsMessageReqConstructErrors_Pre_AreaSize_NA -} RtemsMessageReqConstructErrors_Pre_AreaSize; - -typedef enum { - RtemsMessageReqConstructErrors_Post_Status_Ok, - RtemsMessageReqConstructErrors_Post_Status_InvAddr, - RtemsMessageReqConstructErrors_Post_Status_InvName, - RtemsMessageReqConstructErrors_Post_Status_InvNum, - RtemsMessageReqConstructErrors_Post_Status_InvSize, - RtemsMessageReqConstructErrors_Post_Status_TooMany, - RtemsMessageReqConstructErrors_Post_Status_Unsat, - RtemsMessageReqConstructErrors_Post_Status_NA -} RtemsMessageReqConstructErrors_Post_Status; - -typedef enum { - RtemsMessageReqConstructErrors_Post_Name_Valid, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_Name_NA -} RtemsMessageReqConstructErrors_Post_Name; - -typedef enum { - RtemsMessageReqConstructErrors_Post_IdVar_Set, - RtemsMessageReqConstructErrors_Post_IdVar_Nop, - RtemsMessageReqConstructErrors_Post_IdVar_NA -} RtemsMessageReqConstructErrors_Post_IdVar; - -typedef struct { - uint16_t Skip : 1; - uint16_t Pre_Config_NA : 1; - uint16_t Pre_Name_NA : 1; - uint16_t Pre_Id_NA : 1; - uint16_t Pre_MaxPending_NA : 1; - uint16_t Pre_MaxSize_NA : 1; - uint16_t Pre_Free_NA : 1; - uint16_t Pre_Area_NA : 1; - uint16_t Pre_AreaSize_NA : 1; - uint16_t Post_Status : 3; - uint16_t Post_Name : 2; - uint16_t Post_IdVar : 2; -} RtemsMessageReqConstructErrors_Entry; - -/** - * @brief Test context for spec:/rtems/message/req/construct-errors test case. - */ -typedef struct { - rtems_status_code status; - - const rtems_message_queue_config *config; - - rtems_message_queue_config config_value; - - rtems_id *id; - - rtems_id id_value; - - void *seized_objects; - - struct { - /** - * @brief This member defines the pre-condition states for the next action. - */ - size_t pcs[ 8 ]; - - /** - * @brief If this member is true, then the test action loop is executed. - */ - bool in_action_loop; - - /** - * @brief This member contains the next transition map index. - */ - size_t index; - - /** - * @brief This member contains the current transition map entry. - */ - RtemsMessageReqConstructErrors_Entry entry; - - /** - * @brief If this member is true, then the current transition variant - * should be skipped. - */ - bool skip; - } Map; -} RtemsMessageReqConstructErrors_Context; - -static RtemsMessageReqConstructErrors_Context - RtemsMessageReqConstructErrors_Instance; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_Config[] = { - "Valid", - "Null", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_Name[] = { - "Valid", - "Invalid", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_Id[] = { - "Id", - "Null", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_MaxPending[] = { - "Valid", - "Zero", - "Big", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_MaxSize[] = { - "Valid", - "Zero", - "Big", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_Free[] = { - "Yes", - "No", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_Area[] = { - "Valid", - "Null", - "NA" -}; - -static const char * const RtemsMessageReqConstructErrors_PreDesc_AreaSize[] = { - "Valid", - "Invalid", - "NA" -}; - -static const char * const * const RtemsMessageReqConstructErrors_PreDesc[] = { - RtemsMessageReqConstructErrors_PreDesc_Config, - RtemsMessageReqConstructErrors_PreDesc_Name, - RtemsMessageReqConstructErrors_PreDesc_Id, - RtemsMessageReqConstructErrors_PreDesc_MaxPending, - RtemsMessageReqConstructErrors_PreDesc_MaxSize, - RtemsMessageReqConstructErrors_PreDesc_Free, - RtemsMessageReqConstructErrors_PreDesc_Area, - RtemsMessageReqConstructErrors_PreDesc_AreaSize, - NULL -}; - -#define NAME rtems_build_name( 'T', 'E', 'S', 'T' ) - -#define MAX_MESSAGE_QUEUES 4 - -#define MAX_PENDING_MESSAGES 1 - -#define MAX_MESSAGE_SIZE 1 - -static RTEMS_MESSAGE_QUEUE_BUFFER( MAX_MESSAGE_SIZE ) - buffers_to_seize[ MAX_MESSAGE_QUEUES ][ MAX_PENDING_MESSAGES ]; - -static RTEMS_MESSAGE_QUEUE_BUFFER( MAX_MESSAGE_SIZE ) - buffers[ MAX_PENDING_MESSAGES ]; - -static rtems_status_code Create( void *arg, uint32_t *id ) -{ - rtems_message_queue_config config; - size_t *i; - - i = arg; - T_quiet_lt_sz( *i, MAX_MESSAGE_QUEUES ); - - memset( &config, 0, sizeof( config ) ); - config.name = rtems_build_name( 'S', 'I', 'Z', 'E' ); - config.maximum_pending_messages = MAX_PENDING_MESSAGES; - config.maximum_message_size = MAX_MESSAGE_SIZE; - config.storage_size = sizeof( buffers_to_seize[ *i ] ); - config.storage_area = buffers_to_seize[ *i ]; - config.attributes = RTEMS_DEFAULT_ATTRIBUTES; - - ++(*i); - - return rtems_message_queue_construct( &config, id ); -} - -static void RtemsMessageReqConstructErrors_Pre_Config_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_Config state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_Config_Valid: { - /* - * While the ``config`` parameter references an object of type - * rtems_message_queue_config. - */ - ctx->config = &ctx->config_value; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Config_Null: { - /* - * While the ``config`` parameter is NULL. - */ - ctx->config = NULL; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Config_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_Name_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_Name state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_Name_Valid: { - /* - * While the name of the message queue configuration is valid. - */ - ctx->config_value.name = NAME; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Name_Invalid: { - /* - * While the name of the message queue configuration is invalid. - */ - ctx->config_value.name = 0; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Name_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_Id_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_Id state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_Id_Id: { - /* - * While the ``id`` parameter references an object of type rtems_id. - */ - ctx->id = &ctx->id_value; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Id_Null: { - /* - * While the ``id`` parameter is NULL. - */ - ctx->id = NULL; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Id_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_MaxPending_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_MaxPending state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_MaxPending_Valid: { - /* - * While the maximum number of pending messages of the message queue - * configuration is valid. - */ - ctx->config_value.maximum_pending_messages = MAX_PENDING_MESSAGES; - break; - } - - case RtemsMessageReqConstructErrors_Pre_MaxPending_Zero: { - /* - * While the maximum number of pending messages of the message queue - * configuration is zero. - */ - ctx->config_value.maximum_pending_messages = 0; - break; - } - - case RtemsMessageReqConstructErrors_Pre_MaxPending_Big: { - /* - * While the maximum number of pending messages of the message queue - * configuration is big enough so that a calculation to get the message - * buffer storage area size overflows. - */ - ctx->config_value.maximum_pending_messages = UINT32_MAX; - break; - } - - case RtemsMessageReqConstructErrors_Pre_MaxPending_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_MaxSize_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_MaxSize state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_MaxSize_Valid: { - /* - * While the maximum message size of the message queue configuration is - * valid. - */ - if ( ctx->config_value.maximum_pending_messages == UINT32_MAX ) { - /* - * At least on 64-bit systems we need a bit of help to ensure that we - * meet the Big state of the MaxPending pre-condition. The following - * message size is valid with respect to calculations involving only - * the message size. - */ - ctx->config_value.maximum_message_size = SIZE_MAX - sizeof( uintptr_t ) + - 1 - sizeof( CORE_message_queue_Buffer ); - } else { - ctx->config_value.maximum_message_size = MAX_MESSAGE_SIZE; - } - break; - } - - case RtemsMessageReqConstructErrors_Pre_MaxSize_Zero: { - /* - * While the maximum message size of the message queue configuration is - * zero. - */ - ctx->config_value.maximum_message_size = 0; - break; - } - - case RtemsMessageReqConstructErrors_Pre_MaxSize_Big: { - /* - * While the maximum message size of the message queue configuration is - * big enough so that a calculation to get the message buffer storage - * area size overflows. - */ - ctx->config_value.maximum_message_size = SIZE_MAX; - break; - } - - case RtemsMessageReqConstructErrors_Pre_MaxSize_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_Free_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_Free state -) -{ - size_t i; - - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_Free_Yes: { - /* - * While the system has at least one inactive message queue object - * available. - */ - /* Nothing to do */ - break; - } - - case RtemsMessageReqConstructErrors_Pre_Free_No: { - /* - * While the system has no inactive message queue object available. - */ - i = 0; - ctx->seized_objects = T_seize_objects( Create, &i ); - break; - } - - case RtemsMessageReqConstructErrors_Pre_Free_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_Area_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_Area state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_Area_Valid: { - /* - * While the message buffer storage area begin pointer of the message - * queue configuration is valid. - */ - ctx->config_value.storage_area = buffers; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Area_Null: { - /* - * While the message buffer storage area begin pointer of the message - * queue configuration is NULL. - */ - ctx->config_value.storage_area = NULL; - break; - } - - case RtemsMessageReqConstructErrors_Pre_Area_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Pre_AreaSize_Prepare( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Pre_AreaSize state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Pre_AreaSize_Valid: { - /* - * While the message buffer storage area size of the message queue - * configuration is valid. - */ - ctx->config_value.storage_size = sizeof( buffers ); - break; - } - - case RtemsMessageReqConstructErrors_Pre_AreaSize_Invalid: { - /* - * While the message buffer storage area size of the message queue - * configuration is invalid. - */ - ctx->config_value.storage_size = SIZE_MAX; - break; - } - - case RtemsMessageReqConstructErrors_Pre_AreaSize_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Post_Status_Check( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Post_Status state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Post_Status_Ok: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_SUCCESSFUL. - */ - T_rsc_success( ctx->status ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_InvAddr: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_INVALID_ADDRESS. - */ - T_rsc( ctx->status, RTEMS_INVALID_ADDRESS ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_InvName: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_INVALID_NAME. - */ - T_rsc( ctx->status, RTEMS_INVALID_NAME ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_InvNum: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_INVALID_NUMBER. - */ - T_rsc( ctx->status, RTEMS_INVALID_NUMBER ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_InvSize: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_INVALID_SIZE. - */ - T_rsc( ctx->status, RTEMS_INVALID_SIZE ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_TooMany: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_TOO_MANY. - */ - T_rsc( ctx->status, RTEMS_TOO_MANY ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_Unsat: { - /* - * The return status of rtems_message_queue_construct() shall be - * RTEMS_UNSATISFIED. - */ - T_rsc( ctx->status, RTEMS_UNSATISFIED ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Status_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Post_Name_Check( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Post_Name state -) -{ - rtems_status_code sc; - rtems_id id; - - switch ( state ) { - case RtemsMessageReqConstructErrors_Post_Name_Valid: { - /* - * The unique object name shall identify the message queue constructed by - * the rtems_message_queue_construct() call. - */ - id = 0; - sc = rtems_message_queue_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id ); - T_rsc_success( sc ); - T_eq_u32( id, ctx->id_value ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Name_Invalid: { - /* - * The unique object name shall not identify a message queue. - */ - sc = rtems_message_queue_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id ); - T_rsc( sc, RTEMS_INVALID_NAME ); - break; - } - - case RtemsMessageReqConstructErrors_Post_Name_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Post_IdVar_Check( - RtemsMessageReqConstructErrors_Context *ctx, - RtemsMessageReqConstructErrors_Post_IdVar state -) -{ - switch ( state ) { - case RtemsMessageReqConstructErrors_Post_IdVar_Set: { - /* - * The value of the object referenced by the ``id`` parameter shall be - * set to the object identifier of the constructed message queue after - * the return of the rtems_message_queue_construct() call. - */ - T_eq_ptr( ctx->id, &ctx->id_value ); - T_ne_u32( ctx->id_value, INVALID_ID ); - break; - } - - case RtemsMessageReqConstructErrors_Post_IdVar_Nop: { - /* - * Objects referenced by the ``id`` parameter in past calls to - * rtems_message_queue_construct() shall not be accessed by the - * rtems_message_queue_construct() call. - */ - T_eq_u32( ctx->id_value, INVALID_ID ); - break; - } - - case RtemsMessageReqConstructErrors_Post_IdVar_NA: - break; - } -} - -static void RtemsMessageReqConstructErrors_Prepare( - RtemsMessageReqConstructErrors_Context *ctx -) -{ - ctx->id_value = INVALID_ID; - memset( &ctx->config_value, 0, sizeof( ctx->config_value ) ); -} - -static void RtemsMessageReqConstructErrors_Action( - RtemsMessageReqConstructErrors_Context *ctx -) -{ - ctx->status = rtems_message_queue_construct( ctx->config, ctx->id ); -} - -static void RtemsMessageReqConstructErrors_Cleanup( - RtemsMessageReqConstructErrors_Context *ctx -) -{ - if ( ctx->id_value != INVALID_ID ) { - rtems_status_code sc; - - sc = rtems_message_queue_delete( ctx->id_value ); - T_rsc_success( sc ); - - ctx->id_value = INVALID_ID; - } - - T_surrender_objects( &ctx->seized_objects, rtems_message_queue_delete ); -} - -static const RtemsMessageReqConstructErrors_Entry -RtemsMessageReqConstructErrors_Entries[] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, - RtemsMessageReqConstructErrors_Post_Status_InvAddr, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_IdVar_Nop }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, - RtemsMessageReqConstructErrors_Post_Status_InvName, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_IdVar_Nop }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, - RtemsMessageReqConstructErrors_Post_Status_InvNum, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_IdVar_Nop }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, - RtemsMessageReqConstructErrors_Post_Status_InvSize, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_IdVar_Nop }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, - RtemsMessageReqConstructErrors_Post_Status_TooMany, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_IdVar_Nop }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, - RtemsMessageReqConstructErrors_Post_Status_Unsat, - RtemsMessageReqConstructErrors_Post_Name_Invalid, - RtemsMessageReqConstructErrors_Post_IdVar_Nop }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstructErrors_Post_Status_Ok, - RtemsMessageReqConstructErrors_Post_Name_Valid, - RtemsMessageReqConstructErrors_Post_IdVar_Set } -}; - -static const uint8_t -RtemsMessageReqConstructErrors_Map[] = { - 6, 5, 5, 5, 4, 4, 4, 4, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; - -static size_t RtemsMessageReqConstructErrors_Scope( - void *arg, - char *buf, - size_t n -) -{ - RtemsMessageReqConstructErrors_Context *ctx; - - ctx = arg; - - if ( ctx->Map.in_action_loop ) { - return T_get_scope( - RtemsMessageReqConstructErrors_PreDesc, - buf, - n, - ctx->Map.pcs - ); - } - - return 0; -} - -static T_fixture RtemsMessageReqConstructErrors_Fixture = { - .setup = NULL, - .stop = NULL, - .teardown = NULL, - .scope = RtemsMessageReqConstructErrors_Scope, - .initial_context = &RtemsMessageReqConstructErrors_Instance -}; - -static inline RtemsMessageReqConstructErrors_Entry -RtemsMessageReqConstructErrors_PopEntry( - RtemsMessageReqConstructErrors_Context *ctx -) -{ - size_t index; - - index = ctx->Map.index; - ctx->Map.index = index + 1; - return RtemsMessageReqConstructErrors_Entries[ - RtemsMessageReqConstructErrors_Map[ index ] - ]; -} - -static void RtemsMessageReqConstructErrors_TestVariant( - RtemsMessageReqConstructErrors_Context *ctx -) -{ - RtemsMessageReqConstructErrors_Pre_Config_Prepare( ctx, ctx->Map.pcs[ 0 ] ); - RtemsMessageReqConstructErrors_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 1 ] ); - RtemsMessageReqConstructErrors_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 2 ] ); - RtemsMessageReqConstructErrors_Pre_MaxPending_Prepare( - ctx, - ctx->Map.pcs[ 3 ] - ); - RtemsMessageReqConstructErrors_Pre_MaxSize_Prepare( ctx, ctx->Map.pcs[ 4 ] ); - RtemsMessageReqConstructErrors_Pre_Free_Prepare( ctx, ctx->Map.pcs[ 5 ] ); - RtemsMessageReqConstructErrors_Pre_Area_Prepare( ctx, ctx->Map.pcs[ 6 ] ); - RtemsMessageReqConstructErrors_Pre_AreaSize_Prepare( - ctx, - ctx->Map.pcs[ 7 ] - ); - RtemsMessageReqConstructErrors_Action( ctx ); - RtemsMessageReqConstructErrors_Post_Status_Check( - ctx, - ctx->Map.entry.Post_Status - ); - RtemsMessageReqConstructErrors_Post_Name_Check( - ctx, - ctx->Map.entry.Post_Name - ); - RtemsMessageReqConstructErrors_Post_IdVar_Check( - ctx, - ctx->Map.entry.Post_IdVar - ); -} - -/** - * @fn void T_case_body_RtemsMessageReqConstructErrors( void ) - */ -T_TEST_CASE_FIXTURE( - RtemsMessageReqConstructErrors, - &RtemsMessageReqConstructErrors_Fixture -) -{ - RtemsMessageReqConstructErrors_Context *ctx; - - ctx = T_fixture_context(); - ctx->Map.in_action_loop = true; - ctx->Map.index = 0; - - for ( - ctx->Map.pcs[ 0 ] = RtemsMessageReqConstructErrors_Pre_Config_Valid; - ctx->Map.pcs[ 0 ] < RtemsMessageReqConstructErrors_Pre_Config_NA; - ++ctx->Map.pcs[ 0 ] - ) { - for ( - ctx->Map.pcs[ 1 ] = RtemsMessageReqConstructErrors_Pre_Name_Valid; - ctx->Map.pcs[ 1 ] < RtemsMessageReqConstructErrors_Pre_Name_NA; - ++ctx->Map.pcs[ 1 ] - ) { - for ( - ctx->Map.pcs[ 2 ] = RtemsMessageReqConstructErrors_Pre_Id_Id; - ctx->Map.pcs[ 2 ] < RtemsMessageReqConstructErrors_Pre_Id_NA; - ++ctx->Map.pcs[ 2 ] - ) { - for ( - ctx->Map.pcs[ 3 ] = RtemsMessageReqConstructErrors_Pre_MaxPending_Valid; - ctx->Map.pcs[ 3 ] < RtemsMessageReqConstructErrors_Pre_MaxPending_NA; - ++ctx->Map.pcs[ 3 ] - ) { - for ( - ctx->Map.pcs[ 4 ] = RtemsMessageReqConstructErrors_Pre_MaxSize_Valid; - ctx->Map.pcs[ 4 ] < RtemsMessageReqConstructErrors_Pre_MaxSize_NA; - ++ctx->Map.pcs[ 4 ] - ) { - for ( - ctx->Map.pcs[ 5 ] = RtemsMessageReqConstructErrors_Pre_Free_Yes; - ctx->Map.pcs[ 5 ] < RtemsMessageReqConstructErrors_Pre_Free_NA; - ++ctx->Map.pcs[ 5 ] - ) { - for ( - ctx->Map.pcs[ 6 ] = RtemsMessageReqConstructErrors_Pre_Area_Valid; - ctx->Map.pcs[ 6 ] < RtemsMessageReqConstructErrors_Pre_Area_NA; - ++ctx->Map.pcs[ 6 ] - ) { - for ( - ctx->Map.pcs[ 7 ] = RtemsMessageReqConstructErrors_Pre_AreaSize_Valid; - ctx->Map.pcs[ 7 ] < RtemsMessageReqConstructErrors_Pre_AreaSize_NA; - ++ctx->Map.pcs[ 7 ] - ) { - ctx->Map.entry = RtemsMessageReqConstructErrors_PopEntry( - ctx - ); - RtemsMessageReqConstructErrors_Prepare( ctx ); - RtemsMessageReqConstructErrors_TestVariant( ctx ); - RtemsMessageReqConstructErrors_Cleanup( ctx ); - } - } - } - } - } - } - } - } -} - -/** @} */ diff --git a/testsuites/validation/tc-message-construct.c b/testsuites/validation/tc-message-construct.c new file mode 100644 index 0000000000..ec281f5424 --- /dev/null +++ b/testsuites/validation/tc-message-construct.c @@ -0,0 +1,1059 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseRtemsMessageReqConstruct + */ + +/* + * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems.h> +#include <string.h> + +#include "tx-support.h" + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseRtemsMessageReqConstruct \ + * spec:/rtems/message/req/construct + * + * @ingroup RTEMSTestSuiteTestsuitesValidation0 + * + * @{ + */ + +typedef enum { + RtemsMessageReqConstruct_Pre_Config_Valid, + RtemsMessageReqConstruct_Pre_Config_Null, + RtemsMessageReqConstruct_Pre_Config_NA +} RtemsMessageReqConstruct_Pre_Config; + +typedef enum { + RtemsMessageReqConstruct_Pre_Name_Valid, + RtemsMessageReqConstruct_Pre_Name_Invalid, + RtemsMessageReqConstruct_Pre_Name_NA +} RtemsMessageReqConstruct_Pre_Name; + +typedef enum { + RtemsMessageReqConstruct_Pre_Id_Id, + RtemsMessageReqConstruct_Pre_Id_Null, + RtemsMessageReqConstruct_Pre_Id_NA +} RtemsMessageReqConstruct_Pre_Id; + +typedef enum { + RtemsMessageReqConstruct_Pre_MaxPending_Valid, + RtemsMessageReqConstruct_Pre_MaxPending_Zero, + RtemsMessageReqConstruct_Pre_MaxPending_Big, + RtemsMessageReqConstruct_Pre_MaxPending_NA +} RtemsMessageReqConstruct_Pre_MaxPending; + +typedef enum { + RtemsMessageReqConstruct_Pre_MaxSize_Valid, + RtemsMessageReqConstruct_Pre_MaxSize_Zero, + RtemsMessageReqConstruct_Pre_MaxSize_Big, + RtemsMessageReqConstruct_Pre_MaxSize_NA +} RtemsMessageReqConstruct_Pre_MaxSize; + +typedef enum { + RtemsMessageReqConstruct_Pre_Free_Yes, + RtemsMessageReqConstruct_Pre_Free_No, + RtemsMessageReqConstruct_Pre_Free_NA +} RtemsMessageReqConstruct_Pre_Free; + +typedef enum { + RtemsMessageReqConstruct_Pre_Area_Valid, + RtemsMessageReqConstruct_Pre_Area_Null, + RtemsMessageReqConstruct_Pre_Area_NA +} RtemsMessageReqConstruct_Pre_Area; + +typedef enum { + RtemsMessageReqConstruct_Pre_AreaSize_Valid, + RtemsMessageReqConstruct_Pre_AreaSize_Invalid, + RtemsMessageReqConstruct_Pre_AreaSize_NA +} RtemsMessageReqConstruct_Pre_AreaSize; + +typedef enum { + RtemsMessageReqConstruct_Pre_StorageFree_Null, + RtemsMessageReqConstruct_Pre_StorageFree_Handler, + RtemsMessageReqConstruct_Pre_StorageFree_NA +} RtemsMessageReqConstruct_Pre_StorageFree; + +typedef enum { + RtemsMessageReqConstruct_Post_Status_Ok, + RtemsMessageReqConstruct_Post_Status_InvAddr, + RtemsMessageReqConstruct_Post_Status_InvName, + RtemsMessageReqConstruct_Post_Status_InvNum, + RtemsMessageReqConstruct_Post_Status_InvSize, + RtemsMessageReqConstruct_Post_Status_TooMany, + RtemsMessageReqConstruct_Post_Status_Unsat, + RtemsMessageReqConstruct_Post_Status_NA +} RtemsMessageReqConstruct_Post_Status; + +typedef enum { + RtemsMessageReqConstruct_Post_Name_Valid, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_Name_NA +} RtemsMessageReqConstruct_Post_Name; + +typedef enum { + RtemsMessageReqConstruct_Post_IdObj_Set, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_IdObj_NA +} RtemsMessageReqConstruct_Post_IdObj; + +typedef enum { + RtemsMessageReqConstruct_Post_StorageFree_Free, + RtemsMessageReqConstruct_Post_StorageFree_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA +} RtemsMessageReqConstruct_Post_StorageFree; + +typedef struct { + uint32_t Skip : 1; + uint32_t Pre_Config_NA : 1; + uint32_t Pre_Name_NA : 1; + uint32_t Pre_Id_NA : 1; + uint32_t Pre_MaxPending_NA : 1; + uint32_t Pre_MaxSize_NA : 1; + uint32_t Pre_Free_NA : 1; + uint32_t Pre_Area_NA : 1; + uint32_t Pre_AreaSize_NA : 1; + uint32_t Pre_StorageFree_NA : 1; + uint32_t Post_Status : 3; + uint32_t Post_Name : 2; + uint32_t Post_IdObj : 2; + uint32_t Post_StorageFree : 2; +} RtemsMessageReqConstruct_Entry; + +/** + * @brief Test context for spec:/rtems/message/req/construct test case. + */ +typedef struct { + rtems_status_code status; + + const rtems_message_queue_config *config; + + rtems_message_queue_config config_obj; + + rtems_id *id; + + rtems_id id_obj; + + void *seized_objects; + + uint32_t storage_free_counter; + + uint32_t expected_storage_free_counter; + + struct { + /** + * @brief This member defines the pre-condition states for the next action. + */ + size_t pcs[ 9 ]; + + /** + * @brief If this member is true, then the test action loop is executed. + */ + bool in_action_loop; + + /** + * @brief This member contains the next transition map index. + */ + size_t index; + + /** + * @brief This member contains the current transition map entry. + */ + RtemsMessageReqConstruct_Entry entry; + + /** + * @brief If this member is true, then the current transition variant + * should be skipped. + */ + bool skip; + } Map; +} RtemsMessageReqConstruct_Context; + +static RtemsMessageReqConstruct_Context + RtemsMessageReqConstruct_Instance; + +static const char * const RtemsMessageReqConstruct_PreDesc_Config[] = { + "Valid", + "Null", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_Name[] = { + "Valid", + "Invalid", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_Id[] = { + "Id", + "Null", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_MaxPending[] = { + "Valid", + "Zero", + "Big", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_MaxSize[] = { + "Valid", + "Zero", + "Big", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_Free[] = { + "Yes", + "No", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_Area[] = { + "Valid", + "Null", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_AreaSize[] = { + "Valid", + "Invalid", + "NA" +}; + +static const char * const RtemsMessageReqConstruct_PreDesc_StorageFree[] = { + "Null", + "Handler", + "NA" +}; + +static const char * const * const RtemsMessageReqConstruct_PreDesc[] = { + RtemsMessageReqConstruct_PreDesc_Config, + RtemsMessageReqConstruct_PreDesc_Name, + RtemsMessageReqConstruct_PreDesc_Id, + RtemsMessageReqConstruct_PreDesc_MaxPending, + RtemsMessageReqConstruct_PreDesc_MaxSize, + RtemsMessageReqConstruct_PreDesc_Free, + RtemsMessageReqConstruct_PreDesc_Area, + RtemsMessageReqConstruct_PreDesc_AreaSize, + RtemsMessageReqConstruct_PreDesc_StorageFree, + NULL +}; + +#define NAME rtems_build_name( 'T', 'E', 'S', 'T' ) + +#define MAX_MESSAGE_QUEUES 4 + +#define MAX_PENDING_MESSAGES 1 + +#define MAX_MESSAGE_SIZE 1 + +typedef RtemsMessageReqConstruct_Context Context; + +static RTEMS_MESSAGE_QUEUE_BUFFER( MAX_MESSAGE_SIZE ) + buffers_to_seize[ MAX_MESSAGE_QUEUES ][ MAX_PENDING_MESSAGES ]; + +static RTEMS_MESSAGE_QUEUE_BUFFER( MAX_MESSAGE_SIZE ) + buffers[ MAX_PENDING_MESSAGES ]; + +static rtems_status_code Create( void *arg, uint32_t *id ) +{ + rtems_message_queue_config config; + size_t *i; + + i = arg; + T_quiet_lt_sz( *i, MAX_MESSAGE_QUEUES ); + + memset( &config, 0, sizeof( config ) ); + config.name = rtems_build_name( 'S', 'I', 'Z', 'E' ); + config.maximum_pending_messages = MAX_PENDING_MESSAGES; + config.maximum_message_size = MAX_MESSAGE_SIZE; + config.storage_size = sizeof( buffers_to_seize[ *i ] ); + config.storage_area = buffers_to_seize[ *i ]; + config.attributes = RTEMS_DEFAULT_ATTRIBUTES; + + ++(*i); + + return rtems_message_queue_construct( &config, id ); +} + +static void StorageFree( void *ptr ) +{ + Context *ctx; + + ctx = T_fixture_context(); + T_eq_ptr( ptr, buffers ); + ++ctx->storage_free_counter; +} + +static void RtemsMessageReqConstruct_Pre_Config_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_Config state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_Config_Valid: { + /* + * While the ``config`` parameter references an object of type + * rtems_message_queue_config. + */ + ctx->config = &ctx->config_obj; + break; + } + + case RtemsMessageReqConstruct_Pre_Config_Null: { + /* + * While the ``config`` parameter is NULL. + */ + ctx->config = NULL; + break; + } + + case RtemsMessageReqConstruct_Pre_Config_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_Name_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_Name state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_Name_Valid: { + /* + * While the name of the message queue configuration is valid. + */ + ctx->config_obj.name = NAME; + break; + } + + case RtemsMessageReqConstruct_Pre_Name_Invalid: { + /* + * While the name of the message queue configuration is invalid. + */ + ctx->config_obj.name = 0; + break; + } + + case RtemsMessageReqConstruct_Pre_Name_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_Id_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_Id state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_Id_Id: { + /* + * While the ``id`` parameter references an object of type rtems_id. + */ + ctx->id = &ctx->id_obj; + break; + } + + case RtemsMessageReqConstruct_Pre_Id_Null: { + /* + * While the ``id`` parameter is NULL. + */ + ctx->id = NULL; + break; + } + + case RtemsMessageReqConstruct_Pre_Id_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_MaxPending_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_MaxPending state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_MaxPending_Valid: { + /* + * While the maximum number of pending messages of the message queue + * configuration is valid. + */ + ctx->config_obj.maximum_pending_messages = MAX_PENDING_MESSAGES; + break; + } + + case RtemsMessageReqConstruct_Pre_MaxPending_Zero: { + /* + * While the maximum number of pending messages of the message queue + * configuration is zero. + */ + ctx->config_obj.maximum_pending_messages = 0; + break; + } + + case RtemsMessageReqConstruct_Pre_MaxPending_Big: { + /* + * While the maximum number of pending messages of the message queue + * configuration is big enough so that a calculation to get the message + * buffer storage area size overflows. + */ + ctx->config_obj.maximum_pending_messages = UINT32_MAX; + break; + } + + case RtemsMessageReqConstruct_Pre_MaxPending_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_MaxSize_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_MaxSize state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_MaxSize_Valid: { + /* + * While the maximum message size of the message queue configuration is + * valid. + */ + if ( ctx->config_obj.maximum_pending_messages == UINT32_MAX ) { + /* + * At least on 64-bit systems we need a bit of help to ensure that we + * meet the Big state of the MaxPending pre-condition. The following + * message size is valid with respect to calculations involving only + * the message size. + */ + ctx->config_obj.maximum_message_size = SIZE_MAX - sizeof( uintptr_t ) + + 1 - sizeof( CORE_message_queue_Buffer ); + } else { + ctx->config_obj.maximum_message_size = MAX_MESSAGE_SIZE; + } + break; + } + + case RtemsMessageReqConstruct_Pre_MaxSize_Zero: { + /* + * While the maximum message size of the message queue configuration is + * zero. + */ + ctx->config_obj.maximum_message_size = 0; + break; + } + + case RtemsMessageReqConstruct_Pre_MaxSize_Big: { + /* + * While the maximum message size of the message queue configuration is + * big enough so that a calculation to get the message buffer storage + * area size overflows. + */ + ctx->config_obj.maximum_message_size = SIZE_MAX; + break; + } + + case RtemsMessageReqConstruct_Pre_MaxSize_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_Free_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_Free state +) +{ + size_t i; + + switch ( state ) { + case RtemsMessageReqConstruct_Pre_Free_Yes: { + /* + * While the system has at least one inactive message queue object + * available. + */ + /* Nothing to do */ + break; + } + + case RtemsMessageReqConstruct_Pre_Free_No: { + /* + * While the system has no inactive message queue object available. + */ + i = 0; + ctx->seized_objects = T_seize_objects( Create, &i ); + break; + } + + case RtemsMessageReqConstruct_Pre_Free_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_Area_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_Area state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_Area_Valid: { + /* + * While the message buffer storage area begin pointer of the message + * queue configuration is valid. + */ + ctx->config_obj.storage_area = buffers; + break; + } + + case RtemsMessageReqConstruct_Pre_Area_Null: { + /* + * While the message buffer storage area begin pointer of the message + * queue configuration is NULL. + */ + ctx->config_obj.storage_area = NULL; + break; + } + + case RtemsMessageReqConstruct_Pre_Area_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_AreaSize_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_AreaSize state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_AreaSize_Valid: { + /* + * While the message buffer storage area size of the message queue + * configuration is valid. + */ + ctx->config_obj.storage_size = sizeof( buffers ); + break; + } + + case RtemsMessageReqConstruct_Pre_AreaSize_Invalid: { + /* + * While the message buffer storage area size of the message queue + * configuration is invalid. + */ + ctx->config_obj.storage_size = SIZE_MAX; + break; + } + + case RtemsMessageReqConstruct_Pre_AreaSize_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Pre_StorageFree_Prepare( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Pre_StorageFree state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Pre_StorageFree_Null: { + /* + * While the storage free member of the message queue configuration is + * equal to NULL. + */ + ctx->config_obj.storage_free = NULL; + break; + } + + case RtemsMessageReqConstruct_Pre_StorageFree_Handler: { + /* + * While the storage free member of the message queue configuration + * references a storage free handler. + */ + ctx->config_obj.storage_free = StorageFree; + break; + } + + case RtemsMessageReqConstruct_Pre_StorageFree_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Post_Status_Check( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Post_Status state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Post_Status_Ok: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_SUCCESSFUL. + */ + T_rsc_success( ctx->status ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_InvAddr: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_INVALID_ADDRESS. + */ + T_rsc( ctx->status, RTEMS_INVALID_ADDRESS ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_InvName: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_INVALID_NAME. + */ + T_rsc( ctx->status, RTEMS_INVALID_NAME ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_InvNum: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_INVALID_NUMBER. + */ + T_rsc( ctx->status, RTEMS_INVALID_NUMBER ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_InvSize: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_INVALID_SIZE. + */ + T_rsc( ctx->status, RTEMS_INVALID_SIZE ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_TooMany: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_TOO_MANY. + */ + T_rsc( ctx->status, RTEMS_TOO_MANY ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_Unsat: { + /* + * The return status of rtems_message_queue_construct() shall be + * RTEMS_UNSATISFIED. + */ + T_rsc( ctx->status, RTEMS_UNSATISFIED ); + break; + } + + case RtemsMessageReqConstruct_Post_Status_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Post_Name_Check( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Post_Name state +) +{ + rtems_status_code sc; + rtems_id id; + + switch ( state ) { + case RtemsMessageReqConstruct_Post_Name_Valid: { + /* + * The unique object name shall identify the message queue constructed by + * the rtems_message_queue_construct() call. + */ + id = 0; + sc = rtems_message_queue_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id ); + T_rsc_success( sc ); + T_eq_u32( id, ctx->id_obj ); + break; + } + + case RtemsMessageReqConstruct_Post_Name_Invalid: { + /* + * The unique object name shall not identify a message queue. + */ + sc = rtems_message_queue_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id ); + T_rsc( sc, RTEMS_INVALID_NAME ); + break; + } + + case RtemsMessageReqConstruct_Post_Name_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Post_IdObj_Check( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Post_IdObj state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Post_IdObj_Set: { + /* + * The value of the object referenced by the ``id`` parameter shall be + * set to the object identifier of the constructed message queue after + * the return of the rtems_message_queue_construct() call. + */ + T_eq_ptr( ctx->id, &ctx->id_obj ); + T_ne_u32( ctx->id_obj, INVALID_ID ); + break; + } + + case RtemsMessageReqConstruct_Post_IdObj_Nop: { + /* + * Objects referenced by the ``id`` parameter in past calls to + * rtems_message_queue_construct() shall not be accessed by the + * rtems_message_queue_construct() call. + */ + T_eq_u32( ctx->id_obj, INVALID_ID ); + break; + } + + case RtemsMessageReqConstruct_Post_IdObj_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Post_StorageFree_Check( + RtemsMessageReqConstruct_Context *ctx, + RtemsMessageReqConstruct_Post_StorageFree state +) +{ + switch ( state ) { + case RtemsMessageReqConstruct_Post_StorageFree_Free: { + /* + * The storage free handler of the message queue configuration specified + * by the ``config`` parameter shall be used to free the message queue + * storage area. + */ + ctx->expected_storage_free_counter = 1; + break; + } + + case RtemsMessageReqConstruct_Post_StorageFree_Nop: { + /* + * No operation shall be performed to free the message queue storage + * area. + */ + ctx->expected_storage_free_counter = 0; + break; + } + + case RtemsMessageReqConstruct_Post_StorageFree_NA: + break; + } +} + +static void RtemsMessageReqConstruct_Prepare( + RtemsMessageReqConstruct_Context *ctx +) +{ + ctx->id_obj = INVALID_ID; + ctx->storage_free_counter = 0; + ctx->expected_storage_free_counter = UINT32_MAX; + memset( &ctx->config_obj, 0, sizeof( ctx->config_obj ) ); +} + +static void RtemsMessageReqConstruct_Action( + RtemsMessageReqConstruct_Context *ctx +) +{ + ctx->status = rtems_message_queue_construct( ctx->config, ctx->id ); +} + +static void RtemsMessageReqConstruct_Cleanup( + RtemsMessageReqConstruct_Context *ctx +) +{ + if ( ctx->id_obj != INVALID_ID ) { + rtems_status_code sc; + + sc = rtems_message_queue_delete( ctx->id_obj ); + T_rsc_success( sc ); + + T_eq_u32( ctx->storage_free_counter, ctx->expected_storage_free_counter ); + } else { + T_eq_u32( ctx->storage_free_counter, 0 ); + } + + T_surrender_objects( &ctx->seized_objects, rtems_message_queue_delete ); +} + +static const RtemsMessageReqConstruct_Entry +RtemsMessageReqConstruct_Entries[] = { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_InvAddr, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_InvName, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_InvNum, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_InvSize, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_TooMany, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_Unsat, + RtemsMessageReqConstruct_Post_Name_Invalid, + RtemsMessageReqConstruct_Post_IdObj_Nop, + RtemsMessageReqConstruct_Post_StorageFree_NA }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_Ok, + RtemsMessageReqConstruct_Post_Name_Valid, + RtemsMessageReqConstruct_Post_IdObj_Set, + RtemsMessageReqConstruct_Post_StorageFree_Nop }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RtemsMessageReqConstruct_Post_Status_Ok, + RtemsMessageReqConstruct_Post_Name_Valid, + RtemsMessageReqConstruct_Post_IdObj_Set, + RtemsMessageReqConstruct_Post_StorageFree_Free } +}; + +static const uint8_t +RtemsMessageReqConstruct_Map[] = { + 6, 7, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 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ct_Context *ctx; + + ctx = arg; + + if ( ctx->Map.in_action_loop ) { + return T_get_scope( + RtemsMessageReqConstruct_PreDesc, + buf, + n, + ctx->Map.pcs + ); + } + + return 0; +} + +static T_fixture RtemsMessageReqConstruct_Fixture = { + .setup = NULL, + .stop = NULL, + .teardown = NULL, + .scope = RtemsMessageReqConstruct_Scope, + .initial_context = &RtemsMessageReqConstruct_Instance +}; + +static inline RtemsMessageReqConstruct_Entry RtemsMessageReqConstruct_PopEntry( + RtemsMessageReqConstruct_Context *ctx +) +{ + size_t index; + + index = ctx->Map.index; + ctx->Map.index = index + 1; + return RtemsMessageReqConstruct_Entries[ + RtemsMessageReqConstruct_Map[ index ] + ]; +} + +static void RtemsMessageReqConstruct_TestVariant( + RtemsMessageReqConstruct_Context *ctx +) +{ + RtemsMessageReqConstruct_Pre_Config_Prepare( ctx, ctx->Map.pcs[ 0 ] ); + RtemsMessageReqConstruct_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 1 ] ); + RtemsMessageReqConstruct_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 2 ] ); + RtemsMessageReqConstruct_Pre_MaxPending_Prepare( ctx, ctx->Map.pcs[ 3 ] ); + RtemsMessageReqConstruct_Pre_MaxSize_Prepare( ctx, ctx->Map.pcs[ 4 ] ); + RtemsMessageReqConstruct_Pre_Free_Prepare( ctx, ctx->Map.pcs[ 5 ] ); + RtemsMessageReqConstruct_Pre_Area_Prepare( ctx, ctx->Map.pcs[ 6 ] ); + RtemsMessageReqConstruct_Pre_AreaSize_Prepare( ctx, ctx->Map.pcs[ 7 ] ); + RtemsMessageReqConstruct_Pre_StorageFree_Prepare( ctx, ctx->Map.pcs[ 8 ] ); + RtemsMessageReqConstruct_Action( ctx ); + RtemsMessageReqConstruct_Post_Status_Check( + ctx, + ctx->Map.entry.Post_Status + ); + RtemsMessageReqConstruct_Post_Name_Check( ctx, ctx->Map.entry.Post_Name ); + RtemsMessageReqConstruct_Post_IdObj_Check( ctx, ctx->Map.entry.Post_IdObj ); + RtemsMessageReqConstruct_Post_StorageFree_Check( + ctx, + ctx->Map.entry.Post_StorageFree + ); +} + +/** + * @fn void T_case_body_RtemsMessageReqConstruct( void ) + */ +T_TEST_CASE_FIXTURE( + RtemsMessageReqConstruct, + &RtemsMessageReqConstruct_Fixture +) +{ + RtemsMessageReqConstruct_Context *ctx; + + ctx = T_fixture_context(); + ctx->Map.in_action_loop = true; + ctx->Map.index = 0; + + for ( + ctx->Map.pcs[ 0 ] = RtemsMessageReqConstruct_Pre_Config_Valid; + ctx->Map.pcs[ 0 ] < RtemsMessageReqConstruct_Pre_Config_NA; + ++ctx->Map.pcs[ 0 ] + ) { + for ( + ctx->Map.pcs[ 1 ] = RtemsMessageReqConstruct_Pre_Name_Valid; + ctx->Map.pcs[ 1 ] < RtemsMessageReqConstruct_Pre_Name_NA; + ++ctx->Map.pcs[ 1 ] + ) { + for ( + ctx->Map.pcs[ 2 ] = RtemsMessageReqConstruct_Pre_Id_Id; + ctx->Map.pcs[ 2 ] < RtemsMessageReqConstruct_Pre_Id_NA; + ++ctx->Map.pcs[ 2 ] + ) { + for ( + ctx->Map.pcs[ 3 ] = RtemsMessageReqConstruct_Pre_MaxPending_Valid; + ctx->Map.pcs[ 3 ] < RtemsMessageReqConstruct_Pre_MaxPending_NA; + ++ctx->Map.pcs[ 3 ] + ) { + for ( + ctx->Map.pcs[ 4 ] = RtemsMessageReqConstruct_Pre_MaxSize_Valid; + ctx->Map.pcs[ 4 ] < RtemsMessageReqConstruct_Pre_MaxSize_NA; + ++ctx->Map.pcs[ 4 ] + ) { + for ( + ctx->Map.pcs[ 5 ] = RtemsMessageReqConstruct_Pre_Free_Yes; + ctx->Map.pcs[ 5 ] < RtemsMessageReqConstruct_Pre_Free_NA; + ++ctx->Map.pcs[ 5 ] + ) { + for ( + ctx->Map.pcs[ 6 ] = RtemsMessageReqConstruct_Pre_Area_Valid; + ctx->Map.pcs[ 6 ] < RtemsMessageReqConstruct_Pre_Area_NA; + ++ctx->Map.pcs[ 6 ] + ) { + for ( + ctx->Map.pcs[ 7 ] = RtemsMessageReqConstruct_Pre_AreaSize_Valid; + ctx->Map.pcs[ 7 ] < RtemsMessageReqConstruct_Pre_AreaSize_NA; + ++ctx->Map.pcs[ 7 ] + ) { + for ( + ctx->Map.pcs[ 8 ] = RtemsMessageReqConstruct_Pre_StorageFree_Null; + ctx->Map.pcs[ 8 ] < RtemsMessageReqConstruct_Pre_StorageFree_NA; + ++ctx->Map.pcs[ 8 ] + ) { + ctx->Map.entry = RtemsMessageReqConstruct_PopEntry( ctx ); + RtemsMessageReqConstruct_Prepare( ctx ); + RtemsMessageReqConstruct_TestVariant( ctx ); + RtemsMessageReqConstruct_Cleanup( ctx ); + } + } + } + } + } + } + } + } + } +} + +/** @} */ |