source: rtems/testsuites/validation/tc-task-create-errors.c

Last change on this file was bcef89f2, checked in by Sebastian Huber <sebastian.huber@…>, on 05/19/23 at 06:18:25

Update company name

The embedded brains GmbH & Co. KG is the legal successor of embedded
brains GmbH.

  • Property mode set to 100644
File size: 26.4 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RtemsTaskReqCreateErrors
7 */
8
9/*
10 * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * This file is part of the RTEMS quality process and was automatically
36 * generated.  If you find something that needs to be fixed or
37 * worded better please post a report or patch to an RTEMS mailing list
38 * or raise a bug report:
39 *
40 * https://www.rtems.org/bugs.html
41 *
42 * For information on updating and regenerating please refer to the How-To
43 * section in the Software Requirements Engineering chapter of the
44 * RTEMS Software Engineering manual.  The manual is provided as a part of
45 * a release.  For development sources please refer to the online
46 * documentation at:
47 *
48 * https://docs.rtems.org
49 */
50
51#ifdef HAVE_CONFIG_H
52#include "config.h"
53#endif
54
55#include <rtems.h>
56#include <string.h>
57#include <rtems/score/apimutex.h>
58#include <rtems/score/threadimpl.h>
59
60#include "tx-support.h"
61
62#include <rtems/test.h>
63
64/**
65 * @defgroup RtemsTaskReqCreateErrors spec:/rtems/task/req/create-errors
66 *
67 * @ingroup TestsuitesValidationNoClock0
68 * @ingroup TestsuitesValidationOneCpu0
69 *
70 * @{
71 */
72
73typedef enum {
74  RtemsTaskReqCreateErrors_Pre_Name_Valid,
75  RtemsTaskReqCreateErrors_Pre_Name_Inv,
76  RtemsTaskReqCreateErrors_Pre_Name_NA
77} RtemsTaskReqCreateErrors_Pre_Name;
78
79typedef enum {
80  RtemsTaskReqCreateErrors_Pre_Id_Valid,
81  RtemsTaskReqCreateErrors_Pre_Id_Null,
82  RtemsTaskReqCreateErrors_Pre_Id_NA
83} RtemsTaskReqCreateErrors_Pre_Id;
84
85typedef enum {
86  RtemsTaskReqCreateErrors_Pre_SysTsk_Yes,
87  RtemsTaskReqCreateErrors_Pre_SysTsk_No,
88  RtemsTaskReqCreateErrors_Pre_SysTsk_NA
89} RtemsTaskReqCreateErrors_Pre_SysTsk;
90
91typedef enum {
92  RtemsTaskReqCreateErrors_Pre_Prio_Valid,
93  RtemsTaskReqCreateErrors_Pre_Prio_Zero,
94  RtemsTaskReqCreateErrors_Pre_Prio_Inv,
95  RtemsTaskReqCreateErrors_Pre_Prio_NA
96} RtemsTaskReqCreateErrors_Pre_Prio;
97
98typedef enum {
99  RtemsTaskReqCreateErrors_Pre_Free_Yes,
100  RtemsTaskReqCreateErrors_Pre_Free_No,
101  RtemsTaskReqCreateErrors_Pre_Free_NA
102} RtemsTaskReqCreateErrors_Pre_Free;
103
104typedef enum {
105  RtemsTaskReqCreateErrors_Pre_Stack_Normal,
106  RtemsTaskReqCreateErrors_Pre_Stack_Small,
107  RtemsTaskReqCreateErrors_Pre_Stack_Huge,
108  RtemsTaskReqCreateErrors_Pre_Stack_NA
109} RtemsTaskReqCreateErrors_Pre_Stack;
110
111typedef enum {
112  RtemsTaskReqCreateErrors_Pre_Ext_Ok,
113  RtemsTaskReqCreateErrors_Pre_Ext_Err,
114  RtemsTaskReqCreateErrors_Pre_Ext_NA
115} RtemsTaskReqCreateErrors_Pre_Ext;
116
117typedef enum {
118  RtemsTaskReqCreateErrors_Post_Status_Ok,
119  RtemsTaskReqCreateErrors_Post_Status_InvAddr,
120  RtemsTaskReqCreateErrors_Post_Status_InvName,
121  RtemsTaskReqCreateErrors_Post_Status_InvPrio,
122  RtemsTaskReqCreateErrors_Post_Status_TooMany,
123  RtemsTaskReqCreateErrors_Post_Status_Unsat,
124  RtemsTaskReqCreateErrors_Post_Status_NA
125} RtemsTaskReqCreateErrors_Post_Status;
126
127typedef enum {
128  RtemsTaskReqCreateErrors_Post_Name_Valid,
129  RtemsTaskReqCreateErrors_Post_Name_Invalid,
130  RtemsTaskReqCreateErrors_Post_Name_NA
131} RtemsTaskReqCreateErrors_Post_Name;
132
133typedef enum {
134  RtemsTaskReqCreateErrors_Post_IdVar_Set,
135  RtemsTaskReqCreateErrors_Post_IdVar_Nop,
136  RtemsTaskReqCreateErrors_Post_IdVar_NA
137} RtemsTaskReqCreateErrors_Post_IdVar;
138
139typedef enum {
140  RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
141  RtemsTaskReqCreateErrors_Post_CreateExt_No,
142  RtemsTaskReqCreateErrors_Post_CreateExt_NA
143} RtemsTaskReqCreateErrors_Post_CreateExt;
144
145typedef enum {
146  RtemsTaskReqCreateErrors_Post_DelExt_Yes,
147  RtemsTaskReqCreateErrors_Post_DelExt_No,
148  RtemsTaskReqCreateErrors_Post_DelExt_NA
149} RtemsTaskReqCreateErrors_Post_DelExt;
150
151typedef struct {
152  uint32_t Skip : 1;
153  uint32_t Pre_Name_NA : 1;
154  uint32_t Pre_Id_NA : 1;
155  uint32_t Pre_SysTsk_NA : 1;
156  uint32_t Pre_Prio_NA : 1;
157  uint32_t Pre_Free_NA : 1;
158  uint32_t Pre_Stack_NA : 1;
159  uint32_t Pre_Ext_NA : 1;
160  uint32_t Post_Status : 3;
161  uint32_t Post_Name : 2;
162  uint32_t Post_IdVar : 2;
163  uint32_t Post_CreateExt : 2;
164  uint32_t Post_DelExt : 2;
165} RtemsTaskReqCreateErrors_Entry;
166
167/**
168 * @brief Test context for spec:/rtems/task/req/create-errors test case.
169 */
170typedef struct {
171  rtems_status_code status;
172
173  rtems_id *id;
174
175  rtems_id id_value;
176
177  bool create_extension_status;
178
179  uint32_t create_extension_calls;
180
181  uint32_t delete_extension_calls;
182
183  rtems_name name;
184
185  rtems_task_priority initial_priority;
186
187  size_t stack_size;
188
189  rtems_attribute attributes;
190
191  rtems_id extension_id;
192
193  void *seized_objects;
194
195  struct {
196    /**
197     * @brief This member defines the pre-condition states for the next action.
198     */
199    size_t pcs[ 7 ];
200
201    /**
202     * @brief If this member is true, then the test action loop is executed.
203     */
204    bool in_action_loop;
205
206    /**
207     * @brief This member contains the next transition map index.
208     */
209    size_t index;
210
211    /**
212     * @brief This member contains the current transition map entry.
213     */
214    RtemsTaskReqCreateErrors_Entry entry;
215
216    /**
217     * @brief If this member is true, then the current transition variant
218     *   should be skipped.
219     */
220    bool skip;
221  } Map;
222} RtemsTaskReqCreateErrors_Context;
223
224static RtemsTaskReqCreateErrors_Context
225  RtemsTaskReqCreateErrors_Instance;
226
227static const char * const RtemsTaskReqCreateErrors_PreDesc_Name[] = {
228  "Valid",
229  "Inv",
230  "NA"
231};
232
233static const char * const RtemsTaskReqCreateErrors_PreDesc_Id[] = {
234  "Valid",
235  "Null",
236  "NA"
237};
238
239static const char * const RtemsTaskReqCreateErrors_PreDesc_SysTsk[] = {
240  "Yes",
241  "No",
242  "NA"
243};
244
245static const char * const RtemsTaskReqCreateErrors_PreDesc_Prio[] = {
246  "Valid",
247  "Zero",
248  "Inv",
249  "NA"
250};
251
252static const char * const RtemsTaskReqCreateErrors_PreDesc_Free[] = {
253  "Yes",
254  "No",
255  "NA"
256};
257
258static const char * const RtemsTaskReqCreateErrors_PreDesc_Stack[] = {
259  "Normal",
260  "Small",
261  "Huge",
262  "NA"
263};
264
265static const char * const RtemsTaskReqCreateErrors_PreDesc_Ext[] = {
266  "Ok",
267  "Err",
268  "NA"
269};
270
271static const char * const * const RtemsTaskReqCreateErrors_PreDesc[] = {
272  RtemsTaskReqCreateErrors_PreDesc_Name,
273  RtemsTaskReqCreateErrors_PreDesc_Id,
274  RtemsTaskReqCreateErrors_PreDesc_SysTsk,
275  RtemsTaskReqCreateErrors_PreDesc_Prio,
276  RtemsTaskReqCreateErrors_PreDesc_Free,
277  RtemsTaskReqCreateErrors_PreDesc_Stack,
278  RtemsTaskReqCreateErrors_PreDesc_Ext,
279  NULL
280};
281
282#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
283
284typedef RtemsTaskReqCreateErrors_Context Context;
285
286static rtems_status_code Create( void *arg, uint32_t *id )
287{
288  Context          *ctx;
289  bool              create_extension_status;
290  rtems_status_code sc;
291
292  ctx = arg;
293  create_extension_status = ctx->create_extension_status;
294  ctx->create_extension_status = true;
295  sc = rtems_task_create(
296    rtems_build_name( 'S', 'I', 'Z', 'E' ),
297    1,
298    RTEMS_MINIMUM_STACK_SIZE,
299    RTEMS_DEFAULT_MODES,
300    RTEMS_DEFAULT_ATTRIBUTES,
301    id
302  );
303  ctx->create_extension_status = create_extension_status;
304
305  return sc;
306}
307
308static bool ThreadCreate( rtems_tcb *executing, rtems_tcb *created )
309{
310  (void) executing;
311  (void) created;
312
313  ++RtemsTaskReqCreateErrors_Instance.create_extension_calls;
314  return RtemsTaskReqCreateErrors_Instance.create_extension_status;
315}
316
317static void ThreadDelete( rtems_tcb *executing, rtems_tcb *deleted )
318{
319  (void) executing;
320  (void) deleted;
321
322  ++RtemsTaskReqCreateErrors_Instance.delete_extension_calls;
323}
324
325static const rtems_extensions_table extensions = {
326  .thread_create = ThreadCreate,
327  .thread_delete = ThreadDelete
328};
329
330static void RtemsTaskReqCreateErrors_Pre_Name_Prepare(
331  RtemsTaskReqCreateErrors_Context *ctx,
332  RtemsTaskReqCreateErrors_Pre_Name state
333)
334{
335  switch ( state ) {
336    case RtemsTaskReqCreateErrors_Pre_Name_Valid: {
337      /*
338       * While the ``name`` parameter is valid.
339       */
340      ctx->name = NAME;
341      break;
342    }
343
344    case RtemsTaskReqCreateErrors_Pre_Name_Inv: {
345      /*
346       * While the ``name`` parameter is invalid.
347       */
348      ctx->name = 0;
349      break;
350    }
351
352    case RtemsTaskReqCreateErrors_Pre_Name_NA:
353      break;
354  }
355}
356
357static void RtemsTaskReqCreateErrors_Pre_Id_Prepare(
358  RtemsTaskReqCreateErrors_Context *ctx,
359  RtemsTaskReqCreateErrors_Pre_Id   state
360)
361{
362  switch ( state ) {
363    case RtemsTaskReqCreateErrors_Pre_Id_Valid: {
364      /*
365       * While the ``id`` parameter references an object of type rtems_id.
366       */
367      ctx->id = &ctx->id_value;
368      break;
369    }
370
371    case RtemsTaskReqCreateErrors_Pre_Id_Null: {
372      /*
373       * While the ``id`` parameter is NULL.
374       */
375      ctx->id = NULL;
376      break;
377    }
378
379    case RtemsTaskReqCreateErrors_Pre_Id_NA:
380      break;
381  }
382}
383
384static void RtemsTaskReqCreateErrors_Pre_SysTsk_Prepare(
385  RtemsTaskReqCreateErrors_Context   *ctx,
386  RtemsTaskReqCreateErrors_Pre_SysTsk state
387)
388{
389  switch ( state ) {
390    case RtemsTaskReqCreateErrors_Pre_SysTsk_Yes: {
391      /*
392       * While the ``attribute_set`` parameter specifies a system task.
393       */
394      ctx->attributes = RTEMS_SYSTEM_TASK;
395      break;
396    }
397
398    case RtemsTaskReqCreateErrors_Pre_SysTsk_No: {
399      /*
400       * While the ``attribute_set`` parameter specifies an application task.
401       */
402      ctx->attributes = RTEMS_DEFAULT_ATTRIBUTES;
403      break;
404    }
405
406    case RtemsTaskReqCreateErrors_Pre_SysTsk_NA:
407      break;
408  }
409}
410
411static void RtemsTaskReqCreateErrors_Pre_Prio_Prepare(
412  RtemsTaskReqCreateErrors_Context *ctx,
413  RtemsTaskReqCreateErrors_Pre_Prio state
414)
415{
416  switch ( state ) {
417    case RtemsTaskReqCreateErrors_Pre_Prio_Valid: {
418      /*
419       * While the ``initial_priority`` parameter is valid and non-zero.
420       */
421      ctx->initial_priority = RTEMS_MAXIMUM_PRIORITY - 1;
422      break;
423    }
424
425    case RtemsTaskReqCreateErrors_Pre_Prio_Zero: {
426      /*
427       * While the ``initial_priority`` parameter is zero.
428       */
429      ctx->initial_priority = 0;
430      break;
431    }
432
433    case RtemsTaskReqCreateErrors_Pre_Prio_Inv: {
434      /*
435       * While the ``initial_priority`` parameter is invalid.
436       */
437      ctx->initial_priority = 0xffffffff;
438      break;
439    }
440
441    case RtemsTaskReqCreateErrors_Pre_Prio_NA:
442      break;
443  }
444}
445
446static void RtemsTaskReqCreateErrors_Pre_Free_Prepare(
447  RtemsTaskReqCreateErrors_Context *ctx,
448  RtemsTaskReqCreateErrors_Pre_Free state
449)
450{
451  switch ( state ) {
452    case RtemsTaskReqCreateErrors_Pre_Free_Yes: {
453      /*
454       * While the system has at least one inactive task object available.
455       */
456      /* Nothing to do */
457      break;
458    }
459
460    case RtemsTaskReqCreateErrors_Pre_Free_No: {
461      /*
462       * While the system has no inactive task object available.
463       */
464      ctx->seized_objects = T_seize_objects( Create, ctx );
465      break;
466    }
467
468    case RtemsTaskReqCreateErrors_Pre_Free_NA:
469      break;
470  }
471}
472
473static void RtemsTaskReqCreateErrors_Pre_Stack_Prepare(
474  RtemsTaskReqCreateErrors_Context  *ctx,
475  RtemsTaskReqCreateErrors_Pre_Stack state
476)
477{
478  switch ( state ) {
479    case RtemsTaskReqCreateErrors_Pre_Stack_Normal: {
480      /*
481       * While the ``initial_priority`` parameter is greater than or equal to
482       * the configured minimum size and less than or equal to the maximum
483       * stack size which can be allocated by the system.
484       */
485      ctx->stack_size = RTEMS_MINIMUM_STACK_SIZE;
486      break;
487    }
488
489    case RtemsTaskReqCreateErrors_Pre_Stack_Small: {
490      /*
491       * While the ``initial_priority`` parameter is less than the configured
492       * minimum size.
493       */
494      ctx->stack_size = 0;
495      break;
496    }
497
498    case RtemsTaskReqCreateErrors_Pre_Stack_Huge: {
499      /*
500       * While the ``initial_priority`` parameter is greater than the maximum
501       * stack size which can be allocated by the system.
502       */
503      ctx->stack_size = SIZE_MAX;
504      break;
505    }
506
507    case RtemsTaskReqCreateErrors_Pre_Stack_NA:
508      break;
509  }
510}
511
512static void RtemsTaskReqCreateErrors_Pre_Ext_Prepare(
513  RtemsTaskReqCreateErrors_Context *ctx,
514  RtemsTaskReqCreateErrors_Pre_Ext  state
515)
516{
517  switch ( state ) {
518    case RtemsTaskReqCreateErrors_Pre_Ext_Ok: {
519      /*
520       * While none of the task create extensions fails.
521       */
522      ctx->create_extension_status = true;
523      break;
524    }
525
526    case RtemsTaskReqCreateErrors_Pre_Ext_Err: {
527      /*
528       * While at least one of the task create extensions fails.
529       */
530      ctx->create_extension_status = false;
531      break;
532    }
533
534    case RtemsTaskReqCreateErrors_Pre_Ext_NA:
535      break;
536  }
537}
538
539static void RtemsTaskReqCreateErrors_Post_Status_Check(
540  RtemsTaskReqCreateErrors_Context    *ctx,
541  RtemsTaskReqCreateErrors_Post_Status state
542)
543{
544  switch ( state ) {
545    case RtemsTaskReqCreateErrors_Post_Status_Ok: {
546      /*
547       * The return status of rtems_task_create() shall be RTEMS_SUCCESSFUL.
548       */
549      T_rsc_success( ctx->status );
550      break;
551    }
552
553    case RtemsTaskReqCreateErrors_Post_Status_InvAddr: {
554      /*
555       * The return status of rtems_task_create() shall be
556       * RTEMS_INVALID_ADDRESS.
557       */
558      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
559      break;
560    }
561
562    case RtemsTaskReqCreateErrors_Post_Status_InvName: {
563      /*
564       * The return status of rtems_task_create() shall be RTEMS_INVALID_NAME.
565       */
566      T_rsc( ctx->status, RTEMS_INVALID_NAME );
567      break;
568    }
569
570    case RtemsTaskReqCreateErrors_Post_Status_InvPrio: {
571      /*
572       * The return status of rtems_task_create() shall be
573       * RTEMS_INVALID_PRIORITY.
574       */
575      T_rsc( ctx->status, RTEMS_INVALID_PRIORITY );
576      break;
577    }
578
579    case RtemsTaskReqCreateErrors_Post_Status_TooMany: {
580      /*
581       * The return status of rtems_task_create() shall be RTEMS_TOO_MANY.
582       */
583      T_rsc( ctx->status, RTEMS_TOO_MANY );
584      break;
585    }
586
587    case RtemsTaskReqCreateErrors_Post_Status_Unsat: {
588      /*
589       * The return status of rtems_task_create() shall be RTEMS_UNSATISFIED.
590       */
591      T_rsc( ctx->status, RTEMS_UNSATISFIED  );
592      break;
593    }
594
595    case RtemsTaskReqCreateErrors_Post_Status_NA:
596      break;
597  }
598}
599
600static void RtemsTaskReqCreateErrors_Post_Name_Check(
601  RtemsTaskReqCreateErrors_Context  *ctx,
602  RtemsTaskReqCreateErrors_Post_Name state
603)
604{
605  rtems_status_code sc;
606  rtems_id          id;
607
608  switch ( state ) {
609    case RtemsTaskReqCreateErrors_Post_Name_Valid: {
610      /*
611       * The unique object name shall identify the task created by the
612       * rtems_task_create() call.
613       */
614      id = 0;
615      sc = rtems_task_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
616      T_rsc_success( sc );
617      T_eq_u32( id, ctx->id_value );
618      break;
619    }
620
621    case RtemsTaskReqCreateErrors_Post_Name_Invalid: {
622      /*
623       * The unique object name shall not identify a task.
624       */
625      sc = rtems_task_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
626      T_rsc( sc, RTEMS_INVALID_NAME );
627      break;
628    }
629
630    case RtemsTaskReqCreateErrors_Post_Name_NA:
631      break;
632  }
633}
634
635static void RtemsTaskReqCreateErrors_Post_IdVar_Check(
636  RtemsTaskReqCreateErrors_Context   *ctx,
637  RtemsTaskReqCreateErrors_Post_IdVar state
638)
639{
640  switch ( state ) {
641    case RtemsTaskReqCreateErrors_Post_IdVar_Set: {
642      /*
643       * The value of the object referenced by the ``id`` parameter shall be
644       * set to the object identifier of the created task after the return of
645       * the rtems_task_create() call.
646       */
647      T_eq_ptr( ctx->id, &ctx->id_value );
648      T_ne_u32( ctx->id_value, INVALID_ID );
649      break;
650    }
651
652    case RtemsTaskReqCreateErrors_Post_IdVar_Nop: {
653      /*
654       * Objects referenced by the ``id`` parameter in past calls to
655       * rtems_task_create() shall not be accessed by the rtems_task_create()
656       * call.
657       */
658      T_eq_u32( ctx->id_value, INVALID_ID );
659      break;
660    }
661
662    case RtemsTaskReqCreateErrors_Post_IdVar_NA:
663      break;
664  }
665}
666
667static void RtemsTaskReqCreateErrors_Post_CreateExt_Check(
668  RtemsTaskReqCreateErrors_Context       *ctx,
669  RtemsTaskReqCreateErrors_Post_CreateExt state
670)
671{
672  switch ( state ) {
673    case RtemsTaskReqCreateErrors_Post_CreateExt_Yes: {
674      /*
675       * The create user extensions shall be invoked during the
676       * rtems_task_create() call.
677       */
678      T_eq_u32( ctx->create_extension_calls, 1 );
679      break;
680    }
681
682    case RtemsTaskReqCreateErrors_Post_CreateExt_No: {
683      /*
684       * The create user extensions shall not be invoked during the
685       * rtems_task_create() call.
686       */
687      T_eq_u32( ctx->create_extension_calls, 0 );
688      break;
689    }
690
691    case RtemsTaskReqCreateErrors_Post_CreateExt_NA:
692      break;
693  }
694}
695
696static void RtemsTaskReqCreateErrors_Post_DelExt_Check(
697  RtemsTaskReqCreateErrors_Context    *ctx,
698  RtemsTaskReqCreateErrors_Post_DelExt state
699)
700{
701  switch ( state ) {
702    case RtemsTaskReqCreateErrors_Post_DelExt_Yes: {
703      /*
704       * The delete user extensions shall be invoked during the
705       * rtems_task_create() call.
706       */
707      T_eq_u32( ctx->delete_extension_calls, 1 );
708      break;
709    }
710
711    case RtemsTaskReqCreateErrors_Post_DelExt_No: {
712      /*
713       * The delete user extensions shall not be invoked during the
714       * rtems_task_create() call.
715       */
716      T_eq_u32( ctx->delete_extension_calls, 0 );
717      break;
718    }
719
720    case RtemsTaskReqCreateErrors_Post_DelExt_NA:
721      break;
722  }
723}
724
725static void RtemsTaskReqCreateErrors_Setup(
726  RtemsTaskReqCreateErrors_Context *ctx
727)
728{
729  rtems_status_code sc;
730
731  sc = rtems_extension_create(
732    rtems_build_name( 'T', 'E', 'X', 'T' ),
733    &extensions,
734    &ctx->extension_id
735  );
736  T_rsc_success( sc );
737}
738
739static void RtemsTaskReqCreateErrors_Setup_Wrap( void *arg )
740{
741  RtemsTaskReqCreateErrors_Context *ctx;
742
743  ctx = arg;
744  ctx->Map.in_action_loop = false;
745  RtemsTaskReqCreateErrors_Setup( ctx );
746}
747
748static void RtemsTaskReqCreateErrors_Teardown(
749  RtemsTaskReqCreateErrors_Context *ctx
750)
751{
752  rtems_status_code sc;
753
754  sc = rtems_extension_delete( ctx->extension_id );
755  T_rsc_success( sc );
756}
757
758static void RtemsTaskReqCreateErrors_Teardown_Wrap( void *arg )
759{
760  RtemsTaskReqCreateErrors_Context *ctx;
761
762  ctx = arg;
763  ctx->Map.in_action_loop = false;
764  RtemsTaskReqCreateErrors_Teardown( ctx );
765}
766
767static void RtemsTaskReqCreateErrors_Prepare(
768  RtemsTaskReqCreateErrors_Context *ctx
769)
770{
771  _RTEMS_Lock_allocator();
772  _Thread_Kill_zombies();
773  _RTEMS_Unlock_allocator();
774
775  ctx->id_value = INVALID_ID;
776}
777
778static void RtemsTaskReqCreateErrors_Action(
779  RtemsTaskReqCreateErrors_Context *ctx
780)
781{
782  ctx->create_extension_calls = 0;
783  ctx->delete_extension_calls = 0;
784  ctx->status = rtems_task_create(
785    ctx->name,
786    ctx->initial_priority,
787    ctx->stack_size,
788    RTEMS_DEFAULT_MODES,
789    ctx->attributes,
790    ctx->id
791  );
792}
793
794static void RtemsTaskReqCreateErrors_Cleanup(
795  RtemsTaskReqCreateErrors_Context *ctx
796)
797{
798  if ( ctx->id_value != INVALID_ID ) {
799    rtems_status_code sc;
800
801    sc = rtems_task_delete( ctx->id_value );
802    T_rsc_success( sc );
803
804    ctx->id_value = INVALID_ID;
805  }
806
807  T_surrender_objects( &ctx->seized_objects, rtems_task_delete );
808}
809
810static const RtemsTaskReqCreateErrors_Entry
811RtemsTaskReqCreateErrors_Entries[] = {
812  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvName,
813    RtemsTaskReqCreateErrors_Post_Name_Invalid,
814    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
815    RtemsTaskReqCreateErrors_Post_CreateExt_No,
816    RtemsTaskReqCreateErrors_Post_DelExt_No },
817  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvAddr,
818    RtemsTaskReqCreateErrors_Post_Name_Invalid,
819    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
820    RtemsTaskReqCreateErrors_Post_CreateExt_No,
821    RtemsTaskReqCreateErrors_Post_DelExt_No },
822  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvPrio,
823    RtemsTaskReqCreateErrors_Post_Name_Invalid,
824    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
825    RtemsTaskReqCreateErrors_Post_CreateExt_No,
826    RtemsTaskReqCreateErrors_Post_DelExt_No },
827  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_TooMany,
828    RtemsTaskReqCreateErrors_Post_Name_Invalid,
829    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
830    RtemsTaskReqCreateErrors_Post_CreateExt_No,
831    RtemsTaskReqCreateErrors_Post_DelExt_No },
832  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Ok,
833    RtemsTaskReqCreateErrors_Post_Name_Valid,
834    RtemsTaskReqCreateErrors_Post_IdVar_Set,
835    RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
836    RtemsTaskReqCreateErrors_Post_DelExt_No },
837  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Unsat,
838    RtemsTaskReqCreateErrors_Post_Name_Invalid,
839    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
840    RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
841    RtemsTaskReqCreateErrors_Post_DelExt_Yes },
842  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Unsat,
843    RtemsTaskReqCreateErrors_Post_Name_Invalid,
844    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
845    RtemsTaskReqCreateErrors_Post_CreateExt_No,
846    RtemsTaskReqCreateErrors_Post_DelExt_No }
847};
848
849static const uint8_t
850RtemsTaskReqCreateErrors_Map[] = {
851  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,
852  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,
853  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,
854  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,
855  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,
856  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,
857  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,
858  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,
859  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,
860  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,
861  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,
862  0, 0
863};
864
865static size_t RtemsTaskReqCreateErrors_Scope( void *arg, char *buf, size_t n )
866{
867  RtemsTaskReqCreateErrors_Context *ctx;
868
869  ctx = arg;
870
871  if ( ctx->Map.in_action_loop ) {
872    return T_get_scope(
873      RtemsTaskReqCreateErrors_PreDesc,
874      buf,
875      n,
876      ctx->Map.pcs
877    );
878  }
879
880  return 0;
881}
882
883static T_fixture RtemsTaskReqCreateErrors_Fixture = {
884  .setup = RtemsTaskReqCreateErrors_Setup_Wrap,
885  .stop = NULL,
886  .teardown = RtemsTaskReqCreateErrors_Teardown_Wrap,
887  .scope = RtemsTaskReqCreateErrors_Scope,
888  .initial_context = &RtemsTaskReqCreateErrors_Instance
889};
890
891static inline RtemsTaskReqCreateErrors_Entry RtemsTaskReqCreateErrors_PopEntry(
892  RtemsTaskReqCreateErrors_Context *ctx
893)
894{
895  size_t index;
896
897  index = ctx->Map.index;
898  ctx->Map.index = index + 1;
899  return RtemsTaskReqCreateErrors_Entries[
900    RtemsTaskReqCreateErrors_Map[ index ]
901  ];
902}
903
904static void RtemsTaskReqCreateErrors_TestVariant(
905  RtemsTaskReqCreateErrors_Context *ctx
906)
907{
908  RtemsTaskReqCreateErrors_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 0 ] );
909  RtemsTaskReqCreateErrors_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 1 ] );
910  RtemsTaskReqCreateErrors_Pre_SysTsk_Prepare( ctx, ctx->Map.pcs[ 2 ] );
911  RtemsTaskReqCreateErrors_Pre_Prio_Prepare( ctx, ctx->Map.pcs[ 3 ] );
912  RtemsTaskReqCreateErrors_Pre_Free_Prepare( ctx, ctx->Map.pcs[ 4 ] );
913  RtemsTaskReqCreateErrors_Pre_Stack_Prepare( ctx, ctx->Map.pcs[ 5 ] );
914  RtemsTaskReqCreateErrors_Pre_Ext_Prepare( ctx, ctx->Map.pcs[ 6 ] );
915  RtemsTaskReqCreateErrors_Action( ctx );
916  RtemsTaskReqCreateErrors_Post_Status_Check(
917    ctx,
918    ctx->Map.entry.Post_Status
919  );
920  RtemsTaskReqCreateErrors_Post_Name_Check( ctx, ctx->Map.entry.Post_Name );
921  RtemsTaskReqCreateErrors_Post_IdVar_Check( ctx, ctx->Map.entry.Post_IdVar );
922  RtemsTaskReqCreateErrors_Post_CreateExt_Check(
923    ctx,
924    ctx->Map.entry.Post_CreateExt
925  );
926  RtemsTaskReqCreateErrors_Post_DelExt_Check(
927    ctx,
928    ctx->Map.entry.Post_DelExt
929  );
930}
931
932/**
933 * @fn void T_case_body_RtemsTaskReqCreateErrors( void )
934 */
935T_TEST_CASE_FIXTURE(
936  RtemsTaskReqCreateErrors,
937  &RtemsTaskReqCreateErrors_Fixture
938)
939{
940  RtemsTaskReqCreateErrors_Context *ctx;
941
942  ctx = T_fixture_context();
943  ctx->Map.in_action_loop = true;
944  ctx->Map.index = 0;
945
946  for (
947    ctx->Map.pcs[ 0 ] = RtemsTaskReqCreateErrors_Pre_Name_Valid;
948    ctx->Map.pcs[ 0 ] < RtemsTaskReqCreateErrors_Pre_Name_NA;
949    ++ctx->Map.pcs[ 0 ]
950  ) {
951    for (
952      ctx->Map.pcs[ 1 ] = RtemsTaskReqCreateErrors_Pre_Id_Valid;
953      ctx->Map.pcs[ 1 ] < RtemsTaskReqCreateErrors_Pre_Id_NA;
954      ++ctx->Map.pcs[ 1 ]
955    ) {
956      for (
957        ctx->Map.pcs[ 2 ] = RtemsTaskReqCreateErrors_Pre_SysTsk_Yes;
958        ctx->Map.pcs[ 2 ] < RtemsTaskReqCreateErrors_Pre_SysTsk_NA;
959        ++ctx->Map.pcs[ 2 ]
960      ) {
961        for (
962          ctx->Map.pcs[ 3 ] = RtemsTaskReqCreateErrors_Pre_Prio_Valid;
963          ctx->Map.pcs[ 3 ] < RtemsTaskReqCreateErrors_Pre_Prio_NA;
964          ++ctx->Map.pcs[ 3 ]
965        ) {
966          for (
967            ctx->Map.pcs[ 4 ] = RtemsTaskReqCreateErrors_Pre_Free_Yes;
968            ctx->Map.pcs[ 4 ] < RtemsTaskReqCreateErrors_Pre_Free_NA;
969            ++ctx->Map.pcs[ 4 ]
970          ) {
971            for (
972              ctx->Map.pcs[ 5 ] = RtemsTaskReqCreateErrors_Pre_Stack_Normal;
973              ctx->Map.pcs[ 5 ] < RtemsTaskReqCreateErrors_Pre_Stack_NA;
974              ++ctx->Map.pcs[ 5 ]
975            ) {
976              for (
977                ctx->Map.pcs[ 6 ] = RtemsTaskReqCreateErrors_Pre_Ext_Ok;
978                ctx->Map.pcs[ 6 ] < RtemsTaskReqCreateErrors_Pre_Ext_NA;
979                ++ctx->Map.pcs[ 6 ]
980              ) {
981                ctx->Map.entry = RtemsTaskReqCreateErrors_PopEntry( ctx );
982                RtemsTaskReqCreateErrors_Prepare( ctx );
983                RtemsTaskReqCreateErrors_TestVariant( ctx );
984                RtemsTaskReqCreateErrors_Cleanup( ctx );
985              }
986            }
987          }
988        }
989      }
990    }
991  }
992}
993
994/** @} */
Note: See TracBrowser for help on using the repository browser.