summaryrefslogtreecommitdiffstats
path: root/testsuites/validation/tc-task-create-errors.c
blob: 1733201ab1885805aa9522f65413d76a0a73d4e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @ingroup RTEMSTestCaseRtemsTaskReqCreateErrors
 */

/*
 * 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 <rtems/score/apimutex.h>
#include <rtems/score/threadimpl.h>

#include <rtems/test.h>

/**
 * @defgroup RTEMSTestCaseRtemsTaskReqCreateErrors \
 *   spec:/rtems/task/req/create-errors
 *
 * @ingroup RTEMSTestSuiteTestsuitesValidation0
 * @ingroup RTEMSTestSuiteTestsuitesValidation1
 *
 * @{
 */

typedef enum {
  RtemsTaskReqCreateErrors_Pre_Name_Valid,
  RtemsTaskReqCreateErrors_Pre_Name_Inv,
  RtemsTaskReqCreateErrors_Pre_Name_NA
} RtemsTaskReqCreateErrors_Pre_Name;

typedef enum {
  RtemsTaskReqCreateErrors_Pre_Id_Valid,
  RtemsTaskReqCreateErrors_Pre_Id_Null,
  RtemsTaskReqCreateErrors_Pre_Id_NA
} RtemsTaskReqCreateErrors_Pre_Id;

typedef enum {
  RtemsTaskReqCreateErrors_Pre_SysTsk_Yes,
  RtemsTaskReqCreateErrors_Pre_SysTsk_No,
  RtemsTaskReqCreateErrors_Pre_SysTsk_NA
} RtemsTaskReqCreateErrors_Pre_SysTsk;

typedef enum {
  RtemsTaskReqCreateErrors_Pre_Prio_Valid,
  RtemsTaskReqCreateErrors_Pre_Prio_Zero,
  RtemsTaskReqCreateErrors_Pre_Prio_Inv,
  RtemsTaskReqCreateErrors_Pre_Prio_NA
} RtemsTaskReqCreateErrors_Pre_Prio;

typedef enum {
  RtemsTaskReqCreateErrors_Pre_Free_Yes,
  RtemsTaskReqCreateErrors_Pre_Free_No,
  RtemsTaskReqCreateErrors_Pre_Free_NA
} RtemsTaskReqCreateErrors_Pre_Free;

typedef enum {
  RtemsTaskReqCreateErrors_Pre_Stack_Normal,
  RtemsTaskReqCreateErrors_Pre_Stack_Small,
  RtemsTaskReqCreateErrors_Pre_Stack_Huge,
  RtemsTaskReqCreateErrors_Pre_Stack_NA
} RtemsTaskReqCreateErrors_Pre_Stack;

typedef enum {
  RtemsTaskReqCreateErrors_Pre_Ext_Ok,
  RtemsTaskReqCreateErrors_Pre_Ext_Err,
  RtemsTaskReqCreateErrors_Pre_Ext_NA
} RtemsTaskReqCreateErrors_Pre_Ext;

typedef enum {
  RtemsTaskReqCreateErrors_Post_Status_Ok,
  RtemsTaskReqCreateErrors_Post_Status_InvAddr,
  RtemsTaskReqCreateErrors_Post_Status_InvName,
  RtemsTaskReqCreateErrors_Post_Status_InvPrio,
  RtemsTaskReqCreateErrors_Post_Status_TooMany,
  RtemsTaskReqCreateErrors_Post_Status_Unsat,
  RtemsTaskReqCreateErrors_Post_Status_NA
} RtemsTaskReqCreateErrors_Post_Status;

typedef enum {
  RtemsTaskReqCreateErrors_Post_Name_Valid,
  RtemsTaskReqCreateErrors_Post_Name_Invalid,
  RtemsTaskReqCreateErrors_Post_Name_NA
} RtemsTaskReqCreateErrors_Post_Name;

typedef enum {
  RtemsTaskReqCreateErrors_Post_IdVar_Set,
  RtemsTaskReqCreateErrors_Post_IdVar_Nop,
  RtemsTaskReqCreateErrors_Post_IdVar_NA
} RtemsTaskReqCreateErrors_Post_IdVar;

typedef enum {
  RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
  RtemsTaskReqCreateErrors_Post_CreateExt_No,
  RtemsTaskReqCreateErrors_Post_CreateExt_NA
} RtemsTaskReqCreateErrors_Post_CreateExt;

typedef enum {
  RtemsTaskReqCreateErrors_Post_DelExt_Yes,
  RtemsTaskReqCreateErrors_Post_DelExt_No,
  RtemsTaskReqCreateErrors_Post_DelExt_NA
} RtemsTaskReqCreateErrors_Post_DelExt;

/**
 * @brief Test context for spec:/rtems/task/req/create-errors test case.
 */
typedef struct {
  rtems_status_code status;

  rtems_id *id;

  rtems_id id_value;

  bool create_extension_status;

  uint32_t create_extension_calls;

  uint32_t delete_extension_calls;

  rtems_name name;

  rtems_task_priority initial_priority;

  size_t stack_size;

  rtems_attribute attributes;

  rtems_id extension_id;

  void *seized_objects;

  /**
   * @brief This member defines the pre-condition states for the next action.
   */
  size_t pcs[ 7 ];

  /**
   * @brief This member indicates if the test action loop is currently
   *   executed.
   */
  bool in_action_loop;
} RtemsTaskReqCreateErrors_Context;

static RtemsTaskReqCreateErrors_Context
  RtemsTaskReqCreateErrors_Instance;

static const char * const RtemsTaskReqCreateErrors_PreDesc_Name[] = {
  "Valid",
  "Inv",
  "NA"
};

static const char * const RtemsTaskReqCreateErrors_PreDesc_Id[] = {
  "Valid",
  "Null",
  "NA"
};

static const char * const RtemsTaskReqCreateErrors_PreDesc_SysTsk[] = {
  "Yes",
  "No",
  "NA"
};

static const char * const RtemsTaskReqCreateErrors_PreDesc_Prio[] = {
  "Valid",
  "Zero",
  "Inv",
  "NA"
};

static const char * const RtemsTaskReqCreateErrors_PreDesc_Free[] = {
  "Yes",
  "No",
  "NA"
};

static const char * const RtemsTaskReqCreateErrors_PreDesc_Stack[] = {
  "Normal",
  "Small",
  "Huge",
  "NA"
};

static const char * const RtemsTaskReqCreateErrors_PreDesc_Ext[] = {
  "Ok",
  "Err",
  "NA"
};

static const char * const * const RtemsTaskReqCreateErrors_PreDesc[] = {
  RtemsTaskReqCreateErrors_PreDesc_Name,
  RtemsTaskReqCreateErrors_PreDesc_Id,
  RtemsTaskReqCreateErrors_PreDesc_SysTsk,
  RtemsTaskReqCreateErrors_PreDesc_Prio,
  RtemsTaskReqCreateErrors_PreDesc_Free,
  RtemsTaskReqCreateErrors_PreDesc_Stack,
  RtemsTaskReqCreateErrors_PreDesc_Ext,
  NULL
};

#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )

#define INVALID_ID 0xffffffff

typedef RtemsTaskReqCreateErrors_Context Context;

static rtems_status_code Create( void *arg, uint32_t *id )
{
  Context          *ctx;
  bool              create_extension_status;
  rtems_status_code sc;

  ctx = arg;
  create_extension_status = ctx->create_extension_status;
  ctx->create_extension_status = true;
  sc = rtems_task_create(
    rtems_build_name( 'S', 'I', 'Z', 'E' ),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    id
  );
  ctx->create_extension_status = create_extension_status;

  return sc;
}

static bool ThreadCreate( rtems_tcb *executing, rtems_tcb *created )
{
  (void) executing;
  (void) created;

  ++RtemsTaskReqCreateErrors_Instance.create_extension_calls;
  return RtemsTaskReqCreateErrors_Instance.create_extension_status;
}

static void ThreadDelete( rtems_tcb *executing, rtems_tcb *deleted )
{
  (void) executing;
  (void) deleted;

  ++RtemsTaskReqCreateErrors_Instance.delete_extension_calls;
}

static const rtems_extensions_table extensions = {
  .thread_create = ThreadCreate,
  .thread_delete = ThreadDelete
};

static void RtemsTaskReqCreateErrors_Pre_Name_Prepare(
  RtemsTaskReqCreateErrors_Context *ctx,
  RtemsTaskReqCreateErrors_Pre_Name state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_Name_Valid: {
      /*
       * While the ``name`` parameter is valid.
       */
      ctx->name = NAME;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Name_Inv: {
      /*
       * While the ``name`` parameter is invalid.
       */
      ctx->name = 0;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Name_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Pre_Id_Prepare(
  RtemsTaskReqCreateErrors_Context *ctx,
  RtemsTaskReqCreateErrors_Pre_Id   state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_Id_Valid: {
      /*
       * While the ``id`` parameter references an object of type rtems_id.
       */
      ctx->id = &ctx->id_value;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Id_Null: {
      /*
       * While the ``id`` parameter is NULL.
       */
      ctx->id = NULL;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Id_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Pre_SysTsk_Prepare(
  RtemsTaskReqCreateErrors_Context   *ctx,
  RtemsTaskReqCreateErrors_Pre_SysTsk state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_SysTsk_Yes: {
      /*
       * While the ``attribute_set`` parameter specifies a system task.
       */
      ctx->attributes = RTEMS_SYSTEM_TASK;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_SysTsk_No: {
      /*
       * While the ``attribute_set`` parameter specifies an application task.
       */
      ctx->attributes = RTEMS_DEFAULT_ATTRIBUTES;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_SysTsk_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Pre_Prio_Prepare(
  RtemsTaskReqCreateErrors_Context *ctx,
  RtemsTaskReqCreateErrors_Pre_Prio state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_Prio_Valid: {
      /*
       * While the ``initial_priority`` parameter is valid and non-zero.
       */
      ctx->initial_priority = 254;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Prio_Zero: {
      /*
       * While the ``initial_priority`` parameter is zero.
       */
      ctx->initial_priority = 0;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Prio_Inv: {
      /*
       * While the ``initial_priority`` parameter is invalid.
       */
      ctx->initial_priority = 0xffffffff;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Prio_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Pre_Free_Prepare(
  RtemsTaskReqCreateErrors_Context *ctx,
  RtemsTaskReqCreateErrors_Pre_Free state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_Free_Yes: {
      /*
       * While the system has at least one inactive task object available.
       */
      /* Nothing to do */
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Free_No: {
      /*
       * While the system has no inactive task object available.
       */
      ctx->seized_objects = T_seize_objects( Create, ctx );
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Free_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Pre_Stack_Prepare(
  RtemsTaskReqCreateErrors_Context  *ctx,
  RtemsTaskReqCreateErrors_Pre_Stack state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_Stack_Normal: {
      /*
       * While the ``initial_priority`` parameter is greater than or equal to
       * the configured minimum size and less than or equal to the maximum
       * stack size which can be allocated by the system.
       */
      ctx->stack_size = RTEMS_MINIMUM_STACK_SIZE;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Stack_Small: {
      /*
       * While the ``initial_priority`` parameter is less than the configured
       * minimum size.
       */
      ctx->stack_size = 0;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Stack_Huge: {
      /*
       * While the ``initial_priority`` parameter is greater than the maximum
       * stack size which can be allocated by the system.
       */
      ctx->stack_size = SIZE_MAX;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Stack_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Pre_Ext_Prepare(
  RtemsTaskReqCreateErrors_Context *ctx,
  RtemsTaskReqCreateErrors_Pre_Ext  state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Pre_Ext_Ok: {
      /*
       * While none of the task create extensions fails.
       */
      ctx->create_extension_status = true;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Ext_Err: {
      /*
       * While at least one of the task create extensions fails.
       */
      ctx->create_extension_status = false;
      break;
    }

    case RtemsTaskReqCreateErrors_Pre_Ext_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Post_Status_Check(
  RtemsTaskReqCreateErrors_Context    *ctx,
  RtemsTaskReqCreateErrors_Post_Status state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Post_Status_Ok: {
      /*
       * The return status of rtems_task_create() shall be RTEMS_SUCCESSFUL.
       */
      T_rsc_success( ctx->status );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Status_InvAddr: {
      /*
       * The return status of rtems_task_create() shall be
       * RTEMS_INVALID_ADDRESS.
       */
      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Status_InvName: {
      /*
       * The return status of rtems_task_create() shall be RTEMS_INVALID_NAME.
       */
      T_rsc( ctx->status, RTEMS_INVALID_NAME );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Status_InvPrio: {
      /*
       * The return status of rtems_task_create() shall be
       * RTEMS_INVALID_PRIORITY.
       */
      T_rsc( ctx->status, RTEMS_INVALID_PRIORITY );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Status_TooMany: {
      /*
       * The return status of rtems_task_create() shall be RTEMS_TOO_MANY.
       */
      T_rsc( ctx->status, RTEMS_TOO_MANY );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Status_Unsat: {
      /*
       * The return status of rtems_task_create() shall be RTEMS_UNSATISFIED.
       */
      T_rsc( ctx->status, RTEMS_UNSATISFIED  );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Status_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Post_Name_Check(
  RtemsTaskReqCreateErrors_Context  *ctx,
  RtemsTaskReqCreateErrors_Post_Name state
)
{
  rtems_status_code sc;
  rtems_id          id;

  switch ( state ) {
    case RtemsTaskReqCreateErrors_Post_Name_Valid: {
      /*
       * The unique object name shall identify the task created by the
       * rtems_task_create() call.
       */
      id = 0;
      sc = rtems_task_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
      T_rsc_success( sc );
      T_eq_u32( id, ctx->id_value );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Name_Invalid: {
      /*
       * The unique object name shall not identify a task.
       */
      sc = rtems_task_ident( NAME, RTEMS_SEARCH_LOCAL_NODE, &id );
      T_rsc( sc, RTEMS_INVALID_NAME );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_Name_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Post_IdVar_Check(
  RtemsTaskReqCreateErrors_Context   *ctx,
  RtemsTaskReqCreateErrors_Post_IdVar state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Post_IdVar_Set: {
      /*
       * The value of the object referenced by the ``id`` parameter shall be
       * set to the object identifier of the created task after the return of
       * the rtems_task_create() call.
       */
      T_eq_ptr( ctx->id, &ctx->id_value );
      T_ne_u32( ctx->id_value, INVALID_ID );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_IdVar_Nop: {
      /*
       * Objects referenced by the ``id`` parameter in past calls to
       * rtems_task_create() shall not be accessed by the rtems_task_create()
       * call.
       */
      T_eq_u32( ctx->id_value, INVALID_ID );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_IdVar_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Post_CreateExt_Check(
  RtemsTaskReqCreateErrors_Context       *ctx,
  RtemsTaskReqCreateErrors_Post_CreateExt state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Post_CreateExt_Yes: {
      /*
       * The create user extensions shall be invoked during the
       * rtems_task_create() call.
       */
      T_eq_u32( ctx->create_extension_calls, 1 );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_CreateExt_No: {
      /*
       * The create user extensions shall not be invoked during the
       * rtems_task_create() call.
       */
      T_eq_u32( ctx->create_extension_calls, 0 );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_CreateExt_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Post_DelExt_Check(
  RtemsTaskReqCreateErrors_Context    *ctx,
  RtemsTaskReqCreateErrors_Post_DelExt state
)
{
  switch ( state ) {
    case RtemsTaskReqCreateErrors_Post_DelExt_Yes: {
      /*
       * The delete user extensions shall be invoked during the
       * rtems_task_create() call.
       */
      T_eq_u32( ctx->delete_extension_calls, 1 );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_DelExt_No: {
      /*
       * The delete user extensions shall not be invoked during the
       * rtems_task_create() call.
       */
      T_eq_u32( ctx->delete_extension_calls, 0 );
      break;
    }

    case RtemsTaskReqCreateErrors_Post_DelExt_NA:
      break;
  }
}

static void RtemsTaskReqCreateErrors_Setup(
  RtemsTaskReqCreateErrors_Context *ctx
)
{
  rtems_status_code sc;

  sc = rtems_extension_create(
    rtems_build_name( 'T', 'E', 'X', 'T' ),
    &extensions,
    &ctx->extension_id
  );
  T_rsc_success( sc );
}

static void RtemsTaskReqCreateErrors_Setup_Wrap( void *arg )
{
  RtemsTaskReqCreateErrors_Context *ctx;

  ctx = arg;
  ctx->in_action_loop = false;
  RtemsTaskReqCreateErrors_Setup( ctx );
}

static void RtemsTaskReqCreateErrors_Teardown(
  RtemsTaskReqCreateErrors_Context *ctx
)
{
  rtems_status_code sc;

  sc = rtems_extension_delete( ctx->extension_id );
  T_rsc_success( sc );
}

static void RtemsTaskReqCreateErrors_Teardown_Wrap( void *arg )
{
  RtemsTaskReqCreateErrors_Context *ctx;

  ctx = arg;
  ctx->in_action_loop = false;
  RtemsTaskReqCreateErrors_Teardown( ctx );
}

static void RtemsTaskReqCreateErrors_Prepare(
  RtemsTaskReqCreateErrors_Context *ctx
)
{
  _RTEMS_Lock_allocator();
  _Thread_Kill_zombies();
  _RTEMS_Unlock_allocator();

  ctx->id_value = INVALID_ID;
}

static void RtemsTaskReqCreateErrors_Action(
  RtemsTaskReqCreateErrors_Context *ctx
)
{
  ctx->create_extension_calls = 0;
  ctx->delete_extension_calls = 0;
  ctx->status = rtems_task_create(
    ctx->name,
    ctx->initial_priority,
    ctx->stack_size,
    RTEMS_DEFAULT_MODES,
    ctx->attributes,
    ctx->id
  );
}

static void RtemsTaskReqCreateErrors_Cleanup(
  RtemsTaskReqCreateErrors_Context *ctx
)
{
  if ( ctx->id_value != INVALID_ID ) {
    rtems_status_code sc;

    sc = rtems_task_delete( ctx->id_value );
    T_rsc_success( sc );

    ctx->id_value = INVALID_ID;
  }

  T_surrender_objects( &ctx->seized_objects, rtems_task_delete );
}

typedef struct {
  uint32_t Skip : 1;
  uint32_t Pre_Name_NA : 1;
  uint32_t Pre_Id_NA : 1;
  uint32_t Pre_SysTsk_NA : 1;
  uint32_t Pre_Prio_NA : 1;
  uint32_t Pre_Free_NA : 1;
  uint32_t Pre_Stack_NA : 1;
  uint32_t Pre_Ext_NA : 1;
  uint32_t Post_Status : 3;
  uint32_t Post_Name : 2;
  uint32_t Post_IdVar : 2;
  uint32_t Post_CreateExt : 2;
  uint32_t Post_DelExt : 2;
} RtemsTaskReqCreateErrors_Entry;

static const RtemsTaskReqCreateErrors_Entry
RtemsTaskReqCreateErrors_Entries[] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvName,
    RtemsTaskReqCreateErrors_Post_Name_Invalid,
    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
    RtemsTaskReqCreateErrors_Post_CreateExt_No,
    RtemsTaskReqCreateErrors_Post_DelExt_No },
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvAddr,
    RtemsTaskReqCreateErrors_Post_Name_Invalid,
    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
    RtemsTaskReqCreateErrors_Post_CreateExt_No,
    RtemsTaskReqCreateErrors_Post_DelExt_No },
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_InvPrio,
    RtemsTaskReqCreateErrors_Post_Name_Invalid,
    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
    RtemsTaskReqCreateErrors_Post_CreateExt_No,
    RtemsTaskReqCreateErrors_Post_DelExt_No },
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_TooMany,
    RtemsTaskReqCreateErrors_Post_Name_Invalid,
    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
    RtemsTaskReqCreateErrors_Post_CreateExt_No,
    RtemsTaskReqCreateErrors_Post_DelExt_No },
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Ok,
    RtemsTaskReqCreateErrors_Post_Name_Valid,
    RtemsTaskReqCreateErrors_Post_IdVar_Set,
    RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
    RtemsTaskReqCreateErrors_Post_DelExt_No },
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Unsat,
    RtemsTaskReqCreateErrors_Post_Name_Invalid,
    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
    RtemsTaskReqCreateErrors_Post_CreateExt_Yes,
    RtemsTaskReqCreateErrors_Post_DelExt_Yes },
  { 0, 0, 0, 0, 0, 0, 0, 0, RtemsTaskReqCreateErrors_Post_Status_Unsat,
    RtemsTaskReqCreateErrors_Post_Name_Invalid,
    RtemsTaskReqCreateErrors_Post_IdVar_Nop,
    RtemsTaskReqCreateErrors_Post_CreateExt_No,
    RtemsTaskReqCreateErrors_Post_DelExt_No }
};

static const uint8_t
RtemsTaskReqCreateErrors_Map[] = {
  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,
  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,
  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,
  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,
  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,
  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,
  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 RtemsTaskReqCreateErrors_Scope( void *arg, char *buf, size_t n )
{
  RtemsTaskReqCreateErrors_Context *ctx;

  ctx = arg;

  if ( ctx->in_action_loop ) {
    return T_get_scope( RtemsTaskReqCreateErrors_PreDesc, buf, n, ctx->pcs );
  }

  return 0;
}

static T_fixture RtemsTaskReqCreateErrors_Fixture = {
  .setup = RtemsTaskReqCreateErrors_Setup_Wrap,
  .stop = NULL,
  .teardown = RtemsTaskReqCreateErrors_Teardown_Wrap,
  .scope = RtemsTaskReqCreateErrors_Scope,
  .initial_context = &RtemsTaskReqCreateErrors_Instance
};

static inline RtemsTaskReqCreateErrors_Entry RtemsTaskReqCreateErrors_GetEntry(
  size_t index
)
{
  return RtemsTaskReqCreateErrors_Entries[
    RtemsTaskReqCreateErrors_Map[ index ]
  ];
}

/**
 * @fn void T_case_body_RtemsTaskReqCreateErrors( void )
 */
T_TEST_CASE_FIXTURE(
  RtemsTaskReqCreateErrors,
  &RtemsTaskReqCreateErrors_Fixture
)
{
  RtemsTaskReqCreateErrors_Context *ctx;
  RtemsTaskReqCreateErrors_Entry entry;
  size_t index;

  ctx = T_fixture_context();
  ctx->in_action_loop = true;
  index = 0;

  for (
    ctx->pcs[ 0 ] = RtemsTaskReqCreateErrors_Pre_Name_Valid;
    ctx->pcs[ 0 ] < RtemsTaskReqCreateErrors_Pre_Name_NA;
    ++ctx->pcs[ 0 ]
  ) {
    entry = RtemsTaskReqCreateErrors_GetEntry( index );

    if ( entry.Pre_Name_NA ) {
      ctx->pcs[ 0 ] = RtemsTaskReqCreateErrors_Pre_Name_NA;
      index += ( RtemsTaskReqCreateErrors_Pre_Name_NA - 1 )
        * RtemsTaskReqCreateErrors_Pre_Id_NA
        * RtemsTaskReqCreateErrors_Pre_SysTsk_NA
        * RtemsTaskReqCreateErrors_Pre_Prio_NA
        * RtemsTaskReqCreateErrors_Pre_Free_NA
        * RtemsTaskReqCreateErrors_Pre_Stack_NA
        * RtemsTaskReqCreateErrors_Pre_Ext_NA;
    }

    for (
      ctx->pcs[ 1 ] = RtemsTaskReqCreateErrors_Pre_Id_Valid;
      ctx->pcs[ 1 ] < RtemsTaskReqCreateErrors_Pre_Id_NA;
      ++ctx->pcs[ 1 ]
    ) {
      entry = RtemsTaskReqCreateErrors_GetEntry( index );

      if ( entry.Pre_Id_NA ) {
        ctx->pcs[ 1 ] = RtemsTaskReqCreateErrors_Pre_Id_NA;
        index += ( RtemsTaskReqCreateErrors_Pre_Id_NA - 1 )
          * RtemsTaskReqCreateErrors_Pre_SysTsk_NA
          * RtemsTaskReqCreateErrors_Pre_Prio_NA
          * RtemsTaskReqCreateErrors_Pre_Free_NA
          * RtemsTaskReqCreateErrors_Pre_Stack_NA
          * RtemsTaskReqCreateErrors_Pre_Ext_NA;
      }

      for (
        ctx->pcs[ 2 ] = RtemsTaskReqCreateErrors_Pre_SysTsk_Yes;
        ctx->pcs[ 2 ] < RtemsTaskReqCreateErrors_Pre_SysTsk_NA;
        ++ctx->pcs[ 2 ]
      ) {
        entry = RtemsTaskReqCreateErrors_GetEntry( index );

        if ( entry.Pre_SysTsk_NA ) {
          ctx->pcs[ 2 ] = RtemsTaskReqCreateErrors_Pre_SysTsk_NA;
          index += ( RtemsTaskReqCreateErrors_Pre_SysTsk_NA - 1 )
            * RtemsTaskReqCreateErrors_Pre_Prio_NA
            * RtemsTaskReqCreateErrors_Pre_Free_NA
            * RtemsTaskReqCreateErrors_Pre_Stack_NA
            * RtemsTaskReqCreateErrors_Pre_Ext_NA;
        }

        for (
          ctx->pcs[ 3 ] = RtemsTaskReqCreateErrors_Pre_Prio_Valid;
          ctx->pcs[ 3 ] < RtemsTaskReqCreateErrors_Pre_Prio_NA;
          ++ctx->pcs[ 3 ]
        ) {
          entry = RtemsTaskReqCreateErrors_GetEntry( index );

          if ( entry.Pre_Prio_NA ) {
            ctx->pcs[ 3 ] = RtemsTaskReqCreateErrors_Pre_Prio_NA;
            index += ( RtemsTaskReqCreateErrors_Pre_Prio_NA - 1 )
              * RtemsTaskReqCreateErrors_Pre_Free_NA
              * RtemsTaskReqCreateErrors_Pre_Stack_NA
              * RtemsTaskReqCreateErrors_Pre_Ext_NA;
          }

          for (
            ctx->pcs[ 4 ] = RtemsTaskReqCreateErrors_Pre_Free_Yes;
            ctx->pcs[ 4 ] < RtemsTaskReqCreateErrors_Pre_Free_NA;
            ++ctx->pcs[ 4 ]
          ) {
            entry = RtemsTaskReqCreateErrors_GetEntry( index );

            if ( entry.Pre_Free_NA ) {
              ctx->pcs[ 4 ] = RtemsTaskReqCreateErrors_Pre_Free_NA;
              index += ( RtemsTaskReqCreateErrors_Pre_Free_NA - 1 )
                * RtemsTaskReqCreateErrors_Pre_Stack_NA
                * RtemsTaskReqCreateErrors_Pre_Ext_NA;
            }

            for (
              ctx->pcs[ 5 ] = RtemsTaskReqCreateErrors_Pre_Stack_Normal;
              ctx->pcs[ 5 ] < RtemsTaskReqCreateErrors_Pre_Stack_NA;
              ++ctx->pcs[ 5 ]
            ) {
              entry = RtemsTaskReqCreateErrors_GetEntry( index );

              if ( entry.Pre_Stack_NA ) {
                ctx->pcs[ 5 ] = RtemsTaskReqCreateErrors_Pre_Stack_NA;
                index += ( RtemsTaskReqCreateErrors_Pre_Stack_NA - 1 )
                  * RtemsTaskReqCreateErrors_Pre_Ext_NA;
              }

              for (
                ctx->pcs[ 6 ] = RtemsTaskReqCreateErrors_Pre_Ext_Ok;
                ctx->pcs[ 6 ] < RtemsTaskReqCreateErrors_Pre_Ext_NA;
                ++ctx->pcs[ 6 ]
              ) {
                entry = RtemsTaskReqCreateErrors_GetEntry( index );

                if ( entry.Pre_Ext_NA ) {
                  ctx->pcs[ 6 ] = RtemsTaskReqCreateErrors_Pre_Ext_NA;
                  index += ( RtemsTaskReqCreateErrors_Pre_Ext_NA - 1 );
                }

                if ( entry.Skip ) {
                  ++index;
                  continue;
                }

                RtemsTaskReqCreateErrors_Prepare( ctx );
                RtemsTaskReqCreateErrors_Pre_Name_Prepare(
                  ctx,
                  ctx->pcs[ 0 ]
                );
                RtemsTaskReqCreateErrors_Pre_Id_Prepare( ctx, ctx->pcs[ 1 ] );
                RtemsTaskReqCreateErrors_Pre_SysTsk_Prepare(
                  ctx,
                  ctx->pcs[ 2 ]
                );
                RtemsTaskReqCreateErrors_Pre_Prio_Prepare(
                  ctx,
                  ctx->pcs[ 3 ]
                );
                RtemsTaskReqCreateErrors_Pre_Free_Prepare(
                  ctx,
                  ctx->pcs[ 4 ]
                );
                RtemsTaskReqCreateErrors_Pre_Stack_Prepare(
                  ctx,
                  ctx->pcs[ 5 ]
                );
                RtemsTaskReqCreateErrors_Pre_Ext_Prepare( ctx, ctx->pcs[ 6 ] );
                RtemsTaskReqCreateErrors_Action( ctx );
                RtemsTaskReqCreateErrors_Post_Status_Check(
                  ctx,
                  entry.Post_Status
                );
                RtemsTaskReqCreateErrors_Post_Name_Check(
                  ctx,
                  entry.Post_Name
                );
                RtemsTaskReqCreateErrors_Post_IdVar_Check(
                  ctx,
                  entry.Post_IdVar
                );
                RtemsTaskReqCreateErrors_Post_CreateExt_Check(
                  ctx,
                  entry.Post_CreateExt
                );
                RtemsTaskReqCreateErrors_Post_DelExt_Check(
                  ctx,
                  entry.Post_DelExt
                );
                RtemsTaskReqCreateErrors_Cleanup( ctx );
                ++index;
              }
            }
          }
        }
      }
    }
  }
}

/** @} */