Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RtemsStatusReqIsEqual
0007  */
0008 
0009 /*
0010  * Copyright (C) 2021 embedded brains GmbH & Co. KG
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 /*
0035  * This file is part of the RTEMS quality process and was automatically
0036  * generated.  If you find something that needs to be fixed or
0037  * worded better please post a report or patch to an RTEMS mailing list
0038  * or raise a bug report:
0039  *
0040  * https://www.rtems.org/bugs.html
0041  *
0042  * For information on updating and regenerating please refer to the How-To
0043  * section in the Software Requirements Engineering chapter of the
0044  * RTEMS Software Engineering manual.  The manual is provided as a part of
0045  * a release.  For development sources please refer to the online
0046  * documentation at:
0047  *
0048  * https://docs.rtems.org
0049  */
0050 
0051 #ifdef HAVE_CONFIG_H
0052 #include "config.h"
0053 #endif
0054 
0055 #include <rtems.h>
0056 
0057 #include <rtems/test.h>
0058 
0059 /**
0060  * @defgroup RtemsStatusReqIsEqual spec:/rtems/status/req/is-equal
0061  *
0062  * @ingroup TestsuitesValidationNoClock0
0063  *
0064  * @{
0065  */
0066 
0067 typedef enum {
0068   RtemsStatusReqIsEqual_Pre_Status_Equal,
0069   RtemsStatusReqIsEqual_Pre_Status_NotEqual,
0070   RtemsStatusReqIsEqual_Pre_Status_NA
0071 } RtemsStatusReqIsEqual_Pre_Status;
0072 
0073 typedef enum {
0074   RtemsStatusReqIsEqual_Post_Result_True,
0075   RtemsStatusReqIsEqual_Post_Result_False,
0076   RtemsStatusReqIsEqual_Post_Result_NA
0077 } RtemsStatusReqIsEqual_Post_Result;
0078 
0079 typedef struct {
0080   uint8_t Skip : 1;
0081   uint8_t Pre_Status_NA : 1;
0082   uint8_t Post_Result : 2;
0083 } RtemsStatusReqIsEqual_Entry;
0084 
0085 /**
0086  * @brief Test context for spec:/rtems/status/req/is-equal test case.
0087  */
0088 typedef struct {
0089   /**
0090    * @brief This member contains the return value of the
0091    *   rtems_are_statuses_equal() call.
0092    */
0093   bool result;
0094 
0095   /**
0096    * @brief This member specifies if the ``left_status_code`` parameter value.
0097    */
0098   rtems_status_code status_0;
0099 
0100   /**
0101    * @brief This member specifies if the ``right_status_code`` parameter value.
0102    */
0103   rtems_status_code status_1;
0104 
0105   struct {
0106     /**
0107      * @brief This member defines the pre-condition states for the next action.
0108      */
0109     size_t pcs[ 1 ];
0110 
0111     /**
0112      * @brief If this member is true, then the test action loop is executed.
0113      */
0114     bool in_action_loop;
0115 
0116     /**
0117      * @brief This member contains the next transition map index.
0118      */
0119     size_t index;
0120 
0121     /**
0122      * @brief This member contains the current transition map entry.
0123      */
0124     RtemsStatusReqIsEqual_Entry entry;
0125 
0126     /**
0127      * @brief If this member is true, then the current transition variant
0128      *   should be skipped.
0129      */
0130     bool skip;
0131   } Map;
0132 } RtemsStatusReqIsEqual_Context;
0133 
0134 static RtemsStatusReqIsEqual_Context
0135   RtemsStatusReqIsEqual_Instance;
0136 
0137 static const char * const RtemsStatusReqIsEqual_PreDesc_Status[] = {
0138   "Equal",
0139   "NotEqual",
0140   "NA"
0141 };
0142 
0143 static const char * const * const RtemsStatusReqIsEqual_PreDesc[] = {
0144   RtemsStatusReqIsEqual_PreDesc_Status,
0145   NULL
0146 };
0147 
0148 static void RtemsStatusReqIsEqual_Pre_Status_Prepare(
0149   RtemsStatusReqIsEqual_Context   *ctx,
0150   RtemsStatusReqIsEqual_Pre_Status state
0151 )
0152 {
0153   switch ( state ) {
0154     case RtemsStatusReqIsEqual_Pre_Status_Equal: {
0155       /*
0156        * While the ``left_status_code`` parameter is equal to the
0157        * ``right_status_code`` parameter.
0158        */
0159       ctx->status_0 = RTEMS_INVALID_NAME;
0160       ctx->status_1 = RTEMS_INVALID_NAME;
0161       break;
0162     }
0163 
0164     case RtemsStatusReqIsEqual_Pre_Status_NotEqual: {
0165       /*
0166        * While the ``left_status_code`` parameter is not equal to the
0167        * ``right_status_code`` parameter.
0168        */
0169       ctx->status_0 = RTEMS_SUCCESSFUL;
0170       ctx->status_1 = RTEMS_INVALID_ID;
0171       break;
0172     }
0173 
0174     case RtemsStatusReqIsEqual_Pre_Status_NA:
0175       break;
0176   }
0177 }
0178 
0179 static void RtemsStatusReqIsEqual_Post_Result_Check(
0180   RtemsStatusReqIsEqual_Context    *ctx,
0181   RtemsStatusReqIsEqual_Post_Result state
0182 )
0183 {
0184   switch ( state ) {
0185     case RtemsStatusReqIsEqual_Post_Result_True: {
0186       /*
0187        * The return value of rtems_are_statuses_equal() shall be true.
0188        */
0189       T_true( ctx->result );
0190       break;
0191     }
0192 
0193     case RtemsStatusReqIsEqual_Post_Result_False: {
0194       /*
0195        * The return value of rtems_are_statuses_equal() shall be false.
0196        */
0197       T_false( ctx->result );
0198       break;
0199     }
0200 
0201     case RtemsStatusReqIsEqual_Post_Result_NA:
0202       break;
0203   }
0204 }
0205 
0206 static void RtemsStatusReqIsEqual_Action( RtemsStatusReqIsEqual_Context *ctx )
0207 {
0208   ctx->result = rtems_are_statuses_equal( ctx->status_0, ctx->status_1 );
0209 }
0210 
0211 static const RtemsStatusReqIsEqual_Entry
0212 RtemsStatusReqIsEqual_Entries[] = {
0213   { 0, 0, RtemsStatusReqIsEqual_Post_Result_True },
0214   { 0, 0, RtemsStatusReqIsEqual_Post_Result_False }
0215 };
0216 
0217 static const uint8_t
0218 RtemsStatusReqIsEqual_Map[] = {
0219   0, 1
0220 };
0221 
0222 static size_t RtemsStatusReqIsEqual_Scope( void *arg, char *buf, size_t n )
0223 {
0224   RtemsStatusReqIsEqual_Context *ctx;
0225 
0226   ctx = arg;
0227 
0228   if ( ctx->Map.in_action_loop ) {
0229     return T_get_scope( RtemsStatusReqIsEqual_PreDesc, buf, n, ctx->Map.pcs );
0230   }
0231 
0232   return 0;
0233 }
0234 
0235 static T_fixture RtemsStatusReqIsEqual_Fixture = {
0236   .setup = NULL,
0237   .stop = NULL,
0238   .teardown = NULL,
0239   .scope = RtemsStatusReqIsEqual_Scope,
0240   .initial_context = &RtemsStatusReqIsEqual_Instance
0241 };
0242 
0243 static inline RtemsStatusReqIsEqual_Entry RtemsStatusReqIsEqual_PopEntry(
0244   RtemsStatusReqIsEqual_Context *ctx
0245 )
0246 {
0247   size_t index;
0248 
0249   index = ctx->Map.index;
0250   ctx->Map.index = index + 1;
0251   return RtemsStatusReqIsEqual_Entries[
0252     RtemsStatusReqIsEqual_Map[ index ]
0253   ];
0254 }
0255 
0256 static void RtemsStatusReqIsEqual_TestVariant(
0257   RtemsStatusReqIsEqual_Context *ctx
0258 )
0259 {
0260   RtemsStatusReqIsEqual_Pre_Status_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0261   RtemsStatusReqIsEqual_Action( ctx );
0262   RtemsStatusReqIsEqual_Post_Result_Check( ctx, ctx->Map.entry.Post_Result );
0263 }
0264 
0265 /**
0266  * @fn void T_case_body_RtemsStatusReqIsEqual( void )
0267  */
0268 T_TEST_CASE_FIXTURE( RtemsStatusReqIsEqual, &RtemsStatusReqIsEqual_Fixture )
0269 {
0270   RtemsStatusReqIsEqual_Context *ctx;
0271 
0272   ctx = T_fixture_context();
0273   ctx->Map.in_action_loop = true;
0274   ctx->Map.index = 0;
0275 
0276   for (
0277     ctx->Map.pcs[ 0 ] = RtemsStatusReqIsEqual_Pre_Status_Equal;
0278     ctx->Map.pcs[ 0 ] < RtemsStatusReqIsEqual_Pre_Status_NA;
0279     ++ctx->Map.pcs[ 0 ]
0280   ) {
0281     ctx->Map.entry = RtemsStatusReqIsEqual_PopEntry( ctx );
0282     RtemsStatusReqIsEqual_TestVariant( ctx );
0283   }
0284 }
0285 
0286 /** @} */