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

Last change on this file since c0d8670 was c0d8670, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/21 at 13:11:58

validation: Add optional begin/end time point

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