source: rtems-central/rtemsspec/tests/test_validation.py @ 9f9917c

Last change on this file since 9f9917c was 9f9917c, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/21 at 15:08:52

validation: Support optional perf measurements

  • Property mode set to 100644
File size: 57.4 KB
Line 
1# SPDX-License-Identifier: BSD-2-Clause
2""" Unit tests for the rtemsspec.validation module. """
3
4# Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26
27import os
28import pytest
29
30from rtemsspec.validation import generate, TransitionMap
31from rtemsspec.items import EmptyItemCache, Item, ItemCache
32from rtemsspec.tests.util import create_item_cache_config_and_copy_spec
33
34
35def test_validation(tmpdir):
36    base_directory = os.path.join(tmpdir, "base")
37    validation_config = {"base-directory": base_directory}
38
39    generate(validation_config, EmptyItemCache())
40
41    item_cache_config = create_item_cache_config_and_copy_spec(
42        tmpdir, "spec-validation", with_spec_types=True)
43    item_cache = ItemCache(item_cache_config)
44
45    transition_map = TransitionMap(item_cache["/directive"])
46    assert transition_map.pre_co_idx_to_co_name(0) == "Name"
47    assert transition_map.post_co_idx_st_idx_to_st_name(0, 0) == "Ok"
48    assert transition_map.post_co_idx_to_co_name(0) == "Status"
49    assert len(list(transition_map.get_variants([]))) == 36
50    assert len(list(transition_map.get_variants(["RTEMS_MULTIPROCESSING"
51                                                 ]))) == 36
52    assert len(list(transition_map.get_post_conditions([]))) == 4
53    assert len(
54        list(transition_map.get_post_conditions(["RTEMS_MULTIPROCESSING"
55                                                 ]))) == 5
56    transition_map = TransitionMap(item_cache["/action2"])
57    assert transition_map.skip_idx_to_name(2) == "SkipReason"
58    assert len(list(transition_map.get_post_conditions(["BOOM"]))) == 6
59    transition_map = TransitionMap(item_cache["/action3"])
60    assert len(list(transition_map.get_post_conditions(["RTEMS_SMP"]))) == 9
61
62    generate(validation_config, item_cache)
63    generate(validation_config, item_cache, ["ts.c"])
64
65    with open(os.path.join(base_directory, "ts.c"), "r") as src:
66        content = """/* SPDX-License-Identifier: BSD-2-Clause */
67
68/**
69 * @file
70 *
71 * @ingroup RTEMSTestSuiteTs
72 */
73
74/*
75 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
76 *
77 * Redistribution and use in source and binary forms, with or without
78 * modification, are permitted provided that the following conditions
79 * are met:
80 * 1. Redistributions of source code must retain the above copyright
81 *    notice, this list of conditions and the following disclaimer.
82 * 2. Redistributions in binary form must reproduce the above copyright
83 *    notice, this list of conditions and the following disclaimer in the
84 *    documentation and/or other materials provided with the distribution.
85 *
86 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
87 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
88 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
89 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
90 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
91 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
92 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
93 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
94 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
95 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
96 * POSSIBILITY OF SUCH DAMAGE.
97 */
98
99/*
100 * This file is part of the RTEMS quality process and was automatically
101 * generated.  If you find something that needs to be fixed or
102 * worded better please post a report or patch to an RTEMS mailing list
103 * or raise a bug report:
104 *
105 * https://www.rtems.org/bugs.html
106 *
107 * For information on updating and regenerating please refer to the How-To
108 * section in the Software Requirements Engineering chapter of the
109 * RTEMS Software Engineering manual.  The manual is provided as a part of
110 * a release.  For development sources please refer to the online
111 * documentation at:
112 *
113 * https://docs.rtems.org
114 */
115
116#ifdef HAVE_CONFIG_H
117#include "config.h"
118#endif
119
120#include <blue.h>
121
122#include "green.h"
123
124#include <rtems/test.h>
125
126/**
127 * @defgroup RTEMSTestSuiteTs spec:/ts
128 *
129 * @ingroup RTEMSTestSuites
130 *
131 * @brief The Blue Green brief description.
132 *
133 * The Blue Green description.
134 *
135 * @{
136 */
137
138/* Blue green code */
139
140/** @} */
141"""
142        assert content == src.read()
143    with open(os.path.join(base_directory, "tc12.c"), "r") as src:
144        content = """/* SPDX-License-Identifier: BSD-2-Clause */
145
146/**
147 * @file
148 *
149 * @ingroup RTEMSTestCaseDirective
150 * @ingroup RTEMSTestCaseTc
151 * @ingroup RTEMSTestCaseTc2
152 */
153
154/*
155 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
156 *
157 * Redistribution and use in source and binary forms, with or without
158 * modification, are permitted provided that the following conditions
159 * are met:
160 * 1. Redistributions of source code must retain the above copyright
161 *    notice, this list of conditions and the following disclaimer.
162 * 2. Redistributions in binary form must reproduce the above copyright
163 *    notice, this list of conditions and the following disclaimer in the
164 *    documentation and/or other materials provided with the distribution.
165 *
166 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
167 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
168 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
169 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
170 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
171 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
172 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
173 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
174 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
175 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
176 * POSSIBILITY OF SUCH DAMAGE.
177 */
178
179/*
180 * This file is part of the RTEMS quality process and was automatically
181 * generated.  If you find something that needs to be fixed or
182 * worded better please post a report or patch to an RTEMS mailing list
183 * or raise a bug report:
184 *
185 * https://www.rtems.org/bugs.html
186 *
187 * For information on updating and regenerating please refer to the How-To
188 * section in the Software Requirements Engineering chapter of the
189 * RTEMS Software Engineering manual.  The manual is provided as a part of
190 * a release.  For development sources please refer to the online
191 * documentation at:
192 *
193 * https://docs.rtems.org
194 */
195
196#ifdef HAVE_CONFIG_H
197#include "config.h"
198#endif
199
200#include <a.h>
201#include <b.h>
202#include <rtems.h>
203
204#include "x.h"
205#include "y.h"
206
207#include <rtems/test.h>
208
209/**
210 * @defgroup RTEMSTestCaseDirective spec:/directive
211 *
212 * @ingroup RTEMSTestSuiteTs
213 *
214 * @brief Test rtems_task_ident() brief description.
215 *
216 * Test rtems_task_ident() description.
217 *
218 * @{
219 */
220
221typedef enum {
222  Directive_Pre_Name_Invalid,
223  Directive_Pre_Name_Self,
224  Directive_Pre_Name_Valid,
225  Directive_Pre_Name_NA
226} Directive_Pre_Name;
227
228typedef enum {
229  Directive_Pre_Node_Local,
230  Directive_Pre_Node_Remote,
231  Directive_Pre_Node_Invalid,
232  Directive_Pre_Node_SearchAll,
233  Directive_Pre_Node_SearchOther,
234  Directive_Pre_Node_SearchLocal,
235  Directive_Pre_Node_NA
236} Directive_Pre_Node;
237
238typedef enum {
239  Directive_Pre_Id_NullPtr,
240  Directive_Pre_Id_Valid,
241  Directive_Pre_Id_NA
242} Directive_Pre_Id;
243
244typedef enum {
245  Directive_Post_Status_Ok,
246  Directive_Post_Status_InvAddr,
247  Directive_Post_Status_InvName,
248  Directive_Post_Status_InvNode,
249  Directive_Post_Status_InvId,
250  Directive_Post_Status_NA
251} Directive_Post_Status;
252
253typedef enum {
254  Directive_Post_Id_Nop,
255  Directive_Post_Id_NullPtr,
256  Directive_Post_Id_Self,
257  Directive_Post_Id_LocalTask,
258  Directive_Post_Id_RemoteTask,
259  Directive_Post_Id_NA
260} Directive_Post_Id;
261
262typedef struct {
263  uint16_t Skip : 1;
264  uint16_t Pre_Name_NA : 1;
265  uint16_t Pre_Node_NA : 1;
266  uint16_t Pre_Id_NA : 1;
267  uint16_t Post_Status : 3;
268  uint16_t Post_Id : 3;
269} Directive_Entry;
270
271/**
272 * @brief Test context for spec:/directive test case.
273 */
274typedef struct {
275  /**
276   * @brief Brief context member description.
277   *
278   * Context member description.
279   */
280  rtems_status_code status;
281
282  rtems_name name;
283
284  uint32_t node;
285
286  rtems_id *id;
287
288  rtems_id id_value;
289
290  rtems_id id_local_task;
291
292  rtems_id id_remote_task;
293
294  struct {
295    /**
296     * @brief This member defines the pre-condition states for the next action.
297     */
298    size_t pcs[ 3 ];
299
300    /**
301     * @brief If this member is true, then the test action loop is executed.
302     */
303    bool in_action_loop;
304
305    /**
306     * @brief This member contains the next transition map index.
307     */
308    size_t index;
309
310    /**
311     * @brief This member contains the current transition map entry.
312     */
313    Directive_Entry entry;
314
315    /**
316     * @brief If this member is true, then the current transition variant
317     *   should be skipped.
318     */
319    bool skip;
320  } Map;
321} Directive_Context;
322
323static Directive_Context
324  Directive_Instance;
325
326static const char * const Directive_PreDesc_Name[] = {
327  "Invalid",
328  "Self",
329  "Valid",
330  "NA"
331};
332
333static const char * const Directive_PreDesc_Node[] = {
334  "Local",
335  "Remote",
336  "Invalid",
337  "SearchAll",
338  "SearchOther",
339  "SearchLocal",
340  "NA"
341};
342
343static const char * const Directive_PreDesc_Id[] = {
344  "NullPtr",
345  "Valid",
346  "NA"
347};
348
349static const char * const * const Directive_PreDesc[] = {
350  Directive_PreDesc_Name,
351  Directive_PreDesc_Node,
352  Directive_PreDesc_Id,
353  NULL
354};
355
356/* Test rtems_task_ident() support */
357
358static void Directive_Pre_Name_Prepare(
359  Directive_Context *ctx,
360  Directive_Pre_Name state
361)
362{
363  /* Prologue */
364
365  switch ( state ) {
366    case Directive_Pre_Name_Invalid: {
367      /*
368       * The name parameter shall not equal to a name of an active Classic API
369       * task object and not equal to RTEMS_SELF.
370       */
371      ctx->name = 1;
372      break;
373    }
374
375    case Directive_Pre_Name_Self: {
376      /*
377       * The name parameter shall be RTEMS_SELF.
378       */
379      ctx->name = RTEMS_SELF;
380      break;
381    }
382
383    case Directive_Pre_Name_Valid: {
384      /*
385       * The name parameter shall equal to a name of an active Classic API task
386       * object.
387       */
388      ctx->name = rtems_build_name( 'T', 'A', 'S', 'K' );
389      break;
390    }
391
392    case Directive_Pre_Name_NA:
393      break;
394  }
395
396  /* Epilogue */
397}
398
399static void Directive_Pre_Node_Prepare(
400  Directive_Context *ctx,
401  Directive_Pre_Node state
402)
403{
404  switch ( state ) {
405    case Directive_Pre_Node_Local: {
406      /*
407       * The node parameter shall be the local node number.
408       */
409      ctx->node = 1;
410      break;
411    }
412
413    case Directive_Pre_Node_Remote: {
414      /*
415       * The node parameter shall be a remote node number.
416       */
417      ctx->node = 2;
418      break;
419    }
420
421    case Directive_Pre_Node_Invalid: {
422      /*
423       * The node parameter shall be an invalid node number.
424       */
425      ctx->node = 256;
426      break;
427    }
428
429    case Directive_Pre_Node_SearchAll: {
430      /*
431       * The node parameter shall be RTEMS_SEARCH_ALL_NODES.
432       */
433      ctx->node = RTEMS_SEARCH_ALL_NODES;
434      break;
435    }
436
437    case Directive_Pre_Node_SearchOther: {
438      /*
439       * The node parameter shall be RTEMS_SEARCH_OTHER_NODES.
440       */
441      ctx->node = RTEMS_SEARCH_OTHER_NODES;
442      break;
443    }
444
445    case Directive_Pre_Node_SearchLocal: {
446      /*
447       * The node parameter shall be RTEMS_SEARCH_LOCAL_NODE.
448       */
449      ctx->node = RTEMS_SEARCH_LOCAL_NODE;
450      break;
451    }
452
453    case Directive_Pre_Node_NA:
454      break;
455  }
456}
457
458static void Directive_Pre_Id_Prepare(
459  Directive_Context *ctx,
460  Directive_Pre_Id   state
461)
462{
463  switch ( state ) {
464    case Directive_Pre_Id_NullPtr: {
465      /*
466       * The id parameter shall be NULL.
467       */
468      ctx->id = NULL;
469      break;
470    }
471
472    case Directive_Pre_Id_Valid: {
473      /*
474       * The id parameter shall point to an object identifier.
475       */
476      ctx->id_value = 0xffffffff;
477      ctx->id = &ctx->id_value;
478      break;
479    }
480
481    case Directive_Pre_Id_NA:
482      break;
483  }
484}
485
486static void Directive_Post_Status_Check(
487  Directive_Context    *ctx,
488  Directive_Post_Status state
489)
490{
491  switch ( state ) {
492    case Directive_Post_Status_Ok: {
493      /*
494       * The status shall be RTEMS_SUCCESSFUL.
495       */
496      T_rsc(ctx->status, RTEMS_SUCCESSFUL);
497      break;
498    }
499
500    case Directive_Post_Status_InvAddr: {
501      /*
502       * The status shall be RTEMS_INVALID_ADDRESS.
503       */
504      T_rsc(ctx->status, RTEMS_INVALID_ADDRESS);
505      break;
506    }
507
508    case Directive_Post_Status_InvName: {
509      /*
510       * The status shall be RTEMS_INVALID_NAME.
511       */
512      T_rsc(ctx->status, RTEMS_INVALID_NAME);
513      break;
514    }
515
516    case Directive_Post_Status_InvNode: {
517      /*
518       * The status shall be RTEMS_INVALID_NODE.
519       */
520      T_rsc(ctx->status, RTEMS_INVALID_NODE);
521      break;
522    }
523
524    case Directive_Post_Status_InvId: {
525      /*
526       * The status shall be RTEMS_INVALID_ID.
527       */
528      T_rsc(ctx->status, RTEMS_INVALID_ID);
529      break;
530    }
531
532    case Directive_Post_Status_NA:
533      break;
534  }
535}
536
537static void Directive_Post_Id_Check(
538  Directive_Context *ctx,
539  Directive_Post_Id  state
540)
541{
542  switch ( state ) {
543    case Directive_Post_Id_Nop: {
544      /*
545       * The value of the object identifier referenced by the id parameter
546       * shall be the value before the call to rtems_task_ident().
547       */
548      T_eq_ptr(ctx->id, &ctx->id_value);
549      T_eq_u32(ctx->id_value, 0xffffffff);
550      break;
551    }
552
553    case Directive_Post_Id_NullPtr: {
554      /*
555       * The id parameter shall be NULL.
556       */
557      T_null(ctx->id)
558      break;
559    }
560
561    case Directive_Post_Id_Self: {
562      /*
563       * The value of the object identifier referenced by the id parameter
564       * shall be the identifier of the executing thread.
565       */
566      T_eq_ptr(ctx->id, &ctx->id_value);
567      T_eq_u32(ctx->id_value, rtems_task_self());
568      break;
569    }
570
571    case Directive_Post_Id_LocalTask: {
572      /*
573       * The value of the object identifier referenced by the id parameter
574       * shall be the identifier of a local task with a name equal to the name
575       * parameter.  If more than one local task with such a name exists, then
576       * it shall be the identifier of the task with the lowest object index.
577       */
578      T_eq_ptr(ctx->id, &ctx->id_value);
579      T_eq_u32(ctx->id_value, ctx->id_local_task);
580      break;
581    }
582
583    case Directive_Post_Id_RemoteTask: {
584      /*
585       * The value of the object identifier referenced by the id parameter
586       * shall be the identifier of a remote task on a eligible node defined by
587       * the node parameter with a name equal to the name parameter.  If more
588       * than one task with such a name exists on the same node, then it shall
589       * be the identifier of the task with the lowest object index.  If more
590       * than one task with such a name exists on different eligible nodes,
591       * then it shall be the identifier of the task with the lowest node
592       * index.
593       */
594      T_eq_ptr(ctx->id, &ctx->id_value);
595      T_eq_u32(ctx->id_value, ctx->id_remote_task);
596      break;
597    }
598
599    case Directive_Post_Id_NA:
600      break;
601  }
602}
603
604/**
605 * @brief Setup brief description.
606 *
607 * Setup description.
608 */
609static void Directive_Setup( Directive_Context *ctx )
610{
611  rtems_status_code sc;
612
613  sc = rtems_task_create(
614    rtems_build_name( 'T', 'A', 'S', 'K' ),
615    1,
616    RTEMS_MINIMUM_STACK_SIZE,
617    RTEMS_DEFAULT_MODES,
618    RTEMS_DEFAULT_ATTRIBUTES,
619    &ctx->id_local_task
620  );
621  T_assert_rsc_success( sc );
622}
623
624static void Directive_Setup_Wrap( void *arg )
625{
626  Directive_Context *ctx;
627
628  ctx = arg;
629  ctx->Map.in_action_loop = false;
630  Directive_Setup( ctx );
631}
632
633static void Directive_Teardown( Directive_Context *ctx )
634{
635  rtems_status_code sc;
636
637  if ( ctx->id_local_task != 0 ) {
638    sc = rtems_task_delete( ctx->id_local_task );
639    T_rsc_success( sc );
640  }
641}
642
643static void Directive_Teardown_Wrap( void *arg )
644{
645  Directive_Context *ctx;
646
647  ctx = arg;
648  ctx->Map.in_action_loop = false;
649  Directive_Teardown( ctx );
650}
651
652static void Directive_Action( Directive_Context *ctx )
653{
654  ctx->status = rtems_task_ident( ctx->name, ctx->node, ctx->id );
655}
656
657static const Directive_Entry
658Directive_Entries[] = {
659  { 0, 0, 0, 0, Directive_Post_Status_InvAddr, Directive_Post_Id_NullPtr },
660  { 0, 0, 0, 0, Directive_Post_Status_InvName, Directive_Post_Id_Nop },
661  { 0, 0, 0, 0, Directive_Post_Status_Ok, Directive_Post_Id_Self },
662  { 0, 0, 0, 0, Directive_Post_Status_Ok, Directive_Post_Id_LocalTask },
663#if defined(RTEMS_MULTIPROCESSING)
664  { 0, 0, 0, 0, Directive_Post_Status_Ok, Directive_Post_Id_RemoteTask }
665#else
666  { 0, 0, 0, 0, Directive_Post_Status_InvName, Directive_Post_Id_Nop }
667#endif
668};
669
670static const uint8_t
671Directive_Map[] = {
672  0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 3,
673  0, 4, 0, 1, 0, 3, 0, 4, 0, 3
674};
675
676static size_t Directive_Scope( void *arg, char *buf, size_t n )
677{
678  Directive_Context *ctx;
679
680  ctx = arg;
681
682  if ( ctx->Map.in_action_loop ) {
683    return T_get_scope( Directive_PreDesc, buf, n, ctx->Map.pcs );
684  }
685
686  return 0;
687}
688
689static T_fixture Directive_Fixture = {
690  .setup = Directive_Setup_Wrap,
691  .stop = NULL,
692  .teardown = Directive_Teardown_Wrap,
693  .scope = Directive_Scope,
694  .initial_context = &Directive_Instance
695};
696
697static inline Directive_Entry Directive_PopEntry( Directive_Context *ctx )
698{
699  size_t index;
700
701  index = ctx->Map.index;
702  ctx->Map.index = index + 1;
703  return Directive_Entries[
704    Directive_Map[ index ]
705  ];
706}
707
708static void Directive_TestVariant( Directive_Context *ctx )
709{
710  Directive_Pre_Name_Prepare( ctx, ctx->Map.pcs[ 0 ] );
711  Directive_Pre_Node_Prepare( ctx, ctx->Map.pcs[ 1 ] );
712  Directive_Pre_Id_Prepare( ctx, ctx->Map.pcs[ 2 ] );
713  Directive_Action( ctx );
714  Directive_Post_Status_Check( ctx, ctx->Map.entry.Post_Status );
715  Directive_Post_Id_Check( ctx, ctx->Map.entry.Post_Id );
716}
717
718/**
719 * @fn void T_case_body_Directive( void )
720 */
721T_TEST_CASE_FIXTURE( Directive, &Directive_Fixture )
722{
723  Directive_Context *ctx;
724
725  ctx = T_fixture_context();
726  ctx->Map.in_action_loop = true;
727  ctx->Map.index = 0;
728
729  for (
730    ctx->Map.pcs[ 0 ] = Directive_Pre_Name_Invalid;
731    ctx->Map.pcs[ 0 ] < Directive_Pre_Name_NA;
732    ++ctx->Map.pcs[ 0 ]
733  ) {
734    for (
735      ctx->Map.pcs[ 1 ] = Directive_Pre_Node_Local;
736      ctx->Map.pcs[ 1 ] < Directive_Pre_Node_NA;
737      ++ctx->Map.pcs[ 1 ]
738    ) {
739      for (
740        ctx->Map.pcs[ 2 ] = Directive_Pre_Id_NullPtr;
741        ctx->Map.pcs[ 2 ] < Directive_Pre_Id_NA;
742        ++ctx->Map.pcs[ 2 ]
743      ) {
744        ctx->Map.entry = Directive_PopEntry( ctx );
745        Directive_TestVariant( ctx );
746      }
747    }
748  }
749}
750
751/** @} */
752
753/**
754 * @defgroup RTEMSTestCaseTc spec:/tc
755 *
756 * @ingroup RTEMSTestSuiteTs
757 *
758 * @brief Test case brief description.
759 *
760 * Test case description.
761 *
762 * This test case performs the following actions:
763 *
764 * - Test case action 0 description.
765 *
766 *   - Test case action 0 check 0 description.
767 *
768 *   - Test case action 0 check 1 description.
769 *
770 * - Test case action 1 description.
771 *
772 *   - Test case action 1 check 0 description.
773 *
774 *   - Test case action 1 check 1 description.
775 *
776 * @{
777 */
778
779/* Test case support code */
780
781/**
782 * @brief Test case action 0 description.
783 */
784static void Tc_Action_0( void )
785{
786  /* Test case action 0 code */
787
788  /*
789   * Test case action 0 check 0 description.
790   */
791  /* Test case action 0 check 0 code: Accounts for 123 test plan steps */
792
793  /*
794   * Test case action 0 check 1 description.
795   */
796  /* Test case action 0 check 1 code; step 123 */
797}
798
799/**
800 * @brief Test case action 1 description.
801 */
802static void Tc_Action_1( void )
803{
804  /* Test case action 1 code */
805
806  /*
807   * Test case action 1 check 0 description.
808   */
809  /* Test case action 1 check 0 code; step 124 */
810
811  /*
812   * Test case action 1 check 1 description.
813   */
814  /* Test case action 1 check 1 code */
815}
816
817/**
818 * @fn void T_case_body_Tc( void )
819 */
820T_TEST_CASE( Tc )
821{
822  T_plan( 125 );
823
824  Tc_Action_0();
825  Tc_Action_1();
826}
827
828/** @} */
829
830/**
831 * @defgroup RTEMSTestCaseTc2 spec:/tc2
832 *
833 * @ingroup RTEMSTestSuiteTs
834 *
835 * @brief Test case 2 brief description.
836 *
837 * Test case 2 description.
838 *
839 * This test case performs the following actions:
840 *
841 * - Test case 2 action 0 description.
842 *
843 *   - Test case 2 action 0 check 0 description.
844 *
845 *   - Test case 2 action 0 check 1 description.
846 *
847 * - Test case 2 action 1 description.
848 *
849 * @{
850 */
851
852/**
853 * @brief Test context for spec:/tc2 test case.
854 */
855typedef struct {
856  /**
857   * @brief Context member brief.
858   *
859   * Context member description.
860   */
861  int member;
862} Tc2_Context;
863
864static Tc2_Context
865  Tc2_Instance;
866
867/**
868 * @brief Setup brief.
869 *
870 * Setup description.
871 */
872static void Tc2_Setup( Tc2_Context *ctx )
873{
874  /* Setup code */
875}
876
877static void Tc2_Setup_Wrap( void *arg )
878{
879  Tc2_Context *ctx;
880
881  ctx = arg;
882  Tc2_Setup( ctx );
883}
884
885static T_fixture Tc2_Fixture = {
886  .setup = Tc2_Setup_Wrap,
887  .stop = NULL,
888  .teardown = NULL,
889  .scope = NULL,
890  .initial_context = &Tc2_Instance
891};
892
893/**
894 * @brief Test case 2 action 0 description.
895 */
896static void Tc2_Action_0( Tc2_Context *ctx )
897{
898  /* Test case 2 action 0 code */
899
900  /*
901   * Test case 2 action 0 check 0 description.
902   */
903  /* Test case 2 action 0 check 0 code */
904
905  /*
906   * Test case 2 action 0 check 1 description.
907   */
908  /* Test case 2 action 0 check 1 code */
909}
910
911/**
912 * @brief Test case 2 action 1 description.
913 */
914static void Tc2_Action_1( Tc2_Context *ctx )
915{
916  /* Test case 2 action 1 code */
917}
918
919/**
920 * @fn void T_case_body_Tc2( void )
921 */
922T_TEST_CASE_FIXTURE( Tc2, &Tc2_Fixture )
923{
924  Tc2_Context *ctx;
925
926  ctx = T_fixture_context();
927
928  Tc2_Action_0( ctx );
929  Tc2_Action_1( ctx );
930}
931
932/** @} */
933"""
934        assert content == src.read()
935    with open(os.path.join(base_directory, "tc34.c"), "r") as src:
936        content = """/* SPDX-License-Identifier: BSD-2-Clause */
937
938/**
939 * @file
940 *
941 * @ingroup RTEMSTestCaseRtm
942 * @ingroup RTEMSTestCaseTc3
943 * @ingroup RTEMSTestCaseTc4
944 * @ingroup RTEMSTestCaseTc5
945 * @ingroup RTEMSTestCaseTc6
946 * @ingroup RTEMSTestCaseTc7
947 * @ingroup RTEMSTestCaseTc8
948 */
949
950/*
951 * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de)
952 *
953 * Redistribution and use in source and binary forms, with or without
954 * modification, are permitted provided that the following conditions
955 * are met:
956 * 1. Redistributions of source code must retain the above copyright
957 *    notice, this list of conditions and the following disclaimer.
958 * 2. Redistributions in binary form must reproduce the above copyright
959 *    notice, this list of conditions and the following disclaimer in the
960 *    documentation and/or other materials provided with the distribution.
961 *
962 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
963 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
964 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
965 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
966 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
967 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
968 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
969 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
970 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
971 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
972 * POSSIBILITY OF SUCH DAMAGE.
973 */
974
975/*
976 * This file is part of the RTEMS quality process and was automatically
977 * generated.  If you find something that needs to be fixed or
978 * worded better please post a report or patch to an RTEMS mailing list
979 * or raise a bug report:
980 *
981 * https://www.rtems.org/bugs.html
982 *
983 * For information on updating and regenerating please refer to the How-To
984 * section in the Software Requirements Engineering chapter of the
985 * RTEMS Software Engineering manual.  The manual is provided as a part of
986 * a release.  For development sources please refer to the online
987 * documentation at:
988 *
989 * https://docs.rtems.org
990 */
991
992#ifdef HAVE_CONFIG_H
993#include "config.h"
994#endif
995
996#include <c.h>
997#include <u.h>
998
999#include "v.h"
1000#include "z.h"
1001
1002#include <rtems/test.h>
1003
1004/**
1005 * @defgroup RTEMSTestCaseRtm spec:/rtm
1006 *
1007 * @ingroup RTEMSTestSuiteTs
1008 *
1009 * @brief Test brief.
1010 *
1011 * Test description.
1012 *
1013 * @{
1014 */
1015
1016/* Context support code */
1017
1018/**
1019 * @brief Test context for spec:/rtm test case.
1020 */
1021typedef struct {
1022  /**
1023   * @brief Context member brief.
1024   *
1025   * Context member description.
1026   */
1027  int member;
1028
1029  /**
1030   * @brief This member references the measure runtime context.
1031   */
1032  T_measure_runtime_context *context;
1033
1034  /**
1035   * @brief This member provides the measure runtime request.
1036   */
1037  T_measure_runtime_request request;
1038
1039  /**
1040   * @brief This member provides an optional measurement begin time point.
1041   */
1042  T_ticks begin;
1043
1044  /**
1045   * @brief This member provides an optional measurement end time point.
1046   */
1047  T_ticks end;
1048} Rtm_Context;
1049
1050static Rtm_Context
1051  Rtm_Instance;
1052
1053/* Support code */
1054
1055static void Rtm_Setup_Context( Rtm_Context *ctx )
1056{
1057  T_measure_runtime_config config;
1058
1059  memset( &config, 0, sizeof( config ) );
1060  config.sample_count = 100;
1061  ctx->request.arg = ctx;
1062  ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES;
1063  ctx->context = T_measure_runtime_create( &config );
1064  T_assert_not_null( ctx->context );
1065}
1066
1067static void Rtm_Setup_Wrap( void *arg )
1068{
1069  Rtm_Context *ctx;
1070
1071  ctx = arg;
1072  Rtm_Setup_Context( ctx );
1073}
1074
1075/**
1076 * @brief Stop brief.
1077 *
1078 * Stop description.
1079 */
1080static void Rtm_Stop( Rtm_Context *ctx )
1081{
1082  /* Stop code */
1083}
1084
1085static void Rtm_Stop_Wrap( void *arg )
1086{
1087  Rtm_Context *ctx;
1088
1089  ctx = arg;
1090  Rtm_Stop( ctx );
1091}
1092
1093/**
1094 * @brief Teardown brief.
1095 *
1096 * Teardown description.
1097 */
1098static void Rtm_Teardown( Rtm_Context *ctx )
1099{
1100  /* Teardown code */
1101}
1102
1103static void Rtm_Teardown_Wrap( void *arg )
1104{
1105  Rtm_Context *ctx;
1106
1107  ctx = arg;
1108  Rtm_Teardown( ctx );
1109}
1110
1111static T_fixture Rtm_Fixture = {
1112  .setup = Rtm_Setup_Wrap,
1113  .stop = Rtm_Stop_Wrap,
1114  .teardown = Rtm_Teardown_Wrap,
1115  .scope = NULL,
1116  .initial_context = &Rtm_Instance
1117};
1118
1119/**
1120 * @brief Cleanup brief.
1121 *
1122 * Cleanup description.
1123 */
1124static void Rtm_Cleanup( Rtm_Context *ctx )
1125{
1126  /* Cleanup code */
1127}
1128
1129/**
1130 * @brief Body brief.
1131 *
1132 * Body description.
1133 */
1134static void Rpr_Body( Rtm_Context *ctx )
1135{
1136  /* Body code */
1137}
1138
1139static void Rpr_Body_Wrap( void *arg )
1140{
1141  Rtm_Context *ctx;
1142
1143  ctx = arg;
1144  Rpr_Body( ctx );
1145}
1146
1147/**
1148 * @brief Teardown brief.
1149 *
1150 * Teardown description.
1151 */
1152static bool Rpr_Teardown(
1153  Rtm_Context *ctx,
1154  T_ticks     *delta,
1155  uint32_t     tic,
1156  uint32_t     toc,
1157  unsigned int retry
1158)
1159{
1160  /* Teardown code */
1161}
1162
1163static bool Rpr_Teardown_Wrap(
1164  void        *arg,
1165  T_ticks     *delta,
1166  uint32_t     tic,
1167  uint32_t     toc,
1168  unsigned int retry
1169)
1170{
1171  Rtm_Context *ctx;
1172
1173  ctx = arg;
1174  return Rpr_Teardown( ctx, delta, tic, toc, retry );
1175}
1176
1177/**
1178 * @brief Cleanup brief.
1179 *
1180 * Cleanup description.
1181 */
1182static void Rpr_Cleanup( Rtm_Context *ctx )
1183{
1184  /* Cleanup code */
1185}
1186
1187#if defined(FOOBAR)
1188/**
1189 * @brief Body brief.
1190 *
1191 * Body description.
1192 */
1193static void Rpr2_Body( Rtm_Context *ctx )
1194{
1195  /* Body code */
1196}
1197
1198static void Rpr2_Body_Wrap( void *arg )
1199{
1200  Rtm_Context *ctx;
1201
1202  ctx = arg;
1203  Rpr2_Body( ctx );
1204}
1205#endif
1206
1207/**
1208 * @fn void T_case_body_Rtm( void )
1209 */
1210T_TEST_CASE_FIXTURE( Rtm, &Rtm_Fixture )
1211{
1212  Rtm_Context *ctx;
1213
1214  ctx = T_fixture_context();
1215
1216  ctx->request.name = "Rpr";
1217  ctx->request.setup = NULL;
1218  ctx->request.body = Rpr_Body_Wrap;
1219  ctx->request.teardown = Rpr_Teardown_Wrap;
1220  T_measure_runtime( ctx->context, &ctx->request );
1221  Rpr_Cleanup( ctx );
1222  Rtm_Cleanup( ctx );
1223
1224  #if defined(FOOBAR)
1225  ctx->request.name = "Rpr2";
1226  ctx->request.setup = NULL;
1227  ctx->request.body = Rpr2_Body_Wrap;
1228  ctx->request.teardown = NULL;
1229  T_measure_runtime( ctx->context, &ctx->request );
1230  Rtm_Cleanup( ctx );
1231  #endif
1232}
1233
1234/** @} */
1235
1236/**
1237 * @defgroup RTEMSTestCaseTc3 spec:/tc3
1238 *
1239 * @ingroup RTEMSTestSuiteTs
1240 *
1241 * @brief Test case 3 brief description.
1242 *
1243 * Test case 3 description.
1244 *
1245 * This test case performs the following actions:
1246 *
1247 * - Test case 3 action 0 description.
1248 *
1249 *   - Test case 3 action 0 check 0 description.
1250 *
1251 * @{
1252 */
1253
1254/**
1255 * @brief Test case 3 action 0 description.
1256 */
1257static void Tc3_Action_0( void )
1258{
1259  /* Test case 3 action 0 code */
1260
1261  /*
1262   * Test case 3 action 0 check 0 description.
1263   */
1264  /* Test case 3 action 0 check 0 code; step 0 */
1265}
1266
1267/**
1268 * @fn void T_case_body_Tc3( void )
1269 */
1270T_TEST_CASE( Tc3 )
1271{
1272  T_plan( 1 );
1273
1274  Tc3_Action_0();
1275}
1276
1277/** @} */
1278
1279/**
1280 * @defgroup RTEMSTestCaseTc4 spec:/tc4
1281 *
1282 * @ingroup RTEMSTestSuiteTs
1283 *
1284 * @brief Test case 4 brief description.
1285 *
1286 * Test case 4 description.
1287 *
1288 * @{
1289 */
1290
1291/**
1292 * @fn void T_case_body_Tc4( void )
1293 */
1294T_TEST_CASE( Tc4 )
1295{
1296}
1297
1298/** @} */
1299
1300/**
1301 * @defgroup RTEMSTestCaseTc5 spec:/tc5
1302 *
1303 * @ingroup RTEMSTestSuiteTs
1304 *
1305 * @brief Test case 5 brief description.
1306 *
1307 * Test case 5 description.
1308 *
1309 * This test case performs the following actions:
1310 *
1311 * - Test case action 0 description.
1312 *
1313 *   - Test case action 0 check 0 description.
1314 *
1315 *   - Test case action 0 check 1 description.
1316 *
1317 * - Test case action 1 description.
1318 *
1319 *   - Test case action 1 check 0 description.
1320 *
1321 *   - Test case action 1 check 1 description.
1322 *
1323 * @{
1324 */
1325
1326/**
1327 * @brief Test context for spec:/tc5 test case.
1328 */
1329typedef struct {
1330  /**
1331   * @brief This member contains a copy of the corresponding Tc5_Run()
1332   *   parameter.
1333   */
1334  int *a;
1335
1336  /**
1337   * @brief This member contains a copy of the corresponding Tc5_Run()
1338   *   parameter.
1339   */
1340  int b;
1341
1342  /**
1343   * @brief This member contains a copy of the corresponding Tc5_Run()
1344   *   parameter.
1345   */
1346  int *c;
1347} Tc5_Context;
1348
1349static Tc5_Context
1350  Tc5_Instance;
1351
1352static T_fixture Tc5_Fixture = {
1353  .setup = NULL,
1354  .stop = NULL,
1355  .teardown = NULL,
1356  .scope = NULL,
1357  .initial_context = &Tc5_Instance
1358};
1359
1360/**
1361 * @brief Test case action 0 description.
1362 */
1363static void Tc5_Action_0( Tc5_Context *ctx )
1364{
1365  /* Test case action 0 code */
1366
1367  /*
1368   * Test case action 0 check 0 description.
1369   */
1370  /* Test case action 0 check 0 code */
1371
1372  /*
1373   * Test case action 0 check 1 description.
1374   */
1375  /* Test case action 0 check 1 code; step 0 */
1376}
1377
1378/**
1379 * @brief Test case action 1 description.
1380 */
1381static void Tc5_Action_1( Tc5_Context *ctx )
1382{
1383  /* Test case action 1 code */
1384
1385  /*
1386   * Test case action 1 check 0 description.
1387   */
1388  /* Test case action 1 check 0 code; step 1 */
1389
1390  /*
1391   * Test case action 1 check 1 description.
1392   */
1393  /* Test case action 1 check 1 code */
1394}
1395
1396void Tc5_Run( int *a, int b, int *c )
1397{
1398  Tc5_Context *ctx;
1399
1400  ctx = &Tc5_Instance;
1401  ctx->a = a;
1402  ctx->b = b;
1403  ctx->c = c;
1404
1405  ctx = T_case_begin( "Tc5", &Tc5_Fixture );
1406
1407  T_plan( 2 );
1408
1409  Tc5_Action_0( ctx );
1410  Tc5_Action_1( ctx );
1411
1412  T_case_end();
1413}
1414
1415/** @} */
1416
1417/**
1418 * @defgroup RTEMSTestCaseTc6 spec:/tc6
1419 *
1420 * @ingroup RTEMSTestSuiteTs
1421 *
1422 * @{
1423 */
1424
1425void Tc6_Run( void )
1426{
1427}
1428
1429/** @} */
1430
1431/**
1432 * @defgroup RTEMSTestCaseTc7 spec:/tc7
1433 *
1434 * @ingroup RTEMSTestSuiteTs
1435 *
1436 * This test case performs the following actions:
1437 *
1438 * - Action.
1439 *
1440 * @{
1441 */
1442
1443/**
1444 * @brief Action.
1445 */
1446static void Tc7_Action_0( void )
1447{
1448  /* 0 */
1449}
1450
1451static T_fixture_node Tc7_Node;
1452
1453void Tc7_Run( void )
1454{
1455  T_push_fixture( &Tc7_Node, &T_empty_fixture );
1456
1457  T_plan( 1 );
1458
1459  Tc7_Action_0();
1460
1461  T_pop_fixture();
1462}
1463
1464/** @} */
1465
1466/**
1467 * @defgroup RTEMSTestCaseTc8 spec:/tc8
1468 *
1469 * @ingroup RTEMSTestSuiteTs
1470 *
1471 * This test case performs the following actions:
1472 *
1473 * - Action.
1474 *
1475 * @{
1476 */
1477
1478/**
1479 * @brief Test context for spec:/tc8 test case.
1480 */
1481typedef struct {
1482  int member;
1483} Tc8_Context;
1484
1485static Tc8_Context
1486  Tc8_Instance;
1487
1488static T_fixture Tc8_Fixture = {
1489  .setup = NULL,
1490  .stop = NULL,
1491  .teardown = NULL,
1492  .scope = NULL,
1493  .initial_context = &Tc8_Instance
1494};
1495
1496/**
1497 * @brief Action.
1498 */
1499static void Tc8_Action_0( Tc8_Context *ctx )
1500{
1501  /* 0 */
1502}
1503
1504static T_fixture_node Tc8_Node;
1505
1506void Tc8_Run( void )
1507{
1508  Tc8_Context *ctx;
1509
1510  ctx = T_push_fixture( &Tc8_Node, &Tc8_Fixture );
1511
1512  T_plan( 1 );
1513
1514  Tc8_Action_0( ctx );
1515
1516  T_pop_fixture();
1517}
1518
1519/** @} */
1520"""
1521        assert content == src.read()
1522    with open(os.path.join(base_directory, "tc5.h"), "r") as src:
1523        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1524
1525/**
1526 * @file
1527 *
1528 * @ingroup RTEMSTestCaseTc5
1529 */
1530
1531/*
1532 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1533 *
1534 * Redistribution and use in source and binary forms, with or without
1535 * modification, are permitted provided that the following conditions
1536 * are met:
1537 * 1. Redistributions of source code must retain the above copyright
1538 *    notice, this list of conditions and the following disclaimer.
1539 * 2. Redistributions in binary form must reproduce the above copyright
1540 *    notice, this list of conditions and the following disclaimer in the
1541 *    documentation and/or other materials provided with the distribution.
1542 *
1543 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1544 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1545 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1546 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1547 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1548 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1549 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1550 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1551 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1552 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1553 * POSSIBILITY OF SUCH DAMAGE.
1554 */
1555
1556/*
1557 * This file is part of the RTEMS quality process and was automatically
1558 * generated.  If you find something that needs to be fixed or
1559 * worded better please post a report or patch to an RTEMS mailing list
1560 * or raise a bug report:
1561 *
1562 * https://www.rtems.org/bugs.html
1563 *
1564 * For information on updating and regenerating please refer to the How-To
1565 * section in the Software Requirements Engineering chapter of the
1566 * RTEMS Software Engineering manual.  The manual is provided as a part of
1567 * a release.  For development sources please refer to the online
1568 * documentation at:
1569 *
1570 * https://docs.rtems.org
1571 */
1572
1573#ifndef _TC5_H
1574#define _TC5_H
1575
1576#include <d.h>
1577
1578#include "e.h"
1579
1580#ifdef __cplusplus
1581extern "C" {
1582#endif
1583
1584/**
1585 * @addtogroup RTEMSTestCaseTc5
1586 *
1587 * @{
1588 */
1589
1590/* Header code for Tc5_Run() */
1591
1592/**
1593 * @brief Runs the parameterized test case.
1594 *
1595 * @param[in] a Parameter A description.
1596 *
1597 * @param b Parameter B description.
1598 *
1599 * @param[out] c Parameter C description.
1600 */
1601void Tc5_Run( int *a, int b, int *c );
1602
1603/** @} */
1604
1605#ifdef __cplusplus
1606}
1607#endif
1608
1609#endif /* _TC5_H */
1610"""
1611        assert content == src.read()
1612    with open(os.path.join(base_directory, "tc6.h"), "r") as src:
1613        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1614
1615/**
1616 * @file
1617 *
1618 * @ingroup RTEMSTestCaseTc6
1619 */
1620
1621/*
1622 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1623 *
1624 * Redistribution and use in source and binary forms, with or without
1625 * modification, are permitted provided that the following conditions
1626 * are met:
1627 * 1. Redistributions of source code must retain the above copyright
1628 *    notice, this list of conditions and the following disclaimer.
1629 * 2. Redistributions in binary form must reproduce the above copyright
1630 *    notice, this list of conditions and the following disclaimer in the
1631 *    documentation and/or other materials provided with the distribution.
1632 *
1633 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1634 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1635 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1636 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1637 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1638 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1639 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1640 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1641 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1642 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1643 * POSSIBILITY OF SUCH DAMAGE.
1644 */
1645
1646/*
1647 * This file is part of the RTEMS quality process and was automatically
1648 * generated.  If you find something that needs to be fixed or
1649 * worded better please post a report or patch to an RTEMS mailing list
1650 * or raise a bug report:
1651 *
1652 * https://www.rtems.org/bugs.html
1653 *
1654 * For information on updating and regenerating please refer to the How-To
1655 * section in the Software Requirements Engineering chapter of the
1656 * RTEMS Software Engineering manual.  The manual is provided as a part of
1657 * a release.  For development sources please refer to the online
1658 * documentation at:
1659 *
1660 * https://docs.rtems.org
1661 */
1662
1663#ifndef _TC6_H
1664#define _TC6_H
1665
1666#ifdef __cplusplus
1667extern "C" {
1668#endif
1669
1670/**
1671 * @addtogroup RTEMSTestCaseTc6
1672 *
1673 * @{
1674 */
1675
1676/**
1677 * @brief Runs the parameterized test case.
1678 */
1679void Tc6_Run( void );
1680
1681/** @} */
1682
1683#ifdef __cplusplus
1684}
1685#endif
1686
1687#endif /* _TC6_H */
1688"""
1689        assert content == src.read()
1690    with open(os.path.join(base_directory, "action2.h"), "r") as src:
1691        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1692
1693/**
1694 * @file
1695 *
1696 * @ingroup RTEMSTestCaseAction2
1697 */
1698
1699/*
1700 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1701 *
1702 * Redistribution and use in source and binary forms, with or without
1703 * modification, are permitted provided that the following conditions
1704 * are met:
1705 * 1. Redistributions of source code must retain the above copyright
1706 *    notice, this list of conditions and the following disclaimer.
1707 * 2. Redistributions in binary form must reproduce the above copyright
1708 *    notice, this list of conditions and the following disclaimer in the
1709 *    documentation and/or other materials provided with the distribution.
1710 *
1711 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1712 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1713 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1714 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1715 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1716 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1717 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1718 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1719 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1720 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1721 * POSSIBILITY OF SUCH DAMAGE.
1722 */
1723
1724/*
1725 * This file is part of the RTEMS quality process and was automatically
1726 * generated.  If you find something that needs to be fixed or
1727 * worded better please post a report or patch to an RTEMS mailing list
1728 * or raise a bug report:
1729 *
1730 * https://www.rtems.org/bugs.html
1731 *
1732 * For information on updating and regenerating please refer to the How-To
1733 * section in the Software Requirements Engineering chapter of the
1734 * RTEMS Software Engineering manual.  The manual is provided as a part of
1735 * a release.  For development sources please refer to the online
1736 * documentation at:
1737 *
1738 * https://docs.rtems.org
1739 */
1740
1741#ifndef _ACTION2_H
1742#define _ACTION2_H
1743
1744#include <d.h>
1745
1746#include "e.h"
1747
1748#ifdef __cplusplus
1749extern "C" {
1750#endif
1751
1752/**
1753 * @addtogroup RTEMSTestCaseAction2
1754 *
1755 * @{
1756 */
1757
1758typedef enum {
1759  Action2_Pre_A_A0,
1760  Action2_Pre_A_A1,
1761  Action2_Pre_A_NA
1762} Action2_Pre_A;
1763
1764typedef enum {
1765  Action2_Pre_B_B0,
1766  Action2_Pre_B_B1,
1767  Action2_Pre_B_B2,
1768  Action2_Pre_B_NA
1769} Action2_Pre_B;
1770
1771typedef enum {
1772  Action2_Pre_C_C0,
1773  Action2_Pre_C_C1,
1774  Action2_Pre_C_C2,
1775  Action2_Pre_C_NA
1776} Action2_Pre_C;
1777
1778typedef enum {
1779  Action2_Post_A_A0,
1780  Action2_Post_A_A1,
1781  Action2_Post_A_A2,
1782  Action2_Post_A_A3,
1783  Action2_Post_A_NA
1784} Action2_Post_A;
1785
1786typedef enum {
1787  Action2_Post_B_B0,
1788  Action2_Post_B_B1,
1789  Action2_Post_B_B2,
1790  Action2_Post_B_NA
1791} Action2_Post_B;
1792
1793/* Header code for Action 2 with Action2_Run() */
1794
1795/**
1796 * @brief Runs the parameterized test case.
1797 *
1798 * @param[in] a Parameter A description.
1799 *
1800 * @param b Parameter B description.
1801 *
1802 * @param[out] c Parameter C description.
1803 */
1804void Action2_Run( int *a, int b, int *c );
1805
1806/** @} */
1807
1808#ifdef __cplusplus
1809}
1810#endif
1811
1812#endif /* _ACTION2_H */
1813"""
1814        assert content == src.read()
1815    with open(os.path.join(base_directory, "action2.c"), "r") as src:
1816        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1817
1818/**
1819 * @file
1820 *
1821 * @ingroup RTEMSTestCaseAction2
1822 */
1823
1824/*
1825 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1826 *
1827 * Redistribution and use in source and binary forms, with or without
1828 * modification, are permitted provided that the following conditions
1829 * are met:
1830 * 1. Redistributions of source code must retain the above copyright
1831 *    notice, this list of conditions and the following disclaimer.
1832 * 2. Redistributions in binary form must reproduce the above copyright
1833 *    notice, this list of conditions and the following disclaimer in the
1834 *    documentation and/or other materials provided with the distribution.
1835 *
1836 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1837 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1838 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1839 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1840 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1841 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1842 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1843 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1844 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1845 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1846 * POSSIBILITY OF SUCH DAMAGE.
1847 */
1848
1849/*
1850 * This file is part of the RTEMS quality process and was automatically
1851 * generated.  If you find something that needs to be fixed or
1852 * worded better please post a report or patch to an RTEMS mailing list
1853 * or raise a bug report:
1854 *
1855 * https://www.rtems.org/bugs.html
1856 *
1857 * For information on updating and regenerating please refer to the How-To
1858 * section in the Software Requirements Engineering chapter of the
1859 * RTEMS Software Engineering manual.  The manual is provided as a part of
1860 * a release.  For development sources please refer to the online
1861 * documentation at:
1862 *
1863 * https://docs.rtems.org
1864 */
1865
1866#ifdef HAVE_CONFIG_H
1867#include "config.h"
1868#endif
1869
1870#include <a.h>
1871
1872#include "b.h"
1873
1874#include <rtems/test.h>
1875
1876/**
1877 * @defgroup RTEMSTestCaseAction2 spec:/action2
1878 *
1879 * @ingroup RTEMSTestSuiteTs
1880 *
1881 * @brief Test brief.
1882 *
1883 * Test description.
1884 *
1885 * @{
1886 */
1887
1888typedef struct {
1889  uint16_t Skip : 1;
1890  uint16_t Pre_A_NA : 1;
1891  uint16_t Pre_B_NA : 1;
1892  uint16_t Pre_C_NA : 1;
1893  uint16_t Post_A : 3;
1894  uint16_t Post_B : 2;
1895} Action2_Entry;
1896
1897/* Context support code */
1898
1899/**
1900 * @brief Test context for spec:/action2 test case.
1901 */
1902typedef struct {
1903  /**
1904   * @brief Context member brief.
1905   *
1906   * Context member description.
1907   */
1908  int member;
1909
1910  /**
1911   * @brief This member contains a copy of the corresponding Action2_Run()
1912   *   parameter.
1913   */
1914  int *a;
1915
1916  /**
1917   * @brief This member contains a copy of the corresponding Action2_Run()
1918   *   parameter.
1919   */
1920  int b;
1921
1922  /**
1923   * @brief This member contains a copy of the corresponding Action2_Run()
1924   *   parameter.
1925   */
1926  int *c;
1927
1928  struct {
1929    /**
1930     * @brief This member defines the pre-condition indices for the next
1931     *   action.
1932     */
1933    size_t pci[ 3 ];
1934
1935    /**
1936     * @brief This member defines the pre-condition states for the next action.
1937     */
1938    size_t pcs[ 3 ];
1939
1940    /**
1941     * @brief If this member is true, then the test action loop is executed.
1942     */
1943    bool in_action_loop;
1944
1945    /**
1946     * @brief This member contains the next transition map index.
1947     */
1948    size_t index;
1949
1950    /**
1951     * @brief This member contains the current transition map entry.
1952     */
1953    Action2_Entry entry;
1954
1955    /**
1956     * @brief If this member is true, then the current transition variant
1957     *   should be skipped.
1958     */
1959    bool skip;
1960  } Map;
1961} Action2_Context;
1962
1963static Action2_Context
1964  Action2_Instance;
1965
1966static const char * const Action2_PreDesc_A[] = {
1967  "A0",
1968  "A1",
1969  "NA"
1970};
1971
1972static const char * const Action2_PreDesc_B[] = {
1973  "B0",
1974  "B1",
1975  "B2",
1976  "NA"
1977};
1978
1979static const char * const Action2_PreDesc_C[] = {
1980  "C0",
1981  "C1",
1982  "C2",
1983  "NA"
1984};
1985
1986static const char * const * const Action2_PreDesc[] = {
1987  Action2_PreDesc_A,
1988  Action2_PreDesc_B,
1989  Action2_PreDesc_C,
1990  NULL
1991};
1992
1993/* Support code */
1994Action2_Context *instance = &Action2_Instance;
1995
1996static void Action2_Pre_A_Prepare( Action2_Context *ctx, Action2_Pre_A state )
1997{
1998  /* Pre A prologue. */
1999
2000  switch ( state ) {
2001    case Action2_Pre_A_A0: {
2002      /*
2003       * Pre A 0.
2004       */
2005      /* Pre A 0 */
2006      break;
2007    }
2008
2009    case Action2_Pre_A_A1: {
2010      /*
2011       * Pre A 1.
2012       */
2013      /* Pre A 1 */
2014      ctx->Map.skip = true;
2015      break;
2016    }
2017
2018    case Action2_Pre_A_NA:
2019      break;
2020  }
2021
2022  /* Pre A epilogue. */
2023}
2024
2025static void Action2_Pre_B_Prepare( Action2_Context *ctx, Action2_Pre_B state )
2026{
2027  /* Pre B prologue. */
2028
2029  switch ( state ) {
2030    case Action2_Pre_B_B0: {
2031      /*
2032       * Pre B 0.
2033       */
2034      /* Pre B 0 */
2035      break;
2036    }
2037
2038    case Action2_Pre_B_B1: {
2039      /*
2040       * Pre B 1.
2041       */
2042      /* Pre B 1 */
2043      break;
2044    }
2045
2046    case Action2_Pre_B_B2: {
2047      /*
2048       * Pre B 1.
2049       */
2050      /* Pre B 1 */
2051      break;
2052    }
2053
2054    case Action2_Pre_B_NA:
2055      break;
2056  }
2057
2058  /* Pre B epilogue. */
2059}
2060
2061static void Action2_Pre_C_Prepare( Action2_Context *ctx, Action2_Pre_C state )
2062{
2063  /* Pre C prologue. */
2064
2065  switch ( state ) {
2066    case Action2_Pre_C_C0: {
2067      /*
2068       * Pre C 0.
2069       */
2070      /* Pre C 0 */
2071      break;
2072    }
2073
2074    case Action2_Pre_C_C1: {
2075      /*
2076       * Pre C 1.
2077       */
2078      /* Pre B 1 */
2079      break;
2080    }
2081
2082    case Action2_Pre_C_C2: {
2083      /*
2084       * Pre C 2.
2085       */
2086      /* Pre C 2 */
2087      break;
2088    }
2089
2090    case Action2_Pre_C_NA:
2091      break;
2092  }
2093
2094  /* Pre C epilogue. */
2095}
2096
2097static void Action2_Post_A_Check( Action2_Context *ctx, Action2_Post_A state )
2098{
2099  /* Post A prologue. */
2100
2101  switch ( state ) {
2102    case Action2_Post_A_A0: {
2103      /*
2104       * Post A 0.
2105       */
2106      /* Post A 0 */
2107      break;
2108    }
2109
2110    case Action2_Post_A_A1: {
2111      /*
2112       * Post A 1.
2113       */
2114      /* Post A 1 */
2115      break;
2116    }
2117
2118    case Action2_Post_A_A2: {
2119      /*
2120       * Post A 2.
2121       */
2122      /* Post A 2 */
2123      break;
2124    }
2125
2126    case Action2_Post_A_A3: {
2127      /*
2128       * Post A 3.
2129       */
2130      /* Post A 3 */
2131      break;
2132    }
2133
2134    case Action2_Post_A_NA:
2135      break;
2136  }
2137
2138  /* Post A epilogue. */
2139}
2140
2141static void Action2_Post_B_Check( Action2_Context *ctx, Action2_Post_B state )
2142{
2143  /* Post B prologue. */
2144
2145  switch ( state ) {
2146    case Action2_Post_B_B0: {
2147      /*
2148       * Post B 0.
2149       */
2150      /* Post B 0 */
2151      break;
2152    }
2153
2154    case Action2_Post_B_B1: {
2155      /*
2156       * Post B 1.
2157       */
2158      /* Post B 1 */
2159      break;
2160    }
2161
2162    case Action2_Post_B_B2: {
2163      /*
2164       * Post B 2.
2165       */
2166      /* Post B 2 */
2167      break;
2168    }
2169
2170    case Action2_Post_B_NA:
2171      break;
2172  }
2173
2174  /* Post B epilogue. */
2175}
2176
2177/**
2178 * @brief Setup brief.
2179 *
2180 * Setup description.
2181 */
2182static void Action2_Setup( Action2_Context *ctx )
2183{
2184  /* Setup code */
2185}
2186
2187static void Action2_Setup_Wrap( void *arg )
2188{
2189  Action2_Context *ctx;
2190
2191  ctx = arg;
2192  ctx->Map.in_action_loop = false;
2193  Action2_Setup( ctx );
2194}
2195
2196/**
2197 * @brief Teardown brief.
2198 *
2199 * Teardown description.
2200 */
2201static void Action2_Teardown( Action2_Context *ctx )
2202{
2203  /* Teardown code */
2204}
2205
2206static void Action2_Teardown_Wrap( void *arg )
2207{
2208  Action2_Context *ctx;
2209
2210  ctx = arg;
2211  ctx->Map.in_action_loop = false;
2212  Action2_Teardown( ctx );
2213}
2214
2215static void Action2_Prepare( Action2_Context *ctx )
2216{
2217  /* Prepare */
2218}
2219
2220static void Action2_Action( Action2_Context *ctx )
2221{
2222  /* Action */
2223}
2224
2225static void Action2_Cleanup( Action2_Context *ctx )
2226{
2227  /* Cleanup */
2228}
2229
2230static const Action2_Entry
2231Action2_Entries[] = {
2232  { 0, 1, 0, 0, Action2_Post_A_A1, Action2_Post_B_NA },
2233  { 0, 0, 0, 0, Action2_Post_A_A2, Action2_Post_B_B0 },
2234  { 1, 0, 0, 0, Action2_Post_A_NA, Action2_Post_B_NA },
2235  { 0, 0, 0, 0, Action2_Post_A_A1, Action2_Post_B_B0 },
2236#if defined(BOOM)
2237  { 0, 1, 0, 0, Action2_Post_A_NA, Action2_Post_B_B0 },
2238#else
2239  { 0, 0, 0, 0, Action2_Post_A_A1, Action2_Post_B_B0 },
2240#endif
2241#if defined(BOOM)
2242  { 0, 1, 0, 0, Action2_Post_A_NA, Action2_Post_B_B0 },
2243#else
2244  { 0, 0, 0, 0, Action2_Post_A_A2, Action2_Post_B_B0 },
2245#endif
2246  { 0, 0, 0, 0, Action2_Post_A_A3, Action2_Post_B_B0 }
2247};
2248
2249static const uint8_t
2250Action2_Map[] = {
2251  4, 3, 3, 0, 0, 0, 1, 1, 1, 5, 1, 6, 0, 0, 0, 2, 2, 2
2252};
2253
2254static size_t Action2_Scope( void *arg, char *buf, size_t n )
2255{
2256  Action2_Context *ctx;
2257
2258  ctx = arg;
2259
2260  if ( ctx->Map.in_action_loop ) {
2261    return T_get_scope( Action2_PreDesc, buf, n, ctx->Map.pcs );
2262  }
2263
2264  return 0;
2265}
2266
2267static T_fixture Action2_Fixture = {
2268  .setup = Action2_Setup_Wrap,
2269  .stop = NULL,
2270  .teardown = Action2_Teardown_Wrap,
2271  .scope = Action2_Scope,
2272  .initial_context = &Action2_Instance
2273};
2274
2275static const uint8_t Action2_Weights[] = {
2276  9, 3, 1
2277};
2278
2279static void Action2_Skip( Action2_Context *ctx, size_t index )
2280{
2281  switch ( index + 1 ) {
2282    case 1:
2283      ctx->Map.pci[ 1 ] = Action2_Pre_B_NA - 1;
2284      /* Fall through */
2285    case 2:
2286      ctx->Map.pci[ 2 ] = Action2_Pre_C_NA - 1;
2287      break;
2288  }
2289}
2290
2291static inline Action2_Entry Action2_PopEntry( Action2_Context *ctx )
2292{
2293  size_t index;
2294
2295  if ( ctx->Map.skip ) {
2296    size_t i;
2297
2298    ctx->Map.skip = false;
2299    index = 0;
2300
2301    for ( i = 0; i < 3; ++i ) {
2302      index += Action2_Weights[ i ] * ctx->Map.pci[ i ];
2303    }
2304  } else {
2305    index = ctx->Map.index;
2306  }
2307
2308  ctx->Map.index = index + 1;
2309
2310  return Action2_Entries[
2311    Action2_Map[ index ]
2312  ];
2313}
2314
2315static void Action2_SetPreConditionStates( Action2_Context *ctx )
2316{
2317  if ( ctx->Map.entry.Pre_A_NA ) {
2318    ctx->Map.pcs[ 0 ] = Action2_Pre_A_NA;
2319  } else {
2320    ctx->Map.pcs[ 0 ] = ctx->Map.pci[ 0 ];
2321  }
2322
2323  ctx->Map.pcs[ 1 ] = ctx->Map.pci[ 1 ];
2324  ctx->Map.pcs[ 2 ] = ctx->Map.pci[ 2 ];
2325}
2326
2327static void Action2_TestVariant( Action2_Context *ctx )
2328{
2329  Action2_Pre_A_Prepare( ctx, ctx->Map.pcs[ 0 ] );
2330
2331  if ( ctx->Map.skip ) {
2332    Action2_Skip( ctx, 0 );
2333    return;
2334  }
2335
2336  Action2_Pre_B_Prepare( ctx, ctx->Map.pcs[ 1 ] );
2337  Action2_Pre_C_Prepare( ctx, ctx->Map.pcs[ 2 ] );
2338  Action2_Action( ctx );
2339  Action2_Post_A_Check( ctx, ctx->Map.entry.Post_A );
2340  Action2_Post_B_Check( ctx, ctx->Map.entry.Post_B );
2341}
2342
2343static T_fixture_node Action2_Node;
2344
2345void Action2_Run( int *a, int b, int *c )
2346{
2347  Action2_Context *ctx;
2348
2349  ctx = &Action2_Instance;
2350  ctx->a = a;
2351  ctx->b = b;
2352  ctx->c = c;
2353
2354  ctx = T_push_fixture( &Action2_Node, &Action2_Fixture );
2355  ctx->Map.in_action_loop = true;
2356  ctx->Map.index = 0;
2357  ctx->Map.skip = false;
2358
2359  for (
2360    ctx->Map.pci[ 0 ] = Action2_Pre_A_A0;
2361    ctx->Map.pci[ 0 ] < Action2_Pre_A_NA;
2362    ++ctx->Map.pci[ 0 ]
2363  ) {
2364    for (
2365      ctx->Map.pci[ 1 ] = Action2_Pre_B_B0;
2366      ctx->Map.pci[ 1 ] < Action2_Pre_B_NA;
2367      ++ctx->Map.pci[ 1 ]
2368    ) {
2369      for (
2370        ctx->Map.pci[ 2 ] = Action2_Pre_C_C0;
2371        ctx->Map.pci[ 2 ] < Action2_Pre_C_NA;
2372        ++ctx->Map.pci[ 2 ]
2373      ) {
2374        ctx->Map.entry = Action2_PopEntry( ctx );
2375
2376        if ( ctx->Map.entry.Skip ) {
2377          continue;
2378        }
2379
2380        Action2_SetPreConditionStates( ctx );
2381        Action2_Prepare( ctx );
2382        Action2_TestVariant( ctx );
2383        Action2_Cleanup( ctx );
2384      }
2385    }
2386  }
2387
2388  T_pop_fixture();
2389}
2390
2391/** @} */
2392"""
2393        assert content == src.read()
2394
2395
2396def _add_item(item_cache, uid, data, item_type):
2397    item = Item(item_cache, uid, data)
2398    item["_type"] = item_type
2399    item_cache.all[item.uid] = item
2400    return item
2401
2402
2403def test_validation_invalid_actions():
2404    item_cache = EmptyItemCache()
2405    validation_config = {"base-directory": "/foobar"}
2406    spdx = "CC-BY-SA-4.0 OR BSD-2-Clause"
2407    copyright = "Copyright (C) 2021 John Doe"
2408    action_data = {
2409        "SPDX-License-Identifier":
2410        spdx,
2411        "copyrights": [copyright],
2412        "enabled-by":
2413        True,
2414        "functional-type":
2415        "action",
2416        "links": [],
2417        "post-conditions": [{
2418            "name": "X",
2419            "states": [],
2420            "test-epilogue": None,
2421            "test-prologue": None,
2422        }],
2423        "pre-conditions": [{
2424            "name": "A",
2425            "states": [],
2426            "test-epilogue": None,
2427            "test-prologue": None,
2428        }],
2429        "rationale":
2430        None,
2431        "references": [],
2432        "requirement-type":
2433        "functional",
2434        "skip-reasons": {},
2435        "test-action":
2436        None,
2437        "test-brief":
2438        None,
2439        "test-cleanup":
2440        None,
2441        "test-context": [],
2442        "test-context-support":
2443        None,
2444        "test-description":
2445        None,
2446        "test-header":
2447        None,
2448        "test-includes": [],
2449        "test-local-includes": [],
2450        "test-name":
2451        "A",
2452        "test-prepare":
2453        None,
2454        "test-setup":
2455        None,
2456        "test-stop":
2457        None,
2458        "test-support":
2459        None,
2460        "test-target":
2461        "a.c",
2462        "test-teardown":
2463        None,
2464        "text":
2465        None,
2466        "transition-map": [{
2467            "enabled-by": True,
2468            "post-conditions": {
2469                "X": "X0",
2470            },
2471            "pre-conditions": {
2472                "A": "all"
2473            },
2474        }],
2475        "type":
2476        "requirement",
2477    }
2478    _add_item(item_cache, "/a", action_data, "requirement/functional/action")
2479    match = ("the target file 'a.c' of spec:/a is not a source file of an "
2480             "item of type 'build/test-program'")
2481    with pytest.raises(ValueError, match=match):
2482        generate(validation_config, item_cache)
2483    test_program_data = {
2484        "SPDX-License-Identifier": spdx,
2485        "copyrights": [copyright],
2486        "build-type": "test-program",
2487        "enabled-by": True,
2488        "links": [],
2489        "source": ["a.c"],
2490        "type": "build",
2491    }
2492    _add_item(item_cache, "/tp", test_program_data, "build/test-program")
2493    match = "pre-condition 'A' of spec:/a has no states"
2494    with pytest.raises(ValueError, match=match):
2495        generate(validation_config, item_cache)
2496    action_data["pre-conditions"][0]["states"] = [{
2497        "name": "A0",
2498        "test-code": None,
2499        "text": None
2500    }]
2501    match = ("transition map descriptor 0 of spec:/a refers to non-existent "
2502             "post-condition state 'X0'")
2503    with pytest.raises(ValueError, match=match):
2504        generate(validation_config, item_cache)
2505    action_data["post-conditions"][0]["states"] = [{
2506        "name": "X0",
2507        "test-code": None,
2508        "text": None
2509    }]
2510    action_data["transition-map"][0]["pre-conditions"]["A"] = ["a"]
2511    match = ("transition map descriptor 0 of spec:/a refers to non-existent "
2512             "state 'a' of pre-condition 'A'")
2513    with pytest.raises(ValueError, match=match):
2514        generate(validation_config, item_cache)
2515    action_data["transition-map"][0]["pre-conditions"]["A"] = ["A0"]
2516    action_data["transition-map"].append({
2517        "enabled-by": True,
2518        "post-conditions": {
2519            "X": "X0",
2520        },
2521        "pre-conditions": {
2522            "A": "all"
2523        },
2524    })
2525    match = ("transition map descriptor 1 of spec:/a duplicates pre-condition "
2526             "set {A=A0} defined by transition map descriptor 0")
2527    with pytest.raises(ValueError, match=match):
2528        generate(validation_config, item_cache)
2529    action_data["transition-map"][1]["pre-conditions"]["A"] = ["A1"]
2530    action_data["pre-conditions"][0]["states"].append({
2531        "name": "A1",
2532        "test-code": None,
2533        "text": None
2534    })
2535    action_data["pre-conditions"][0]["states"].append({
2536        "name": "A2",
2537        "test-code": None,
2538        "text": None
2539    })
2540    match = ("transition map of spec:/a contains no default entry "
2541             "for pre-condition set {A=A2}")
2542    with pytest.raises(ValueError, match=match):
2543        generate(validation_config, item_cache)
2544    action_data["transition-map"][0]["enabled-by"] = False
2545    match = ("transition map descriptor 0 of spec:/a is the first "
2546             "variant for {A=A0} and it is not enabled by default")
2547    with pytest.raises(ValueError, match=match):
2548        generate(validation_config, item_cache)
2549    action_data["transition-map"][0]["enabled-by"] = True
2550    action_data["transition-map"][-1]["post-conditions"]["X"] = []
2551    match = ("cannot determine state for post-condition 'X' of transition map "
2552             "descriptor 1 of spec:/a for pre-condition set {A=A1}")
2553    with pytest.raises(ValueError, match=match):
2554        generate(validation_config, item_cache)
Note: See TracBrowser for help on using the repository browser.