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

Last change on this file since 3756347 was 3756347, checked in by Sebastian Huber <sebastian.huber@…>, on 09/21/21 at 18:15:58

validation: Fix skipping of transition variants

  • Property mode set to 100644
File size: 56.7 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} Rtm_Context;
1039
1040static Rtm_Context
1041  Rtm_Instance;
1042
1043/* Support code */
1044
1045static void Rtm_Setup_Context( Rtm_Context *ctx )
1046{
1047  T_measure_runtime_config config;
1048
1049  memset( &config, 0, sizeof( config ) );
1050  config.sample_count = 100;
1051  ctx->request.arg = ctx;
1052  ctx->request.flags = T_MEASURE_RUNTIME_REPORT_SAMPLES;
1053  ctx->context = T_measure_runtime_create( &config );
1054  T_assert_not_null( ctx->context );
1055}
1056
1057static void Rtm_Setup_Wrap( void *arg )
1058{
1059  Rtm_Context *ctx;
1060
1061  ctx = arg;
1062  Rtm_Setup_Context( ctx );
1063}
1064
1065/**
1066 * @brief Stop brief.
1067 *
1068 * Stop description.
1069 */
1070static void Rtm_Stop( Rtm_Context *ctx )
1071{
1072  /* Stop code */
1073}
1074
1075static void Rtm_Stop_Wrap( void *arg )
1076{
1077  Rtm_Context *ctx;
1078
1079  ctx = arg;
1080  Rtm_Stop( ctx );
1081}
1082
1083/**
1084 * @brief Teardown brief.
1085 *
1086 * Teardown description.
1087 */
1088static void Rtm_Teardown( Rtm_Context *ctx )
1089{
1090  /* Teardown code */
1091}
1092
1093static void Rtm_Teardown_Wrap( void *arg )
1094{
1095  Rtm_Context *ctx;
1096
1097  ctx = arg;
1098  Rtm_Teardown( ctx );
1099}
1100
1101static T_fixture Rtm_Fixture = {
1102  .setup = Rtm_Setup_Wrap,
1103  .stop = Rtm_Stop_Wrap,
1104  .teardown = Rtm_Teardown_Wrap,
1105  .scope = NULL,
1106  .initial_context = &Rtm_Instance
1107};
1108
1109/**
1110 * @brief Cleanup brief.
1111 *
1112 * Cleanup description.
1113 */
1114static void Rtm_Cleanup( Rtm_Context *ctx )
1115{
1116  /* Cleanup code */
1117}
1118
1119/**
1120 * @brief Body brief.
1121 *
1122 * Body description.
1123 */
1124static void Rpr_Body( Rtm_Context *ctx )
1125{
1126  /* Body code */
1127}
1128
1129static void Rpr_Body_Wrap( void *arg )
1130{
1131  Rtm_Context *ctx;
1132
1133  ctx = arg;
1134  Rpr_Body( ctx );
1135}
1136
1137/**
1138 * @brief Teardown brief.
1139 *
1140 * Teardown description.
1141 */
1142static bool Rpr_Teardown(
1143  Rtm_Context *ctx,
1144  T_ticks     *delta,
1145  uint32_t     tic,
1146  uint32_t     toc,
1147  unsigned int retry
1148)
1149{
1150  /* Teardown code */
1151}
1152
1153static bool Rpr_Teardown_Wrap(
1154  void        *arg,
1155  T_ticks     *delta,
1156  uint32_t     tic,
1157  uint32_t     toc,
1158  unsigned int retry
1159)
1160{
1161  Rtm_Context *ctx;
1162
1163  ctx = arg;
1164  return Rpr_Teardown( ctx, delta, tic, toc, retry );
1165}
1166
1167/**
1168 * @brief Cleanup brief.
1169 *
1170 * Cleanup description.
1171 */
1172static void Rpr_Cleanup( Rtm_Context *ctx )
1173{
1174  /* Cleanup code */
1175}
1176
1177/**
1178 * @fn void T_case_body_Rtm( void )
1179 */
1180T_TEST_CASE_FIXTURE( Rtm, &Rtm_Fixture )
1181{
1182  Rtm_Context *ctx;
1183
1184  ctx = T_fixture_context();
1185
1186  ctx->request.name = "Rpr";
1187  ctx->request.setup = NULL;
1188  ctx->request.body = Rpr_Body_Wrap;
1189  ctx->request.teardown = Rpr_Teardown_Wrap;
1190  T_measure_runtime( ctx->context, &ctx->request );
1191  Rpr_Cleanup( ctx );
1192  Rtm_Cleanup( ctx );
1193}
1194
1195/** @} */
1196
1197/**
1198 * @defgroup RTEMSTestCaseTc3 spec:/tc3
1199 *
1200 * @ingroup RTEMSTestSuiteTs
1201 *
1202 * @brief Test case 3 brief description.
1203 *
1204 * Test case 3 description.
1205 *
1206 * This test case performs the following actions:
1207 *
1208 * - Test case 3 action 0 description.
1209 *
1210 *   - Test case 3 action 0 check 0 description.
1211 *
1212 * @{
1213 */
1214
1215/**
1216 * @brief Test case 3 action 0 description.
1217 */
1218static void Tc3_Action_0( void )
1219{
1220  /* Test case 3 action 0 code */
1221
1222  /*
1223   * Test case 3 action 0 check 0 description.
1224   */
1225  /* Test case 3 action 0 check 0 code; step 0 */
1226}
1227
1228/**
1229 * @fn void T_case_body_Tc3( void )
1230 */
1231T_TEST_CASE( Tc3 )
1232{
1233  T_plan( 1 );
1234
1235  Tc3_Action_0();
1236}
1237
1238/** @} */
1239
1240/**
1241 * @defgroup RTEMSTestCaseTc4 spec:/tc4
1242 *
1243 * @ingroup RTEMSTestSuiteTs
1244 *
1245 * @brief Test case 4 brief description.
1246 *
1247 * Test case 4 description.
1248 *
1249 * @{
1250 */
1251
1252/**
1253 * @fn void T_case_body_Tc4( void )
1254 */
1255T_TEST_CASE( Tc4 )
1256{
1257}
1258
1259/** @} */
1260
1261/**
1262 * @defgroup RTEMSTestCaseTc5 spec:/tc5
1263 *
1264 * @ingroup RTEMSTestSuiteTs
1265 *
1266 * @brief Test case 5 brief description.
1267 *
1268 * Test case 5 description.
1269 *
1270 * This test case performs the following actions:
1271 *
1272 * - Test case action 0 description.
1273 *
1274 *   - Test case action 0 check 0 description.
1275 *
1276 *   - Test case action 0 check 1 description.
1277 *
1278 * - Test case action 1 description.
1279 *
1280 *   - Test case action 1 check 0 description.
1281 *
1282 *   - Test case action 1 check 1 description.
1283 *
1284 * @{
1285 */
1286
1287/**
1288 * @brief Test context for spec:/tc5 test case.
1289 */
1290typedef struct {
1291  /**
1292   * @brief This member contains a copy of the corresponding Tc5_Run()
1293   *   parameter.
1294   */
1295  int *a;
1296
1297  /**
1298   * @brief This member contains a copy of the corresponding Tc5_Run()
1299   *   parameter.
1300   */
1301  int b;
1302
1303  /**
1304   * @brief This member contains a copy of the corresponding Tc5_Run()
1305   *   parameter.
1306   */
1307  int *c;
1308} Tc5_Context;
1309
1310static Tc5_Context
1311  Tc5_Instance;
1312
1313static T_fixture Tc5_Fixture = {
1314  .setup = NULL,
1315  .stop = NULL,
1316  .teardown = NULL,
1317  .scope = NULL,
1318  .initial_context = &Tc5_Instance
1319};
1320
1321/**
1322 * @brief Test case action 0 description.
1323 */
1324static void Tc5_Action_0( Tc5_Context *ctx )
1325{
1326  /* Test case action 0 code */
1327
1328  /*
1329   * Test case action 0 check 0 description.
1330   */
1331  /* Test case action 0 check 0 code */
1332
1333  /*
1334   * Test case action 0 check 1 description.
1335   */
1336  /* Test case action 0 check 1 code; step 0 */
1337}
1338
1339/**
1340 * @brief Test case action 1 description.
1341 */
1342static void Tc5_Action_1( Tc5_Context *ctx )
1343{
1344  /* Test case action 1 code */
1345
1346  /*
1347   * Test case action 1 check 0 description.
1348   */
1349  /* Test case action 1 check 0 code; step 1 */
1350
1351  /*
1352   * Test case action 1 check 1 description.
1353   */
1354  /* Test case action 1 check 1 code */
1355}
1356
1357void Tc5_Run( int *a, int b, int *c )
1358{
1359  Tc5_Context *ctx;
1360
1361  ctx = &Tc5_Instance;
1362  ctx->a = a;
1363  ctx->b = b;
1364  ctx->c = c;
1365
1366  ctx = T_case_begin( "Tc5", &Tc5_Fixture );
1367
1368  T_plan( 2 );
1369
1370  Tc5_Action_0( ctx );
1371  Tc5_Action_1( ctx );
1372
1373  T_case_end();
1374}
1375
1376/** @} */
1377
1378/**
1379 * @defgroup RTEMSTestCaseTc6 spec:/tc6
1380 *
1381 * @ingroup RTEMSTestSuiteTs
1382 *
1383 * @{
1384 */
1385
1386void Tc6_Run( void )
1387{
1388}
1389
1390/** @} */
1391
1392/**
1393 * @defgroup RTEMSTestCaseTc7 spec:/tc7
1394 *
1395 * @ingroup RTEMSTestSuiteTs
1396 *
1397 * This test case performs the following actions:
1398 *
1399 * - Action.
1400 *
1401 * @{
1402 */
1403
1404/**
1405 * @brief Action.
1406 */
1407static void Tc7_Action_0( void )
1408{
1409  /* 0 */
1410}
1411
1412static T_fixture_node Tc7_Node;
1413
1414void Tc7_Run( void )
1415{
1416  T_push_fixture( &Tc7_Node, &T_empty_fixture );
1417
1418  T_plan( 1 );
1419
1420  Tc7_Action_0();
1421
1422  T_pop_fixture();
1423}
1424
1425/** @} */
1426
1427/**
1428 * @defgroup RTEMSTestCaseTc8 spec:/tc8
1429 *
1430 * @ingroup RTEMSTestSuiteTs
1431 *
1432 * This test case performs the following actions:
1433 *
1434 * - Action.
1435 *
1436 * @{
1437 */
1438
1439/**
1440 * @brief Test context for spec:/tc8 test case.
1441 */
1442typedef struct {
1443  int member;
1444} Tc8_Context;
1445
1446static Tc8_Context
1447  Tc8_Instance;
1448
1449static T_fixture Tc8_Fixture = {
1450  .setup = NULL,
1451  .stop = NULL,
1452  .teardown = NULL,
1453  .scope = NULL,
1454  .initial_context = &Tc8_Instance
1455};
1456
1457/**
1458 * @brief Action.
1459 */
1460static void Tc8_Action_0( Tc8_Context *ctx )
1461{
1462  /* 0 */
1463}
1464
1465static T_fixture_node Tc8_Node;
1466
1467void Tc8_Run( void )
1468{
1469  Tc8_Context *ctx;
1470
1471  ctx = T_push_fixture( &Tc8_Node, &Tc8_Fixture );
1472
1473  T_plan( 1 );
1474
1475  Tc8_Action_0( ctx );
1476
1477  T_pop_fixture();
1478}
1479
1480/** @} */
1481"""
1482        assert content == src.read()
1483    with open(os.path.join(base_directory, "tc5.h"), "r") as src:
1484        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1485
1486/**
1487 * @file
1488 *
1489 * @ingroup RTEMSTestCaseTc5
1490 */
1491
1492/*
1493 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1494 *
1495 * Redistribution and use in source and binary forms, with or without
1496 * modification, are permitted provided that the following conditions
1497 * are met:
1498 * 1. Redistributions of source code must retain the above copyright
1499 *    notice, this list of conditions and the following disclaimer.
1500 * 2. Redistributions in binary form must reproduce the above copyright
1501 *    notice, this list of conditions and the following disclaimer in the
1502 *    documentation and/or other materials provided with the distribution.
1503 *
1504 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1505 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1506 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1507 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1508 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1509 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1510 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1511 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1512 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1513 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1514 * POSSIBILITY OF SUCH DAMAGE.
1515 */
1516
1517/*
1518 * This file is part of the RTEMS quality process and was automatically
1519 * generated.  If you find something that needs to be fixed or
1520 * worded better please post a report or patch to an RTEMS mailing list
1521 * or raise a bug report:
1522 *
1523 * https://www.rtems.org/bugs.html
1524 *
1525 * For information on updating and regenerating please refer to the How-To
1526 * section in the Software Requirements Engineering chapter of the
1527 * RTEMS Software Engineering manual.  The manual is provided as a part of
1528 * a release.  For development sources please refer to the online
1529 * documentation at:
1530 *
1531 * https://docs.rtems.org
1532 */
1533
1534#ifndef _TC5_H
1535#define _TC5_H
1536
1537#include <d.h>
1538
1539#include "e.h"
1540
1541#ifdef __cplusplus
1542extern "C" {
1543#endif
1544
1545/**
1546 * @addtogroup RTEMSTestCaseTc5
1547 *
1548 * @{
1549 */
1550
1551/* Header code for Tc5_Run() */
1552
1553/**
1554 * @brief Runs the parameterized test case.
1555 *
1556 * @param[in] a Parameter A description.
1557 *
1558 * @param b Parameter B description.
1559 *
1560 * @param[out] c Parameter C description.
1561 */
1562void Tc5_Run( int *a, int b, int *c );
1563
1564/** @} */
1565
1566#ifdef __cplusplus
1567}
1568#endif
1569
1570#endif /* _TC5_H */
1571"""
1572        assert content == src.read()
1573    with open(os.path.join(base_directory, "tc6.h"), "r") as src:
1574        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1575
1576/**
1577 * @file
1578 *
1579 * @ingroup RTEMSTestCaseTc6
1580 */
1581
1582/*
1583 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1584 *
1585 * Redistribution and use in source and binary forms, with or without
1586 * modification, are permitted provided that the following conditions
1587 * are met:
1588 * 1. Redistributions of source code must retain the above copyright
1589 *    notice, this list of conditions and the following disclaimer.
1590 * 2. Redistributions in binary form must reproduce the above copyright
1591 *    notice, this list of conditions and the following disclaimer in the
1592 *    documentation and/or other materials provided with the distribution.
1593 *
1594 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1595 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1596 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1597 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1598 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1599 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1600 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1601 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1602 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1603 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1604 * POSSIBILITY OF SUCH DAMAGE.
1605 */
1606
1607/*
1608 * This file is part of the RTEMS quality process and was automatically
1609 * generated.  If you find something that needs to be fixed or
1610 * worded better please post a report or patch to an RTEMS mailing list
1611 * or raise a bug report:
1612 *
1613 * https://www.rtems.org/bugs.html
1614 *
1615 * For information on updating and regenerating please refer to the How-To
1616 * section in the Software Requirements Engineering chapter of the
1617 * RTEMS Software Engineering manual.  The manual is provided as a part of
1618 * a release.  For development sources please refer to the online
1619 * documentation at:
1620 *
1621 * https://docs.rtems.org
1622 */
1623
1624#ifndef _TC6_H
1625#define _TC6_H
1626
1627#ifdef __cplusplus
1628extern "C" {
1629#endif
1630
1631/**
1632 * @addtogroup RTEMSTestCaseTc6
1633 *
1634 * @{
1635 */
1636
1637/**
1638 * @brief Runs the parameterized test case.
1639 */
1640void Tc6_Run( void );
1641
1642/** @} */
1643
1644#ifdef __cplusplus
1645}
1646#endif
1647
1648#endif /* _TC6_H */
1649"""
1650        assert content == src.read()
1651    with open(os.path.join(base_directory, "action2.h"), "r") as src:
1652        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1653
1654/**
1655 * @file
1656 *
1657 * @ingroup RTEMSTestCaseAction2
1658 */
1659
1660/*
1661 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1662 *
1663 * Redistribution and use in source and binary forms, with or without
1664 * modification, are permitted provided that the following conditions
1665 * are met:
1666 * 1. Redistributions of source code must retain the above copyright
1667 *    notice, this list of conditions and the following disclaimer.
1668 * 2. Redistributions in binary form must reproduce the above copyright
1669 *    notice, this list of conditions and the following disclaimer in the
1670 *    documentation and/or other materials provided with the distribution.
1671 *
1672 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1673 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1674 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1675 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1676 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1677 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1678 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1679 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1680 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1681 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1682 * POSSIBILITY OF SUCH DAMAGE.
1683 */
1684
1685/*
1686 * This file is part of the RTEMS quality process and was automatically
1687 * generated.  If you find something that needs to be fixed or
1688 * worded better please post a report or patch to an RTEMS mailing list
1689 * or raise a bug report:
1690 *
1691 * https://www.rtems.org/bugs.html
1692 *
1693 * For information on updating and regenerating please refer to the How-To
1694 * section in the Software Requirements Engineering chapter of the
1695 * RTEMS Software Engineering manual.  The manual is provided as a part of
1696 * a release.  For development sources please refer to the online
1697 * documentation at:
1698 *
1699 * https://docs.rtems.org
1700 */
1701
1702#ifndef _ACTION2_H
1703#define _ACTION2_H
1704
1705#include <d.h>
1706
1707#include "e.h"
1708
1709#ifdef __cplusplus
1710extern "C" {
1711#endif
1712
1713/**
1714 * @addtogroup RTEMSTestCaseAction2
1715 *
1716 * @{
1717 */
1718
1719typedef enum {
1720  Action2_Pre_A_A0,
1721  Action2_Pre_A_A1,
1722  Action2_Pre_A_NA
1723} Action2_Pre_A;
1724
1725typedef enum {
1726  Action2_Pre_B_B0,
1727  Action2_Pre_B_B1,
1728  Action2_Pre_B_B2,
1729  Action2_Pre_B_NA
1730} Action2_Pre_B;
1731
1732typedef enum {
1733  Action2_Pre_C_C0,
1734  Action2_Pre_C_C1,
1735  Action2_Pre_C_C2,
1736  Action2_Pre_C_NA
1737} Action2_Pre_C;
1738
1739typedef enum {
1740  Action2_Post_A_A0,
1741  Action2_Post_A_A1,
1742  Action2_Post_A_A2,
1743  Action2_Post_A_A3,
1744  Action2_Post_A_NA
1745} Action2_Post_A;
1746
1747typedef enum {
1748  Action2_Post_B_B0,
1749  Action2_Post_B_B1,
1750  Action2_Post_B_B2,
1751  Action2_Post_B_NA
1752} Action2_Post_B;
1753
1754/* Header code for Action 2 with Action2_Run() */
1755
1756/**
1757 * @brief Runs the parameterized test case.
1758 *
1759 * @param[in] a Parameter A description.
1760 *
1761 * @param b Parameter B description.
1762 *
1763 * @param[out] c Parameter C description.
1764 */
1765void Action2_Run( int *a, int b, int *c );
1766
1767/** @} */
1768
1769#ifdef __cplusplus
1770}
1771#endif
1772
1773#endif /* _ACTION2_H */
1774"""
1775        assert content == src.read()
1776    with open(os.path.join(base_directory, "action2.c"), "r") as src:
1777        content = """/* SPDX-License-Identifier: BSD-2-Clause */
1778
1779/**
1780 * @file
1781 *
1782 * @ingroup RTEMSTestCaseAction2
1783 */
1784
1785/*
1786 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
1787 *
1788 * Redistribution and use in source and binary forms, with or without
1789 * modification, are permitted provided that the following conditions
1790 * are met:
1791 * 1. Redistributions of source code must retain the above copyright
1792 *    notice, this list of conditions and the following disclaimer.
1793 * 2. Redistributions in binary form must reproduce the above copyright
1794 *    notice, this list of conditions and the following disclaimer in the
1795 *    documentation and/or other materials provided with the distribution.
1796 *
1797 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1798 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1799 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1800 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1801 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1802 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1803 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1804 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1805 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1806 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1807 * POSSIBILITY OF SUCH DAMAGE.
1808 */
1809
1810/*
1811 * This file is part of the RTEMS quality process and was automatically
1812 * generated.  If you find something that needs to be fixed or
1813 * worded better please post a report or patch to an RTEMS mailing list
1814 * or raise a bug report:
1815 *
1816 * https://www.rtems.org/bugs.html
1817 *
1818 * For information on updating and regenerating please refer to the How-To
1819 * section in the Software Requirements Engineering chapter of the
1820 * RTEMS Software Engineering manual.  The manual is provided as a part of
1821 * a release.  For development sources please refer to the online
1822 * documentation at:
1823 *
1824 * https://docs.rtems.org
1825 */
1826
1827#ifdef HAVE_CONFIG_H
1828#include "config.h"
1829#endif
1830
1831#include <a.h>
1832
1833#include "b.h"
1834
1835#include <rtems/test.h>
1836
1837/**
1838 * @defgroup RTEMSTestCaseAction2 spec:/action2
1839 *
1840 * @ingroup RTEMSTestSuiteTs
1841 *
1842 * @brief Test brief.
1843 *
1844 * Test description.
1845 *
1846 * @{
1847 */
1848
1849typedef struct {
1850  uint16_t Skip : 1;
1851  uint16_t Pre_A_NA : 1;
1852  uint16_t Pre_B_NA : 1;
1853  uint16_t Pre_C_NA : 1;
1854  uint16_t Post_A : 3;
1855  uint16_t Post_B : 2;
1856} Action2_Entry;
1857
1858/* Context support code */
1859
1860/**
1861 * @brief Test context for spec:/action2 test case.
1862 */
1863typedef struct {
1864  /**
1865   * @brief Context member brief.
1866   *
1867   * Context member description.
1868   */
1869  int member;
1870
1871  /**
1872   * @brief This member contains a copy of the corresponding Action2_Run()
1873   *   parameter.
1874   */
1875  int *a;
1876
1877  /**
1878   * @brief This member contains a copy of the corresponding Action2_Run()
1879   *   parameter.
1880   */
1881  int b;
1882
1883  /**
1884   * @brief This member contains a copy of the corresponding Action2_Run()
1885   *   parameter.
1886   */
1887  int *c;
1888
1889  struct {
1890    /**
1891     * @brief This member defines the pre-condition indices for the next
1892     *   action.
1893     */
1894    size_t pci[ 3 ];
1895
1896    /**
1897     * @brief This member defines the pre-condition states for the next action.
1898     */
1899    size_t pcs[ 3 ];
1900
1901    /**
1902     * @brief If this member is true, then the test action loop is executed.
1903     */
1904    bool in_action_loop;
1905
1906    /**
1907     * @brief This member contains the next transition map index.
1908     */
1909    size_t index;
1910
1911    /**
1912     * @brief This member contains the current transition map entry.
1913     */
1914    Action2_Entry entry;
1915
1916    /**
1917     * @brief If this member is true, then the current transition variant
1918     *   should be skipped.
1919     */
1920    bool skip;
1921  } Map;
1922} Action2_Context;
1923
1924static Action2_Context
1925  Action2_Instance;
1926
1927static const char * const Action2_PreDesc_A[] = {
1928  "A0",
1929  "A1",
1930  "NA"
1931};
1932
1933static const char * const Action2_PreDesc_B[] = {
1934  "B0",
1935  "B1",
1936  "B2",
1937  "NA"
1938};
1939
1940static const char * const Action2_PreDesc_C[] = {
1941  "C0",
1942  "C1",
1943  "C2",
1944  "NA"
1945};
1946
1947static const char * const * const Action2_PreDesc[] = {
1948  Action2_PreDesc_A,
1949  Action2_PreDesc_B,
1950  Action2_PreDesc_C,
1951  NULL
1952};
1953
1954/* Support code */
1955Action2_Context *instance = &Action2_Instance;
1956
1957static void Action2_Pre_A_Prepare( Action2_Context *ctx, Action2_Pre_A state )
1958{
1959  /* Pre A prologue. */
1960
1961  switch ( state ) {
1962    case Action2_Pre_A_A0: {
1963      /*
1964       * Pre A 0.
1965       */
1966      /* Pre A 0 */
1967      break;
1968    }
1969
1970    case Action2_Pre_A_A1: {
1971      /*
1972       * Pre A 1.
1973       */
1974      /* Pre A 1 */
1975      ctx->Map.skip = true;
1976      break;
1977    }
1978
1979    case Action2_Pre_A_NA:
1980      break;
1981  }
1982
1983  /* Pre A epilogue. */
1984}
1985
1986static void Action2_Pre_B_Prepare( Action2_Context *ctx, Action2_Pre_B state )
1987{
1988  /* Pre B prologue. */
1989
1990  switch ( state ) {
1991    case Action2_Pre_B_B0: {
1992      /*
1993       * Pre B 0.
1994       */
1995      /* Pre B 0 */
1996      break;
1997    }
1998
1999    case Action2_Pre_B_B1: {
2000      /*
2001       * Pre B 1.
2002       */
2003      /* Pre B 1 */
2004      break;
2005    }
2006
2007    case Action2_Pre_B_B2: {
2008      /*
2009       * Pre B 1.
2010       */
2011      /* Pre B 1 */
2012      break;
2013    }
2014
2015    case Action2_Pre_B_NA:
2016      break;
2017  }
2018
2019  /* Pre B epilogue. */
2020}
2021
2022static void Action2_Pre_C_Prepare( Action2_Context *ctx, Action2_Pre_C state )
2023{
2024  /* Pre C prologue. */
2025
2026  switch ( state ) {
2027    case Action2_Pre_C_C0: {
2028      /*
2029       * Pre C 0.
2030       */
2031      /* Pre C 0 */
2032      break;
2033    }
2034
2035    case Action2_Pre_C_C1: {
2036      /*
2037       * Pre C 1.
2038       */
2039      /* Pre B 1 */
2040      break;
2041    }
2042
2043    case Action2_Pre_C_C2: {
2044      /*
2045       * Pre C 2.
2046       */
2047      /* Pre C 2 */
2048      break;
2049    }
2050
2051    case Action2_Pre_C_NA:
2052      break;
2053  }
2054
2055  /* Pre C epilogue. */
2056}
2057
2058static void Action2_Post_A_Check( Action2_Context *ctx, Action2_Post_A state )
2059{
2060  /* Post A prologue. */
2061
2062  switch ( state ) {
2063    case Action2_Post_A_A0: {
2064      /*
2065       * Post A 0.
2066       */
2067      /* Post A 0 */
2068      break;
2069    }
2070
2071    case Action2_Post_A_A1: {
2072      /*
2073       * Post A 1.
2074       */
2075      /* Post A 1 */
2076      break;
2077    }
2078
2079    case Action2_Post_A_A2: {
2080      /*
2081       * Post A 2.
2082       */
2083      /* Post A 2 */
2084      break;
2085    }
2086
2087    case Action2_Post_A_A3: {
2088      /*
2089       * Post A 3.
2090       */
2091      /* Post A 3 */
2092      break;
2093    }
2094
2095    case Action2_Post_A_NA:
2096      break;
2097  }
2098
2099  /* Post A epilogue. */
2100}
2101
2102static void Action2_Post_B_Check( Action2_Context *ctx, Action2_Post_B state )
2103{
2104  /* Post B prologue. */
2105
2106  switch ( state ) {
2107    case Action2_Post_B_B0: {
2108      /*
2109       * Post B 0.
2110       */
2111      /* Post B 0 */
2112      break;
2113    }
2114
2115    case Action2_Post_B_B1: {
2116      /*
2117       * Post B 1.
2118       */
2119      /* Post B 1 */
2120      break;
2121    }
2122
2123    case Action2_Post_B_B2: {
2124      /*
2125       * Post B 2.
2126       */
2127      /* Post B 2 */
2128      break;
2129    }
2130
2131    case Action2_Post_B_NA:
2132      break;
2133  }
2134
2135  /* Post B epilogue. */
2136}
2137
2138/**
2139 * @brief Setup brief.
2140 *
2141 * Setup description.
2142 */
2143static void Action2_Setup( Action2_Context *ctx )
2144{
2145  /* Setup code */
2146}
2147
2148static void Action2_Setup_Wrap( void *arg )
2149{
2150  Action2_Context *ctx;
2151
2152  ctx = arg;
2153  ctx->Map.in_action_loop = false;
2154  Action2_Setup( ctx );
2155}
2156
2157/**
2158 * @brief Teardown brief.
2159 *
2160 * Teardown description.
2161 */
2162static void Action2_Teardown( Action2_Context *ctx )
2163{
2164  /* Teardown code */
2165}
2166
2167static void Action2_Teardown_Wrap( void *arg )
2168{
2169  Action2_Context *ctx;
2170
2171  ctx = arg;
2172  ctx->Map.in_action_loop = false;
2173  Action2_Teardown( ctx );
2174}
2175
2176static void Action2_Prepare( Action2_Context *ctx )
2177{
2178  /* Prepare */
2179}
2180
2181static void Action2_Action( Action2_Context *ctx )
2182{
2183  /* Action */
2184}
2185
2186static void Action2_Cleanup( Action2_Context *ctx )
2187{
2188  /* Cleanup */
2189}
2190
2191static const Action2_Entry
2192Action2_Entries[] = {
2193  { 0, 1, 0, 0, Action2_Post_A_A1, Action2_Post_B_NA },
2194  { 0, 0, 0, 0, Action2_Post_A_A2, Action2_Post_B_B0 },
2195  { 1, 0, 0, 0, Action2_Post_A_NA, Action2_Post_B_NA },
2196  { 0, 0, 0, 0, Action2_Post_A_A1, Action2_Post_B_B0 },
2197#if defined(BOOM)
2198  { 0, 1, 0, 0, Action2_Post_A_NA, Action2_Post_B_B0 },
2199#else
2200  { 0, 0, 0, 0, Action2_Post_A_A1, Action2_Post_B_B0 },
2201#endif
2202#if defined(BOOM)
2203  { 0, 1, 0, 0, Action2_Post_A_NA, Action2_Post_B_B0 },
2204#else
2205  { 0, 0, 0, 0, Action2_Post_A_A2, Action2_Post_B_B0 },
2206#endif
2207  { 0, 0, 0, 0, Action2_Post_A_A3, Action2_Post_B_B0 }
2208};
2209
2210static const uint8_t
2211Action2_Map[] = {
2212  4, 3, 3, 0, 0, 0, 1, 1, 1, 5, 1, 6, 0, 0, 0, 2, 2, 2
2213};
2214
2215static size_t Action2_Scope( void *arg, char *buf, size_t n )
2216{
2217  Action2_Context *ctx;
2218
2219  ctx = arg;
2220
2221  if ( ctx->Map.in_action_loop ) {
2222    return T_get_scope( Action2_PreDesc, buf, n, ctx->Map.pcs );
2223  }
2224
2225  return 0;
2226}
2227
2228static T_fixture Action2_Fixture = {
2229  .setup = Action2_Setup_Wrap,
2230  .stop = NULL,
2231  .teardown = Action2_Teardown_Wrap,
2232  .scope = Action2_Scope,
2233  .initial_context = &Action2_Instance
2234};
2235
2236static const uint8_t Action2_Weights[] = {
2237  9, 3, 1
2238};
2239
2240static void Action2_Skip( Action2_Context *ctx, size_t index )
2241{
2242  switch ( index + 1 ) {
2243    case 1:
2244      ctx->Map.pci[ 1 ] = Action2_Pre_B_NA - 1;
2245      /* Fall through */
2246    case 2:
2247      ctx->Map.pci[ 2 ] = Action2_Pre_C_NA - 1;
2248      break;
2249  }
2250}
2251
2252static inline Action2_Entry Action2_PopEntry( Action2_Context *ctx )
2253{
2254  size_t index;
2255
2256  if ( ctx->Map.skip ) {
2257    size_t i;
2258
2259    ctx->Map.skip = false;
2260    index = 0;
2261
2262    for ( i = 0; i < 3; ++i ) {
2263      index += Action2_Weights[ i ] * ctx->Map.pci[ i ];
2264    }
2265  } else {
2266    index = ctx->Map.index;
2267  }
2268
2269  ctx->Map.index = index + 1;
2270
2271  return Action2_Entries[
2272    Action2_Map[ index ]
2273  ];
2274}
2275
2276static void Action2_SetPreConditionStates( Action2_Context *ctx )
2277{
2278  if ( ctx->Map.entry.Pre_A_NA ) {
2279    ctx->Map.pcs[ 0 ] = Action2_Pre_A_NA;
2280  } else {
2281    ctx->Map.pcs[ 0 ] = ctx->Map.pci[ 0 ];
2282  }
2283
2284  ctx->Map.pcs[ 1 ] = ctx->Map.pci[ 1 ];
2285  ctx->Map.pcs[ 2 ] = ctx->Map.pci[ 2 ];
2286}
2287
2288static void Action2_TestVariant( Action2_Context *ctx )
2289{
2290  Action2_Pre_A_Prepare( ctx, ctx->Map.pcs[ 0 ] );
2291
2292  if ( ctx->Map.skip ) {
2293    Action2_Skip( ctx, 0 );
2294    return;
2295  }
2296
2297  Action2_Pre_B_Prepare( ctx, ctx->Map.pcs[ 1 ] );
2298  Action2_Pre_C_Prepare( ctx, ctx->Map.pcs[ 2 ] );
2299  Action2_Action( ctx );
2300  Action2_Post_A_Check( ctx, ctx->Map.entry.Post_A );
2301  Action2_Post_B_Check( ctx, ctx->Map.entry.Post_B );
2302}
2303
2304static T_fixture_node Action2_Node;
2305
2306void Action2_Run( int *a, int b, int *c )
2307{
2308  Action2_Context *ctx;
2309
2310  ctx = &Action2_Instance;
2311  ctx->a = a;
2312  ctx->b = b;
2313  ctx->c = c;
2314
2315  ctx = T_push_fixture( &Action2_Node, &Action2_Fixture );
2316  ctx->Map.in_action_loop = true;
2317  ctx->Map.index = 0;
2318  ctx->Map.skip = false;
2319
2320  for (
2321    ctx->Map.pci[ 0 ] = Action2_Pre_A_A0;
2322    ctx->Map.pci[ 0 ] < Action2_Pre_A_NA;
2323    ++ctx->Map.pci[ 0 ]
2324  ) {
2325    for (
2326      ctx->Map.pci[ 1 ] = Action2_Pre_B_B0;
2327      ctx->Map.pci[ 1 ] < Action2_Pre_B_NA;
2328      ++ctx->Map.pci[ 1 ]
2329    ) {
2330      for (
2331        ctx->Map.pci[ 2 ] = Action2_Pre_C_C0;
2332        ctx->Map.pci[ 2 ] < Action2_Pre_C_NA;
2333        ++ctx->Map.pci[ 2 ]
2334      ) {
2335        ctx->Map.entry = Action2_PopEntry( ctx );
2336
2337        if ( ctx->Map.entry.Skip ) {
2338          continue;
2339        }
2340
2341        Action2_SetPreConditionStates( ctx );
2342        Action2_Prepare( ctx );
2343        Action2_TestVariant( ctx );
2344        Action2_Cleanup( ctx );
2345      }
2346    }
2347  }
2348
2349  T_pop_fixture();
2350}
2351
2352/** @} */
2353"""
2354        assert content == src.read()
2355
2356
2357def _add_item(item_cache, uid, data, item_type):
2358    item = Item(item_cache, uid, data)
2359    item["_type"] = item_type
2360    item_cache.all[item.uid] = item
2361    return item
2362
2363
2364def test_validation_invalid_actions():
2365    item_cache = EmptyItemCache()
2366    validation_config = {"base-directory": "/foobar"}
2367    spdx = "CC-BY-SA-4.0 OR BSD-2-Clause"
2368    copyright = "Copyright (C) 2021 John Doe"
2369    action_data = {
2370        "SPDX-License-Identifier":
2371        spdx,
2372        "copyrights": [copyright],
2373        "enabled-by":
2374        True,
2375        "functional-type":
2376        "action",
2377        "links": [],
2378        "post-conditions": [{
2379            "name": "X",
2380            "states": [],
2381            "test-epilogue": None,
2382            "test-prologue": None,
2383        }],
2384        "pre-conditions": [{
2385            "name": "A",
2386            "states": [],
2387            "test-epilogue": None,
2388            "test-prologue": None,
2389        }],
2390        "rationale":
2391        None,
2392        "references": [],
2393        "requirement-type":
2394        "functional",
2395        "skip-reasons": {},
2396        "test-action":
2397        None,
2398        "test-brief":
2399        None,
2400        "test-cleanup":
2401        None,
2402        "test-context": [],
2403        "test-context-support":
2404        None,
2405        "test-description":
2406        None,
2407        "test-header":
2408        None,
2409        "test-includes": [],
2410        "test-local-includes": [],
2411        "test-name":
2412        "A",
2413        "test-prepare":
2414        None,
2415        "test-setup":
2416        None,
2417        "test-stop":
2418        None,
2419        "test-support":
2420        None,
2421        "test-target":
2422        "a.c",
2423        "test-teardown":
2424        None,
2425        "text":
2426        None,
2427        "transition-map": [{
2428            "enabled-by": True,
2429            "post-conditions": {
2430                "X": "X0",
2431            },
2432            "pre-conditions": {
2433                "A": "all"
2434            },
2435        }],
2436        "type":
2437        "requirement",
2438    }
2439    _add_item(item_cache, "/a", action_data, "requirement/functional/action")
2440    match = ("the target file 'a.c' of spec:/a is not a source file of an "
2441             "item of type 'build/test-program'")
2442    with pytest.raises(ValueError, match=match):
2443        generate(validation_config, item_cache)
2444    test_program_data = {
2445        "SPDX-License-Identifier": spdx,
2446        "copyrights": [copyright],
2447        "build-type": "test-program",
2448        "enabled-by": True,
2449        "links": [],
2450        "source": ["a.c"],
2451        "type": "build",
2452    }
2453    _add_item(item_cache, "/tp", test_program_data, "build/test-program")
2454    match = "pre-condition 'A' of spec:/a has no states"
2455    with pytest.raises(ValueError, match=match):
2456        generate(validation_config, item_cache)
2457    action_data["pre-conditions"][0]["states"] = [{
2458        "name": "A0",
2459        "test-code": None,
2460        "text": None
2461    }]
2462    match = ("transition map descriptor 0 of spec:/a refers to non-existent "
2463             "post-condition state 'X0'")
2464    with pytest.raises(ValueError, match=match):
2465        generate(validation_config, item_cache)
2466    action_data["post-conditions"][0]["states"] = [{
2467        "name": "X0",
2468        "test-code": None,
2469        "text": None
2470    }]
2471    action_data["transition-map"][0]["pre-conditions"]["A"] = ["a"]
2472    match = ("transition map descriptor 0 of spec:/a refers to non-existent "
2473             "state 'a' of pre-condition 'A'")
2474    with pytest.raises(ValueError, match=match):
2475        generate(validation_config, item_cache)
2476    action_data["transition-map"][0]["pre-conditions"]["A"] = ["A0"]
2477    action_data["transition-map"].append({
2478        "enabled-by": True,
2479        "post-conditions": {
2480            "X": "X0",
2481        },
2482        "pre-conditions": {
2483            "A": "all"
2484        },
2485    })
2486    match = ("transition map descriptor 1 of spec:/a duplicates pre-condition "
2487             "set {A=A0} defined by transition map descriptor 0")
2488    with pytest.raises(ValueError, match=match):
2489        generate(validation_config, item_cache)
2490    action_data["transition-map"][1]["pre-conditions"]["A"] = ["A1"]
2491    action_data["pre-conditions"][0]["states"].append({
2492        "name": "A1",
2493        "test-code": None,
2494        "text": None
2495    })
2496    action_data["pre-conditions"][0]["states"].append({
2497        "name": "A2",
2498        "test-code": None,
2499        "text": None
2500    })
2501    match = ("transition map of spec:/a contains no default entry "
2502             "for pre-condition set {A=A2}")
2503    with pytest.raises(ValueError, match=match):
2504        generate(validation_config, item_cache)
2505    action_data["transition-map"][0]["enabled-by"] = False
2506    match = ("transition map descriptor 0 of spec:/a is the first "
2507             "variant for {A=A0} and it is not enabled by default")
2508    with pytest.raises(ValueError, match=match):
2509        generate(validation_config, item_cache)
2510    action_data["transition-map"][0]["enabled-by"] = True
2511    action_data["transition-map"][-1]["post-conditions"]["X"] = []
2512    match = ("cannot determine state for post-condition 'X' of transition map "
2513             "descriptor 1 of spec:/a for pre-condition set {A=A1}")
2514    with pytest.raises(ValueError, match=match):
2515        generate(validation_config, item_cache)
Note: See TracBrowser for help on using the repository browser.