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 RtemsTaskReqCreateErrors
0007  */
0008 
0009 /*
0010  * Copyright (C) 2020, 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 <string.h>
0057 #include <rtems/score/apimutex.h>
0058 #include <rtems/score/threadimpl.h>
0059 
0060 #include "tx-support.h"
0061 
0062 #include <rtems/test.h>
0063 
0064 /**
0065  * @defgroup RtemsTaskReqCreateErrors spec:/rtems/task/req/create-errors
0066  *
0067  * @ingroup TestsuitesValidationNoClock0
0068  * @ingroup TestsuitesValidationOneCpu0
0069  *
0070  * @{
0071  */
0072 
0073 typedef enum {
0074   RtemsTaskReqCreateErrors_Pre_Name_Valid,
0075   RtemsTaskReqCreateErrors_Pre_Name_Inv,
0076   RtemsTaskReqCreateErrors_Pre_Name_NA
0077 } RtemsTaskReqCreateErrors_Pre_Name;
0078 
0079 typedef enum {
0080   RtemsTaskReqCreateErrors_Pre_Id_Valid,
0081   RtemsTaskReqCreateErrors_Pre_Id_Null,
0082   RtemsTaskReqCreateErrors_Pre_Id_NA
0083 } RtemsTaskReqCreateErrors_Pre_Id;
0084 
0085 typedef enum {
0086   RtemsTaskReqCreateErrors_Pre_SysTsk_Yes,
0087   RtemsTaskReqCreateErrors_Pre_SysTsk_No,
0088   RtemsTaskReqCreateErrors_Pre_SysTsk_NA
0089 } RtemsTaskReqCreateErrors_Pre_SysTsk;
0090 
0091 typedef enum {
0092   RtemsTaskReqCreateErrors_Pre_Prio_Valid,
0093   RtemsTaskReqCreateErrors_Pre_Prio_Zero,
0094   RtemsTaskReqCreateErrors_Pre_Prio_Inv,
0095   RtemsTaskReqCreateErrors_Pre_Prio_NA
0096 } RtemsTaskReqCreateErrors_Pre_Prio;
0097 
0098 typedef enum {
0099   RtemsTaskReqCreateErrors_Pre_Free_Yes,
0100   RtemsTaskReqCreateErrors_Pre_Free_No,
0101   RtemsTaskReqCreateErrors_Pre_Free_NA
0102 } RtemsTaskReqCreateErrors_Pre_Free;
0103 
0104 typedef enum {
0105   RtemsTaskReqCreateErrors_Pre_Stack_Normal,
0106   RtemsTaskReqCreateErrors_Pre_Stack_Small,
0107   RtemsTaskReqCreateErrors_Pre_Stack_Huge,
0108   RtemsTaskReqCreateErrors_Pre_Stack_NA
0109 } RtemsTaskReqCreateErrors_Pre_Stack;
0110 
0111 typedef enum {
0112   RtemsTaskReqCreateErrors_Pre_Ext_Ok,
0113   RtemsTaskReqCreateErrors_Pre_Ext_Err,
0114   RtemsTaskReqCreateErrors_Pre_Ext_NA
0115 } RtemsTaskReqCreateErrors_Pre_Ext;
0116 
0117 typedef enum {
0118   RtemsTaskReqCreateErrors_Post_Status_Ok,
0119   RtemsTaskReqCreateErrors_Post_Status_InvAddr,
0120   RtemsTaskReqCreateErrors_Post_Status_InvName,
0121   RtemsTaskReqCreateErrors_Post_Status_InvPrio,
0122   RtemsTaskReqCreateErrors_Post_Status_TooMany,
0123   RtemsTaskReqCreateErrors_Post_Status_Unsat,
0124   RtemsTaskReqCreateErrors_Post_Status_NA
0125 } RtemsTaskReqCreateErrors_Post_Status;
0126 
0127 typedef enum {
0128   RtemsTaskReqCreateErrors_Post_Name_Valid,
0129   RtemsTaskReqCreateErrors_Post_Name_Invalid,
0130   RtemsTaskReqCreateErrors_Post_Name_NA
0131 } RtemsTaskReqCreateErrors_Post_Name;
0132 
0133 typedef enum {
0134   RtemsTaskReqCreateErrors_Post_IdVar_Set,
0135   RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0136   RtemsTaskReqCreateErrors_Post_IdVar_NA
0137 } RtemsTaskReqCreateErrors_Post_IdVar;
0138 
0139 typedef enum {
0140   RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
0141   RtemsTaskReqCreateErrors_Post_CreateExt_No,
0142   RtemsTaskReqCreateErrors_Post_CreateExt_NA
0143 } RtemsTaskReqCreateErrors_Post_CreateExt;
0144 
0145 typedef enum {
0146   RtemsTaskReqCreateErrors_Post_DelExt_Yes,
0147   RtemsTaskReqCreateErrors_Post_DelExt_No,
0148   RtemsTaskReqCreateErrors_Post_DelExt_NA
0149 } RtemsTaskReqCreateErrors_Post_DelExt;
0150 
0151 typedef struct {
0152   uint32_t Skip : 1;
0153   uint32_t Pre_Name_NA : 1;
0154   uint32_t Pre_Id_NA : 1;
0155   uint32_t Pre_SysTsk_NA : 1;
0156   uint32_t Pre_Prio_NA : 1;
0157   uint32_t Pre_Free_NA : 1;
0158   uint32_t Pre_Stack_NA : 1;
0159   uint32_t Pre_Ext_NA : 1;
0160   uint32_t Post_Status : 3;
0161   uint32_t Post_Name : 2;
0162   uint32_t Post_IdVar : 2;
0163   uint32_t Post_CreateExt : 2;
0164   uint32_t Post_DelExt : 2;
0165 } RtemsTaskReqCreateErrors_Entry;
0166 
0167 /**
0168  * @brief Test context for spec:/rtems/task/req/create-errors test case.
0169  */
0170 typedef struct {
0171   rtems_status_code status;
0172 
0173   rtems_id *id;
0174 
0175   rtems_id id_value;
0176 
0177   bool create_extension_status;
0178 
0179   uint32_t create_extension_calls;
0180 
0181   uint32_t delete_extension_calls;
0182 
0183   rtems_name name;
0184 
0185   rtems_task_priority initial_priority;
0186 
0187   size_t stack_size;
0188 
0189   rtems_attribute attributes;
0190 
0191   rtems_id extension_id;
0192 
0193   void *seized_objects;
0194 
0195   struct {
0196     /**
0197      * @brief This member defines the pre-condition states for the next action.
0198      */
0199     size_t pcs[ 7 ];
0200 
0201     /**
0202      * @brief If this member is true, then the test action loop is executed.
0203      */
0204     bool in_action_loop;
0205 
0206     /**
0207      * @brief This member contains the next transition map index.
0208      */
0209     size_t index;
0210 
0211     /**
0212      * @brief This member contains the current transition map entry.
0213      */
0214     RtemsTaskReqCreateErrors_Entry entry;
0215 
0216     /**
0217      * @brief If this member is true, then the current transition variant
0218      *   should be skipped.
0219      */
0220     bool skip;
0221   } Map;
0222 } RtemsTaskReqCreateErrors_Context;
0223 
0224 static RtemsTaskReqCreateErrors_Context
0225   RtemsTaskReqCreateErrors_Instance;
0226 
0227 static const char * const RtemsTaskReqCreateErrors_PreDesc_Name[] = {
0228   "Valid",
0229   "Inv",
0230   "NA"
0231 };
0232 
0233 static const char * const RtemsTaskReqCreateErrors_PreDesc_Id[] = {
0234   "Valid",
0235   "Null",
0236   "NA"
0237 };
0238 
0239 static const char * const RtemsTaskReqCreateErrors_PreDesc_SysTsk[] = {
0240   "Yes",
0241   "No",
0242   "NA"
0243 };
0244 
0245 static const char * const RtemsTaskReqCreateErrors_PreDesc_Prio[] = {
0246   "Valid",
0247   "Zero",
0248   "Inv",
0249   "NA"
0250 };
0251 
0252 static const char * const RtemsTaskReqCreateErrors_PreDesc_Free[] = {
0253   "Yes",
0254   "No",
0255   "NA"
0256 };
0257 
0258 static const char * const RtemsTaskReqCreateErrors_PreDesc_Stack[] = {
0259   "Normal",
0260   "Small",
0261   "Huge",
0262   "NA"
0263 };
0264 
0265 static const char * const RtemsTaskReqCreateErrors_PreDesc_Ext[] = {
0266   "Ok",
0267   "Err",
0268   "NA"
0269 };
0270 
0271 static const char * const * const RtemsTaskReqCreateErrors_PreDesc[] = {
0272   RtemsTaskReqCreateErrors_PreDesc_Name,
0273   RtemsTaskReqCreateErrors_PreDesc_Id,
0274   RtemsTaskReqCreateErrors_PreDesc_SysTsk,
0275   RtemsTaskReqCreateErrors_PreDesc_Prio,
0276   RtemsTaskReqCreateErrors_PreDesc_Free,
0277   RtemsTaskReqCreateErrors_PreDesc_Stack,
0278   RtemsTaskReqCreateErrors_PreDesc_Ext,
0279   NULL
0280 };
0281 
0282 #define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
0283 
0284 typedef RtemsTaskReqCreateErrors_Context Context;
0285 
0286 static rtems_status_code Create( void *arg, uint32_t *id )
0287 {
0288   Context          *ctx;
0289   bool              create_extension_status;
0290   rtems_status_code sc;
0291 
0292   ctx = arg;
0293   create_extension_status = ctx->create_extension_status;
0294   ctx->create_extension_status = true;
0295   sc = rtems_task_create(
0296     rtems_build_name( 'S', 'I', 'Z', 'E' ),
0297     1,
0298     RTEMS_MINIMUM_STACK_SIZE,
0299     RTEMS_DEFAULT_MODES,
0300     RTEMS_DEFAULT_ATTRIBUTES,
0301     id
0302   );
0303   ctx->create_extension_status = create_extension_status;
0304 
0305   return sc;
0306 }
0307 
0308 static bool ThreadCreate( rtems_tcb *executing, rtems_tcb *created )
0309 {
0310   (void) executing;
0311   (void) created;
0312 
0313   ++RtemsTaskReqCreateErrors_Instance.create_extension_calls;
0314   return RtemsTaskReqCreateErrors_Instance.create_extension_status;
0315 }
0316 
0317 static void ThreadDelete( rtems_tcb *executing, rtems_tcb *deleted )
0318 {
0319   (void) executing;
0320   (void) deleted;
0321 
0322   ++RtemsTaskReqCreateErrors_Instance.delete_extension_calls;
0323 }
0324 
0325 static const rtems_extensions_table extensions = {
0326   .thread_create = ThreadCreate,
0327   .thread_delete = ThreadDelete
0328 };
0329 
0330 static void RtemsTaskReqCreateErrors_Pre_Name_Prepare(
0331   RtemsTaskReqCreateErrors_Context *ctx,
0332   RtemsTaskReqCreateErrors_Pre_Name state
0333 )
0334 {
0335   switch ( state ) {
0336     case RtemsTaskReqCreateErrors_Pre_Name_Valid: {
0337       /*
0338        * While the ``name`` parameter is valid.
0339        */
0340       ctx->name = NAME;
0341       break;
0342     }
0343 
0344     case RtemsTaskReqCreateErrors_Pre_Name_Inv: {
0345       /*
0346        * While the ``name`` parameter is invalid.
0347        */
0348       ctx->name = 0;
0349       break;
0350     }
0351 
0352     case RtemsTaskReqCreateErrors_Pre_Name_NA:
0353       break;
0354   }
0355 }
0356 
0357 static void RtemsTaskReqCreateErrors_Pre_Id_Prepare(
0358   RtemsTaskReqCreateErrors_Context *ctx,
0359   RtemsTaskReqCreateErrors_Pre_Id   state
0360 )
0361 {
0362   switch ( state ) {
0363     case RtemsTaskReqCreateErrors_Pre_Id_Valid: {
0364       /*
0365        * While the ``id`` parameter references an object of type rtems_id.
0366        */
0367       ctx->id = &ctx->id_value;
0368       break;
0369     }
0370 
0371     case RtemsTaskReqCreateErrors_Pre_Id_Null: {
0372       /*
0373        * While the ``id`` parameter is NULL.
0374        */
0375       ctx->id = NULL;
0376       break;
0377     }
0378 
0379     case RtemsTaskReqCreateErrors_Pre_Id_NA:
0380       break;
0381   }
0382 }
0383 
0384 static void RtemsTaskReqCreateErrors_Pre_SysTsk_Prepare(
0385   RtemsTaskReqCreateErrors_Context   *ctx,
0386   RtemsTaskReqCreateErrors_Pre_SysTsk state
0387 )
0388 {
0389   switch ( state ) {
0390     case RtemsTaskReqCreateErrors_Pre_SysTsk_Yes: {
0391       /*
0392        * While the ``attribute_set`` parameter specifies a system task.
0393        */
0394       ctx->attributes = RTEMS_SYSTEM_TASK;
0395       break;
0396     }
0397 
0398     case RtemsTaskReqCreateErrors_Pre_SysTsk_No: {
0399       /*
0400        * While the ``attribute_set`` parameter specifies an application task.
0401        */
0402       ctx->attributes = RTEMS_DEFAULT_ATTRIBUTES;
0403       break;
0404     }
0405 
0406     case RtemsTaskReqCreateErrors_Pre_SysTsk_NA:
0407       break;
0408   }
0409 }
0410 
0411 static void RtemsTaskReqCreateErrors_Pre_Prio_Prepare(
0412   RtemsTaskReqCreateErrors_Context *ctx,
0413   RtemsTaskReqCreateErrors_Pre_Prio state
0414 )
0415 {
0416   switch ( state ) {
0417     case RtemsTaskReqCreateErrors_Pre_Prio_Valid: {
0418       /*
0419        * While the ``initial_priority`` parameter is valid and non-zero.
0420        */
0421       ctx->initial_priority = RTEMS_MAXIMUM_PRIORITY - 1;
0422       break;
0423     }
0424 
0425     case RtemsTaskReqCreateErrors_Pre_Prio_Zero: {
0426       /*
0427        * While the ``initial_priority`` parameter is zero.
0428        */
0429       ctx->initial_priority = 0;
0430       break;
0431     }
0432 
0433     case RtemsTaskReqCreateErrors_Pre_Prio_Inv: {
0434       /*
0435        * While the ``initial_priority`` parameter is invalid.
0436        */
0437       ctx->initial_priority = 0xffffffff;
0438       break;
0439     }
0440 
0441     case RtemsTaskReqCreateErrors_Pre_Prio_NA:
0442       break;
0443   }
0444 }
0445 
0446 static void RtemsTaskReqCreateErrors_Pre_Free_Prepare(
0447   RtemsTaskReqCreateErrors_Context *ctx,
0448   RtemsTaskReqCreateErrors_Pre_Free state
0449 )
0450 {
0451   switch ( state ) {
0452     case RtemsTaskReqCreateErrors_Pre_Free_Yes: {
0453       /*
0454        * While the system has at least one inactive task object available.
0455        */
0456       /* Nothing to do */
0457       break;
0458     }
0459 
0460     case RtemsTaskReqCreateErrors_Pre_Free_No: {
0461       /*
0462        * While the system has no inactive task object available.
0463        */
0464       ctx->seized_objects = T_seize_objects( Create, ctx );
0465       break;
0466     }
0467 
0468     case RtemsTaskReqCreateErrors_Pre_Free_NA:
0469       break;
0470   }
0471 }
0472 
0473 static void RtemsTaskReqCreateErrors_Pre_Stack_Prepare(
0474   RtemsTaskReqCreateErrors_Context  *ctx,
0475   RtemsTaskReqCreateErrors_Pre_Stack state
0476 )
0477 {
0478   switch ( state ) {
0479     case RtemsTaskReqCreateErrors_Pre_Stack_Normal: {
0480       /*
0481        * While the ``initial_priority`` parameter is greater than or equal to
0482        * the configured minimum size and less than or equal to the maximum
0483        * stack size which can be allocated by the system.
0484        */
0485       ctx->stack_size = RTEMS_MINIMUM_STACK_SIZE;
0486       break;
0487     }
0488 
0489     case RtemsTaskReqCreateErrors_Pre_Stack_Small: {
0490       /*
0491        * While the ``initial_priority`` parameter is less than the configured
0492        * minimum size.
0493        */
0494       ctx->stack_size = 0;
0495       break;
0496     }
0497 
0498     case RtemsTaskReqCreateErrors_Pre_Stack_Huge: {
0499       /*
0500        * While the ``initial_priority`` parameter is greater than the maximum
0501        * stack size which can be allocated by the system.
0502        */
0503       ctx->stack_size = SIZE_MAX;
0504       break;
0505     }
0506 
0507     case RtemsTaskReqCreateErrors_Pre_Stack_NA:
0508       break;
0509   }
0510 }
0511 
0512 static void RtemsTaskReqCreateErrors_Pre_Ext_Prepare(
0513   RtemsTaskReqCreateErrors_Context *ctx,
0514   RtemsTaskReqCreateErrors_Pre_Ext  state
0515 )
0516 {
0517   switch ( state ) {
0518     case RtemsTaskReqCreateErrors_Pre_Ext_Ok: {
0519       /*
0520        * While none of the task create extensions fails.
0521        */
0522       ctx->create_extension_status = true;
0523       break;
0524     }
0525 
0526     case RtemsTaskReqCreateErrors_Pre_Ext_Err: {
0527       /*
0528        * While at least one of the task create extensions fails.
0529        */
0530       ctx->create_extension_status = false;
0531       break;
0532     }
0533 
0534     case RtemsTaskReqCreateErrors_Pre_Ext_NA:
0535       break;
0536   }
0537 }
0538 
0539 static void RtemsTaskReqCreateErrors_Post_Status_Check(
0540   RtemsTaskReqCreateErrors_Context    *ctx,
0541   RtemsTaskReqCreateErrors_Post_Status state
0542 )
0543 {
0544   switch ( state ) {
0545     case RtemsTaskReqCreateErrors_Post_Status_Ok: {
0546       /*
0547        * The return status of rtems_task_create() shall be RTEMS_SUCCESSFUL.
0548        */
0549       T_rsc_success( ctx->status );
0550       break;
0551     }
0552 
0553     case RtemsTaskReqCreateErrors_Post_Status_InvAddr: {
0554       /*
0555        * The return status of rtems_task_create() shall be
0556        * RTEMS_INVALID_ADDRESS.
0557        */
0558       T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
0559       break;
0560     }
0561 
0562     case RtemsTaskReqCreateErrors_Post_Status_InvName: {
0563       /*
0564        * The return status of rtems_task_create() shall be RTEMS_INVALID_NAME.
0565        */
0566       T_rsc( ctx->status, RTEMS_INVALID_NAME );
0567       break;
0568     }
0569 
0570     case RtemsTaskReqCreateErrors_Post_Status_InvPrio: {
0571       /*
0572        * The return status of rtems_task_create() shall be
0573        * RTEMS_INVALID_PRIORITY.
0574        */
0575       T_rsc( ctx->status, RTEMS_INVALID_PRIORITY );
0576       break;
0577     }
0578 
0579     case RtemsTaskReqCreateErrors_Post_Status_TooMany: {
0580       /*
0581        * The return status of rtems_task_create() shall be RTEMS_TOO_MANY.
0582        */
0583       T_rsc( ctx->status, RTEMS_TOO_MANY );
0584       break;
0585     }
0586 
0587     case RtemsTaskReqCreateErrors_Post_Status_Unsat: {
0588       /*
0589        * The return status of rtems_task_create() shall be RTEMS_UNSATISFIED.
0590        */
0591       T_rsc( ctx->status, RTEMS_UNSATISFIED  );
0592       break;
0593     }
0594 
0595     case RtemsTaskReqCreateErrors_Post_Status_NA:
0596       break;
0597   }
0598 }
0599 
0600 static void RtemsTaskReqCreateErrors_Post_Name_Check(
0601   RtemsTaskReqCreateErrors_Context  *ctx,
0602   RtemsTaskReqCreateErrors_Post_Name state
0603 )
0604 {
0605   rtems_status_code sc;
0606   rtems_id          id;
0607 
0608   switch ( state ) {
0609     case RtemsTaskReqCreateErrors_Post_Name_Valid: {
0610       /*
0611        * The unique object name shall identify the task created by the
0612        * rtems_task_create() call.
0613        */
0614       id = 0;
0615       sc = rtems_task_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
0616       T_rsc_success( sc );
0617       T_eq_u32( id, ctx->id_value );
0618       break;
0619     }
0620 
0621     case RtemsTaskReqCreateErrors_Post_Name_Invalid: {
0622       /*
0623        * The unique object name shall not identify a task.
0624        */
0625       sc = rtems_task_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
0626       T_rsc( sc, RTEMS_INVALID_NAME );
0627       break;
0628     }
0629 
0630     case RtemsTaskReqCreateErrors_Post_Name_NA:
0631       break;
0632   }
0633 }
0634 
0635 static void RtemsTaskReqCreateErrors_Post_IdVar_Check(
0636   RtemsTaskReqCreateErrors_Context   *ctx,
0637   RtemsTaskReqCreateErrors_Post_IdVar state
0638 )
0639 {
0640   switch ( state ) {
0641     case RtemsTaskReqCreateErrors_Post_IdVar_Set: {
0642       /*
0643        * The value of the object referenced by the ``id`` parameter shall be
0644        * set to the object identifier of the created task after the return of
0645        * the rtems_task_create() call.
0646        */
0647       T_eq_ptr( ctx->id, &ctx->id_value );
0648       T_ne_u32( ctx->id_value, INVALID_ID );
0649       break;
0650     }
0651 
0652     case RtemsTaskReqCreateErrors_Post_IdVar_Nop: {
0653       /*
0654        * Objects referenced by the ``id`` parameter in past calls to
0655        * rtems_task_create() shall not be accessed by the rtems_task_create()
0656        * call.
0657        */
0658       T_eq_u32( ctx->id_value, INVALID_ID );
0659       break;
0660     }
0661 
0662     case RtemsTaskReqCreateErrors_Post_IdVar_NA:
0663       break;
0664   }
0665 }
0666 
0667 static void RtemsTaskReqCreateErrors_Post_CreateExt_Check(
0668   RtemsTaskReqCreateErrors_Context       *ctx,
0669   RtemsTaskReqCreateErrors_Post_CreateExt state
0670 )
0671 {
0672   switch ( state ) {
0673     case RtemsTaskReqCreateErrors_Post_CreateExt_Yes: {
0674       /*
0675        * The create user extensions shall be invoked during the
0676        * rtems_task_create() call.
0677        */
0678       T_eq_u32( ctx->create_extension_calls, 1 );
0679       break;
0680     }
0681 
0682     case RtemsTaskReqCreateErrors_Post_CreateExt_No: {
0683       /*
0684        * The create user extensions shall not be invoked during the
0685        * rtems_task_create() call.
0686        */
0687       T_eq_u32( ctx->create_extension_calls, 0 );
0688       break;
0689     }
0690 
0691     case RtemsTaskReqCreateErrors_Post_CreateExt_NA:
0692       break;
0693   }
0694 }
0695 
0696 static void RtemsTaskReqCreateErrors_Post_DelExt_Check(
0697   RtemsTaskReqCreateErrors_Context    *ctx,
0698   RtemsTaskReqCreateErrors_Post_DelExt state
0699 )
0700 {
0701   switch ( state ) {
0702     case RtemsTaskReqCreateErrors_Post_DelExt_Yes: {
0703       /*
0704        * The delete user extensions shall be invoked during the
0705        * rtems_task_create() call.
0706        */
0707       T_eq_u32( ctx->delete_extension_calls, 1 );
0708       break;
0709     }
0710 
0711     case RtemsTaskReqCreateErrors_Post_DelExt_No: {
0712       /*
0713        * The delete user extensions shall not be invoked during the
0714        * rtems_task_create() call.
0715        */
0716       T_eq_u32( ctx->delete_extension_calls, 0 );
0717       break;
0718     }
0719 
0720     case RtemsTaskReqCreateErrors_Post_DelExt_NA:
0721       break;
0722   }
0723 }
0724 
0725 static void RtemsTaskReqCreateErrors_Setup(
0726   RtemsTaskReqCreateErrors_Context *ctx
0727 )
0728 {
0729   rtems_status_code sc;
0730 
0731   sc = rtems_extension_create(
0732     rtems_build_name( 'T', 'E', 'X', 'T' ),
0733     &extensions,
0734     &ctx->extension_id
0735   );
0736   T_rsc_success( sc );
0737 }
0738 
0739 static void RtemsTaskReqCreateErrors_Setup_Wrap( void *arg )
0740 {
0741   RtemsTaskReqCreateErrors_Context *ctx;
0742 
0743   ctx = arg;
0744   ctx->Map.in_action_loop = false;
0745   RtemsTaskReqCreateErrors_Setup( ctx );
0746 }
0747 
0748 static void RtemsTaskReqCreateErrors_Teardown(
0749   RtemsTaskReqCreateErrors_Context *ctx
0750 )
0751 {
0752   rtems_status_code sc;
0753 
0754   sc = rtems_extension_delete( ctx->extension_id );
0755   T_rsc_success( sc );
0756 }
0757 
0758 static void RtemsTaskReqCreateErrors_Teardown_Wrap( void *arg )
0759 {
0760   RtemsTaskReqCreateErrors_Context *ctx;
0761 
0762   ctx = arg;
0763   ctx->Map.in_action_loop = false;
0764   RtemsTaskReqCreateErrors_Teardown( ctx );
0765 }
0766 
0767 static void RtemsTaskReqCreateErrors_Prepare(
0768   RtemsTaskReqCreateErrors_Context *ctx
0769 )
0770 {
0771   _RTEMS_Lock_allocator();
0772   _Thread_Kill_zombies();
0773   _RTEMS_Unlock_allocator();
0774 
0775   ctx->id_value = INVALID_ID;
0776 }
0777 
0778 static void RtemsTaskReqCreateErrors_Action(
0779   RtemsTaskReqCreateErrors_Context *ctx
0780 )
0781 {
0782   ctx->create_extension_calls = 0;
0783   ctx->delete_extension_calls = 0;
0784   ctx->status = rtems_task_create(
0785     ctx->name,
0786     ctx->initial_priority,
0787     ctx->stack_size,
0788     RTEMS_DEFAULT_MODES,
0789     ctx->attributes,
0790     ctx->id
0791   );
0792 }
0793 
0794 static void RtemsTaskReqCreateErrors_Cleanup(
0795   RtemsTaskReqCreateErrors_Context *ctx
0796 )
0797 {
0798   if ( ctx->id_value != INVALID_ID ) {
0799     rtems_status_code sc;
0800 
0801     sc = rtems_task_delete( ctx->id_value );
0802     T_rsc_success( sc );
0803 
0804     ctx->id_value = INVALID_ID;
0805   }
0806 
0807   T_surrender_objects( &ctx->seized_objects, rtems_task_delete );
0808 }
0809 
0810 static const RtemsTaskReqCreateErrors_Entry
0811 RtemsTaskReqCreateErrors_Entries[] = {
0812   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvName,
0813     RtemsTaskReqCreateErrors_Post_Name_Invalid,
0814     RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0815     RtemsTaskReqCreateErrors_Post_CreateExt_No,
0816     RtemsTaskReqCreateErrors_Post_DelExt_No },
0817   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvAddr,
0818     RtemsTaskReqCreateErrors_Post_Name_Invalid,
0819     RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0820     RtemsTaskReqCreateErrors_Post_CreateExt_No,
0821     RtemsTaskReqCreateErrors_Post_DelExt_No },
0822   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvPrio,
0823     RtemsTaskReqCreateErrors_Post_Name_Invalid,
0824     RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0825     RtemsTaskReqCreateErrors_Post_CreateExt_No,
0826     RtemsTaskReqCreateErrors_Post_DelExt_No },
0827   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_TooMany,
0828     RtemsTaskReqCreateErrors_Post_Name_Invalid,
0829     RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0830     RtemsTaskReqCreateErrors_Post_CreateExt_No,
0831     RtemsTaskReqCreateErrors_Post_DelExt_No },
0832   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Ok,
0833     RtemsTaskReqCreateErrors_Post_Name_Valid,
0834     RtemsTaskReqCreateErrors_Post_IdVar_Set,
0835     RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
0836     RtemsTaskReqCreateErrors_Post_DelExt_No },
0837   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Unsat,
0838     RtemsTaskReqCreateErrors_Post_Name_Invalid,
0839     RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0840     RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
0841     RtemsTaskReqCreateErrors_Post_DelExt_Yes },
0842   { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Unsat,
0843     RtemsTaskReqCreateErrors_Post_Name_Invalid,
0844     RtemsTaskReqCreateErrors_Post_IdVar_Nop,
0845     RtemsTaskReqCreateErrors_Post_CreateExt_No,
0846     RtemsTaskReqCreateErrors_Post_DelExt_No }
0847 };
0848 
0849 static const uint8_t
0850 RtemsTaskReqCreateErrors_Map[] = {
0851   4, 5, 4, 5, 6, 6, 3, 3, 3, 3, 3, 3, 4, 5, 4, 5, 6, 6, 3, 3, 3, 3, 3, 3, 2, 2,
0852   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 5, 4, 5, 6, 6, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
0853   2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
0854   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0855   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0856   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, 0,
0857   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,
0858   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,
0859   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,
0860   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,
0861   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,
0862   0, 0
0863 };
0864 
0865 static size_t RtemsTaskReqCreateErrors_Scope( void *arg, char *buf, size_t n )
0866 {
0867   RtemsTaskReqCreateErrors_Context *ctx;
0868 
0869   ctx = arg;
0870 
0871   if ( ctx->Map.in_action_loop ) {
0872     return T_get_scope(
0873       RtemsTaskReqCreateErrors_PreDesc,
0874       buf,
0875       n,
0876       ctx->Map.pcs
0877     );
0878   }
0879 
0880   return 0;
0881 }
0882 
0883 static T_fixture RtemsTaskReqCreateErrors_Fixture = {
0884   .setup = RtemsTaskReqCreateErrors_Setup_Wrap,
0885   .stop = NULL,
0886   .teardown = RtemsTaskReqCreateErrors_Teardown_Wrap,
0887   .scope = RtemsTaskReqCreateErrors_Scope,
0888   .initial_context = &RtemsTaskReqCreateErrors_Instance
0889 };
0890 
0891 static inline RtemsTaskReqCreateErrors_Entry RtemsTaskReqCreateErrors_PopEntry(
0892   RtemsTaskReqCreateErrors_Context *ctx
0893 )
0894 {
0895   size_t index;
0896 
0897   index = ctx->Map.index;
0898   ctx->Map.index = index + 1;
0899   return RtemsTaskReqCreateErrors_Entries[
0900     RtemsTaskReqCreateErrors_Map[ index ]
0901   ];
0902 }
0903 
0904 static void RtemsTaskReqCreateErrors_TestVariant(
0905   RtemsTaskReqCreateErrors_Context *ctx
0906 )
0907 {
0908   RtemsTaskReqCreateErrors_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 0 ] );
0909   RtemsTaskReqCreateErrors_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 1 ] );
0910   RtemsTaskReqCreateErrors_Pre_SysTsk_Prepare( ctx, ctx->Map.pcs[ 2 ] );
0911   RtemsTaskReqCreateErrors_Pre_Prio_Prepare( ctx, ctx->Map.pcs[ 3 ] );
0912   RtemsTaskReqCreateErrors_Pre_Free_Prepare( ctx, ctx->Map.pcs[ 4 ] );
0913   RtemsTaskReqCreateErrors_Pre_Stack_Prepare( ctx, ctx->Map.pcs[ 5 ] );
0914   RtemsTaskReqCreateErrors_Pre_Ext_Prepare( ctx, ctx->Map.pcs[ 6 ] );
0915   RtemsTaskReqCreateErrors_Action( ctx );
0916   RtemsTaskReqCreateErrors_Post_Status_Check(
0917     ctx,
0918     ctx->Map.entry.Post_Status
0919   );
0920   RtemsTaskReqCreateErrors_Post_Name_Check( ctx, ctx->Map.entry.Post_Name );
0921   RtemsTaskReqCreateErrors_Post_IdVar_Check( ctx, ctx->Map.entry.Post_IdVar );
0922   RtemsTaskReqCreateErrors_Post_CreateExt_Check(
0923     ctx,
0924     ctx->Map.entry.Post_CreateExt
0925   );
0926   RtemsTaskReqCreateErrors_Post_DelExt_Check(
0927     ctx,
0928     ctx->Map.entry.Post_DelExt
0929   );
0930 }
0931 
0932 /**
0933  * @fn void T_case_body_RtemsTaskReqCreateErrors( void )
0934  */
0935 T_TEST_CASE_FIXTURE(
0936   RtemsTaskReqCreateErrors,
0937   &RtemsTaskReqCreateErrors_Fixture
0938 )
0939 {
0940   RtemsTaskReqCreateErrors_Context *ctx;
0941 
0942   ctx = T_fixture_context();
0943   ctx->Map.in_action_loop = true;
0944   ctx->Map.index = 0;
0945 
0946   for (
0947     ctx->Map.pcs[ 0 ] = RtemsTaskReqCreateErrors_Pre_Name_Valid;
0948     ctx->Map.pcs[ 0 ] < RtemsTaskReqCreateErrors_Pre_Name_NA;
0949     ++ctx->Map.pcs[ 0 ]
0950   ) {
0951     for (
0952       ctx->Map.pcs[ 1 ] = RtemsTaskReqCreateErrors_Pre_Id_Valid;
0953       ctx->Map.pcs[ 1 ] < RtemsTaskReqCreateErrors_Pre_Id_NA;
0954       ++ctx->Map.pcs[ 1 ]
0955     ) {
0956       for (
0957         ctx->Map.pcs[ 2 ] = RtemsTaskReqCreateErrors_Pre_SysTsk_Yes;
0958         ctx->Map.pcs[ 2 ] < RtemsTaskReqCreateErrors_Pre_SysTsk_NA;
0959         ++ctx->Map.pcs[ 2 ]
0960       ) {
0961         for (
0962           ctx->Map.pcs[ 3 ] = RtemsTaskReqCreateErrors_Pre_Prio_Valid;
0963           ctx->Map.pcs[ 3 ] < RtemsTaskReqCreateErrors_Pre_Prio_NA;
0964           ++ctx->Map.pcs[ 3 ]
0965         ) {
0966           for (
0967             ctx->Map.pcs[ 4 ] = RtemsTaskReqCreateErrors_Pre_Free_Yes;
0968             ctx->Map.pcs[ 4 ] < RtemsTaskReqCreateErrors_Pre_Free_NA;
0969             ++ctx->Map.pcs[ 4 ]
0970           ) {
0971             for (
0972               ctx->Map.pcs[ 5 ] = RtemsTaskReqCreateErrors_Pre_Stack_Normal;
0973               ctx->Map.pcs[ 5 ] < RtemsTaskReqCreateErrors_Pre_Stack_NA;
0974               ++ctx->Map.pcs[ 5 ]
0975             ) {
0976               for (
0977                 ctx->Map.pcs[ 6 ] = RtemsTaskReqCreateErrors_Pre_Ext_Ok;
0978                 ctx->Map.pcs[ 6 ] < RtemsTaskReqCreateErrors_Pre_Ext_NA;
0979                 ++ctx->Map.pcs[ 6 ]
0980               ) {
0981                 ctx->Map.entry = RtemsTaskReqCreateErrors_PopEntry( ctx );
0982                 RtemsTaskReqCreateErrors_Prepare( ctx );
0983                 RtemsTaskReqCreateErrors_TestVariant( ctx );
0984                 RtemsTaskReqCreateErrors_Cleanup( ctx );
0985               }
0986             }
0987           }
0988         }
0989       }
0990     }
0991   }
0992 }
0993 
0994 /** @} */