source: rtems/testsuites/validation/tc-barrier-create.c @ 34f279aa

Last change on this file since 34f279aa was 34f279aa, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 24, 2021 at 4:59:32 PM

validation: Add comments to barrier tests

Unify code sections across tests.

  • Property mode set to 100644
File size: 29.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSTestCaseRtemsBarrierReqCreate
7 */
8
9/*
10 * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * This file is part of the RTEMS quality process and was automatically
36 * generated.  If you find something that needs to be fixed or
37 * worded better please post a report or patch to an RTEMS mailing list
38 * or raise a bug report:
39 *
40 * https://www.rtems.org/bugs.html
41 *
42 * For information on updating and regenerating please refer to the How-To
43 * section in the Software Requirements Engineering chapter of the
44 * RTEMS Software Engineering manual.  The manual is provided as a part of
45 * a release.  For development sources please refer to the online
46 * documentation at:
47 *
48 * https://docs.rtems.org
49 */
50
51#ifdef HAVE_CONFIG_H
52#include "config.h"
53#endif
54
55#include <rtems.h>
56#include <string.h>
57
58#include <rtems/test.h>
59
60/**
61 * @defgroup RTEMSTestCaseRtemsBarrierReqCreate spec:/rtems/barrier/req/create
62 *
63 * @ingroup RTEMSTestSuiteTestsuitesValidation0
64 *
65 * @{
66 */
67
68typedef enum {
69  RtemsBarrierReqCreate_Pre_Name_Valid,
70  RtemsBarrierReqCreate_Pre_Name_Invalid,
71  RtemsBarrierReqCreate_Pre_Name_NA
72} RtemsBarrierReqCreate_Pre_Name;
73
74typedef enum {
75  RtemsBarrierReqCreate_Pre_Class_Default,
76  RtemsBarrierReqCreate_Pre_Class_Manual,
77  RtemsBarrierReqCreate_Pre_Class_Auto,
78  RtemsBarrierReqCreate_Pre_Class_NA
79} RtemsBarrierReqCreate_Pre_Class;
80
81typedef enum {
82  RtemsBarrierReqCreate_Pre_MaxWait_Zero,
83  RtemsBarrierReqCreate_Pre_MaxWait_Positive,
84  RtemsBarrierReqCreate_Pre_MaxWait_NA
85} RtemsBarrierReqCreate_Pre_MaxWait;
86
87typedef enum {
88  RtemsBarrierReqCreate_Pre_Id_Valid,
89  RtemsBarrierReqCreate_Pre_Id_Null,
90  RtemsBarrierReqCreate_Pre_Id_NA
91} RtemsBarrierReqCreate_Pre_Id;
92
93typedef enum {
94  RtemsBarrierReqCreate_Pre_Free_Yes,
95  RtemsBarrierReqCreate_Pre_Free_No,
96  RtemsBarrierReqCreate_Pre_Free_NA
97} RtemsBarrierReqCreate_Pre_Free;
98
99typedef enum {
100  RtemsBarrierReqCreate_Post_Status_Ok,
101  RtemsBarrierReqCreate_Post_Status_InvName,
102  RtemsBarrierReqCreate_Post_Status_InvAddr,
103  RtemsBarrierReqCreate_Post_Status_InvNum,
104  RtemsBarrierReqCreate_Post_Status_TooMany,
105  RtemsBarrierReqCreate_Post_Status_NA
106} RtemsBarrierReqCreate_Post_Status;
107
108typedef enum {
109  RtemsBarrierReqCreate_Post_Name_Valid,
110  RtemsBarrierReqCreate_Post_Name_Invalid,
111  RtemsBarrierReqCreate_Post_Name_NA
112} RtemsBarrierReqCreate_Post_Name;
113
114typedef enum {
115  RtemsBarrierReqCreate_Post_Class_NoObj,
116  RtemsBarrierReqCreate_Post_Class_Manual,
117  RtemsBarrierReqCreate_Post_Class_Auto,
118  RtemsBarrierReqCreate_Post_Class_NA
119} RtemsBarrierReqCreate_Post_Class;
120
121typedef enum {
122  RtemsBarrierReqCreate_Post_IdValue_Assigned,
123  RtemsBarrierReqCreate_Post_IdValue_Unchanged,
124  RtemsBarrierReqCreate_Post_IdValue_NA
125} RtemsBarrierReqCreate_Post_IdValue;
126
127/**
128 * @brief Test context for spec:/rtems/barrier/req/create test case.
129 */
130typedef struct {
131  void *seized_objects;
132
133  rtems_id worker_id;
134
135  rtems_id id_value;
136
137  uint32_t release_done;
138
139  uint32_t release_expected;
140
141  rtems_name name;
142
143  rtems_attribute attribute_set;
144
145  uint32_t maximum_waiters;
146
147  rtems_id *id;
148
149  rtems_status_code status;
150
151  /**
152   * @brief This member defines the pre-condition states for the next action.
153   */
154  size_t pcs[ 5 ];
155
156  /**
157   * @brief This member indicates if the test action loop is currently
158   *   executed.
159   */
160  bool in_action_loop;
161} RtemsBarrierReqCreate_Context;
162
163static RtemsBarrierReqCreate_Context
164  RtemsBarrierReqCreate_Instance;
165
166static const char * const RtemsBarrierReqCreate_PreDesc_Name[] = {
167  "Valid",
168  "Invalid",
169  "NA"
170};
171
172static const char * const RtemsBarrierReqCreate_PreDesc_Class[] = {
173  "Default",
174  "Manual",
175  "Auto",
176  "NA"
177};
178
179static const char * const RtemsBarrierReqCreate_PreDesc_MaxWait[] = {
180  "Zero",
181  "Positive",
182  "NA"
183};
184
185static const char * const RtemsBarrierReqCreate_PreDesc_Id[] = {
186  "Valid",
187  "Null",
188  "NA"
189};
190
191static const char * const RtemsBarrierReqCreate_PreDesc_Free[] = {
192  "Yes",
193  "No",
194  "NA"
195};
196
197static const char * const * const RtemsBarrierReqCreate_PreDesc[] = {
198  RtemsBarrierReqCreate_PreDesc_Name,
199  RtemsBarrierReqCreate_PreDesc_Class,
200  RtemsBarrierReqCreate_PreDesc_MaxWait,
201  RtemsBarrierReqCreate_PreDesc_Id,
202  RtemsBarrierReqCreate_PreDesc_Free,
203  NULL
204};
205
206#define NAME rtems_build_name( 'T', 'E', 'S', 'T' )
207
208#define INVALID_ID 0xffffffff
209
210typedef RtemsBarrierReqCreate_Context Context;
211
212typedef enum {
213  PRIO_NORMAL = 1,
214  PRIO_LOW
215} Priorities;
216
217static void Worker( rtems_task_argument arg )
218{
219  Context *ctx;
220
221  ctx = (Context *) arg;
222
223  while ( true ) {
224    rtems_status_code sc;
225    uint32_t          released;
226
227    ++ctx->release_done;
228
229    released = 0;
230    sc = rtems_barrier_release( ctx->id_value, &released );
231    T_rsc_success( sc );
232    T_eq_u32( released, 1 );
233  }
234}
235
236static rtems_status_code Create( void *arg, uint32_t *id )
237{
238  return rtems_barrier_create(
239    rtems_build_name( 'S', 'I', 'Z', 'E' ),
240    RTEMS_DEFAULT_ATTRIBUTES,
241    0,
242    id
243  );
244}
245
246static void RtemsBarrierReqCreate_Pre_Name_Prepare(
247  RtemsBarrierReqCreate_Context *ctx,
248  RtemsBarrierReqCreate_Pre_Name state
249)
250{
251  switch ( state ) {
252    case RtemsBarrierReqCreate_Pre_Name_Valid: {
253      /*
254       * The ``name`` parameter shall be valid.
255       */
256      ctx->name = NAME;
257      break;
258    }
259
260    case RtemsBarrierReqCreate_Pre_Name_Invalid: {
261      /*
262       * The ``name`` parameter shall be invalid.
263       */
264      ctx->name = 0;
265      break;
266    }
267
268    case RtemsBarrierReqCreate_Pre_Name_NA:
269      break;
270  }
271}
272
273static void RtemsBarrierReqCreate_Pre_Class_Prepare(
274  RtemsBarrierReqCreate_Context  *ctx,
275  RtemsBarrierReqCreate_Pre_Class state
276)
277{
278  switch ( state ) {
279    case RtemsBarrierReqCreate_Pre_Class_Default: {
280      /*
281       * The ``attribute_set`` parameter shall specify the default
282       * class.
283       */
284      /* Nothing to do */
285      break;
286    }
287
288    case RtemsBarrierReqCreate_Pre_Class_Manual: {
289      /*
290       * The ``attribute_set`` parameter shall specify the manual
291       * release class.
292       */
293      ctx->attribute_set |= RTEMS_BARRIER_MANUAL_RELEASE;
294      break;
295    }
296
297    case RtemsBarrierReqCreate_Pre_Class_Auto: {
298      /*
299       * The ``attribute_set`` parameter shall specify the
300       * automatic release class.
301       */
302      ctx->attribute_set |= RTEMS_BARRIER_AUTOMATIC_RELEASE;
303      break;
304    }
305
306    case RtemsBarrierReqCreate_Pre_Class_NA:
307      break;
308  }
309}
310
311static void RtemsBarrierReqCreate_Pre_MaxWait_Prepare(
312  RtemsBarrierReqCreate_Context    *ctx,
313  RtemsBarrierReqCreate_Pre_MaxWait state
314)
315{
316  switch ( state ) {
317    case RtemsBarrierReqCreate_Pre_MaxWait_Zero: {
318      /*
319       * The ``maximum_waiters`` parameter shall be zero.
320       */
321      ctx->maximum_waiters = 0;
322      break;
323    }
324
325    case RtemsBarrierReqCreate_Pre_MaxWait_Positive: {
326      /*
327       * The ``maximum_waiters`` parameter shall be positive.
328       */
329      ctx->maximum_waiters = 1;
330      break;
331    }
332
333    case RtemsBarrierReqCreate_Pre_MaxWait_NA:
334      break;
335  }
336}
337
338static void RtemsBarrierReqCreate_Pre_Id_Prepare(
339  RtemsBarrierReqCreate_Context *ctx,
340  RtemsBarrierReqCreate_Pre_Id   state
341)
342{
343  switch ( state ) {
344    case RtemsBarrierReqCreate_Pre_Id_Valid: {
345      /*
346       * The ``id`` parameter shall reference an object
347       * identifier value.
348       */
349      ctx->id = &ctx->id_value;
350      break;
351    }
352
353    case RtemsBarrierReqCreate_Pre_Id_Null: {
354      /*
355       * The ``id`` parameter shall be
356       * NULL.
357       */
358      ctx->id = NULL;
359      break;
360    }
361
362    case RtemsBarrierReqCreate_Pre_Id_NA:
363      break;
364  }
365}
366
367static void RtemsBarrierReqCreate_Pre_Free_Prepare(
368  RtemsBarrierReqCreate_Context *ctx,
369  RtemsBarrierReqCreate_Pre_Free state
370)
371{
372  switch ( state ) {
373    case RtemsBarrierReqCreate_Pre_Free_Yes: {
374      /*
375       * The system shall have at least one inactive barrier object available.
376       */
377      /* Nothing to do */
378      break;
379    }
380
381    case RtemsBarrierReqCreate_Pre_Free_No: {
382      /*
383       * The system shall have no inactive partition object available.
384       */
385      ctx->seized_objects = T_seize_objects( Create, NULL );
386      break;
387    }
388
389    case RtemsBarrierReqCreate_Pre_Free_NA:
390      break;
391  }
392}
393
394static void RtemsBarrierReqCreate_Post_Status_Check(
395  RtemsBarrierReqCreate_Context    *ctx,
396  RtemsBarrierReqCreate_Post_Status state
397)
398{
399  switch ( state ) {
400    case RtemsBarrierReqCreate_Post_Status_Ok: {
401      /*
402       * The return status of rtems_barrier_create() shall be
403       * RTEMS_SUCCESSFUL.
404       */
405      T_rsc_success( ctx->status );
406      break;
407    }
408
409    case RtemsBarrierReqCreate_Post_Status_InvName: {
410      /*
411       * The return status of rtems_barrier_create() shall be
412       * RTEMS_INVALID_NAME.
413       */
414      T_rsc( ctx->status, RTEMS_INVALID_NAME );
415      break;
416    }
417
418    case RtemsBarrierReqCreate_Post_Status_InvAddr: {
419      /*
420       * The return status of rtems_barrier_create() shall be
421       * RTEMS_INVALID_ADDRESS.
422       */
423      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
424      break;
425    }
426
427    case RtemsBarrierReqCreate_Post_Status_InvNum: {
428      /*
429       * The return status of rtems_barrier_create() shall be
430       * RTEMS_INVALID_NUMBER.
431       */
432      T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
433      break;
434    }
435
436    case RtemsBarrierReqCreate_Post_Status_TooMany: {
437      /*
438       * The return status of rtems_barrier_create() shall be
439       * RTEMS_TOO_MANY.
440       */
441      T_rsc( ctx->status, RTEMS_TOO_MANY );
442      break;
443    }
444
445    case RtemsBarrierReqCreate_Post_Status_NA:
446      break;
447  }
448}
449
450static void RtemsBarrierReqCreate_Post_Name_Check(
451  RtemsBarrierReqCreate_Context  *ctx,
452  RtemsBarrierReqCreate_Post_Name state
453)
454{
455  rtems_status_code sc;
456  rtems_id          id;
457
458  switch ( state ) {
459    case RtemsBarrierReqCreate_Post_Name_Valid: {
460      /*
461       * The unique object name shall identify the barrier created by the
462       * rtems_barrier_create() call.
463       */
464      id = 0;
465      sc = rtems_barrier_ident( NAME, &id );
466      T_rsc_success( sc );
467      T_eq_u32( id, ctx->id_value );
468      break;
469    }
470
471    case RtemsBarrierReqCreate_Post_Name_Invalid: {
472      /*
473       * The unique object name shall not identify a barrier.
474       */
475      sc = rtems_barrier_ident( NAME, &id );
476      T_rsc( sc, RTEMS_INVALID_NAME );
477      break;
478    }
479
480    case RtemsBarrierReqCreate_Post_Name_NA:
481      break;
482  }
483}
484
485static void RtemsBarrierReqCreate_Post_Class_Check(
486  RtemsBarrierReqCreate_Context   *ctx,
487  RtemsBarrierReqCreate_Post_Class state
488)
489{
490  rtems_status_code sc;
491
492  switch ( state ) {
493    case RtemsBarrierReqCreate_Post_Class_NoObj: {
494      /*
495       * The barrier class is not applicable since there was no barrier created.
496       */
497      /* Not applicable */
498      break;
499    }
500
501    case RtemsBarrierReqCreate_Post_Class_Manual: {
502      /*
503       * The class of the barrier shall be manual release.
504       */
505      sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
506      T_rsc_success( sc );
507
508      ++ctx->release_expected;
509      T_eq_u32( ctx->release_done, ctx->release_expected );
510      break;
511    }
512
513    case RtemsBarrierReqCreate_Post_Class_Auto: {
514      /*
515       * The class of the barrier shall be automatic release.
516       */
517      sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
518      T_rsc_success( sc );
519
520      T_eq_u32( ctx->release_done, ctx->release_expected );
521      break;
522    }
523
524    case RtemsBarrierReqCreate_Post_Class_NA:
525      break;
526  }
527}
528
529static void RtemsBarrierReqCreate_Post_IdValue_Check(
530  RtemsBarrierReqCreate_Context     *ctx,
531  RtemsBarrierReqCreate_Post_IdValue state
532)
533{
534  switch ( state ) {
535    case RtemsBarrierReqCreate_Post_IdValue_Assigned: {
536      /*
537       * The value of the object identifier variable shall be equal to the object
538       * identifier of the barrier created by the rtems_barrier_create() call.
539       */
540      T_eq_ptr( ctx->id, &ctx->id_value );
541      T_ne_u32( ctx->id_value, INVALID_ID );
542      break;
543    }
544
545    case RtemsBarrierReqCreate_Post_IdValue_Unchanged: {
546      /*
547       * The value of the object identifier variable shall be unchanged by the
548       * rtems_barrier_create() call.
549       */
550      T_eq_u32( ctx->id_value, INVALID_ID );
551      break;
552    }
553
554    case RtemsBarrierReqCreate_Post_IdValue_NA:
555      break;
556  }
557}
558
559static void RtemsBarrierReqCreate_Setup( RtemsBarrierReqCreate_Context *ctx )
560{
561  rtems_status_code sc;
562
563  memset( ctx, 0, sizeof( *ctx ) );
564  ctx->id_value = INVALID_ID;
565
566  sc = rtems_task_create(
567    rtems_build_name( 'W', 'O', 'R', 'K' ),
568    PRIO_LOW,
569    RTEMS_MINIMUM_STACK_SIZE,
570    RTEMS_DEFAULT_MODES,
571    RTEMS_DEFAULT_ATTRIBUTES,
572    &ctx->worker_id
573  );
574  T_assert_rsc_success( sc );
575
576  sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
577  T_assert_rsc_success( sc );
578}
579
580static void RtemsBarrierReqCreate_Setup_Wrap( void *arg )
581{
582  RtemsBarrierReqCreate_Context *ctx;
583
584  ctx = arg;
585  ctx->in_action_loop = false;
586  RtemsBarrierReqCreate_Setup( ctx );
587}
588
589static void RtemsBarrierReqCreate_Teardown(
590  RtemsBarrierReqCreate_Context *ctx
591)
592{
593  rtems_status_code sc;
594
595  if ( ctx->worker_id != 0 ) {
596    sc = rtems_task_delete( ctx->worker_id );
597    T_rsc_success( sc );
598  }
599}
600
601static void RtemsBarrierReqCreate_Teardown_Wrap( void *arg )
602{
603  RtemsBarrierReqCreate_Context *ctx;
604
605  ctx = arg;
606  ctx->in_action_loop = false;
607  RtemsBarrierReqCreate_Teardown( ctx );
608}
609
610static size_t RtemsBarrierReqCreate_Scope( void *arg, char *buf, size_t n )
611{
612  RtemsBarrierReqCreate_Context *ctx;
613
614  ctx = arg;
615
616  if ( ctx->in_action_loop ) {
617    return T_get_scope( RtemsBarrierReqCreate_PreDesc, buf, n, ctx->pcs );
618  }
619
620  return 0;
621}
622
623static T_fixture RtemsBarrierReqCreate_Fixture = {
624  .setup = RtemsBarrierReqCreate_Setup_Wrap,
625  .stop = NULL,
626  .teardown = RtemsBarrierReqCreate_Teardown_Wrap,
627  .scope = RtemsBarrierReqCreate_Scope,
628  .initial_context = &RtemsBarrierReqCreate_Instance
629};
630
631static const uint8_t RtemsBarrierReqCreate_TransitionMap[][ 4 ] = {
632  {
633    RtemsBarrierReqCreate_Post_Status_Ok,
634    RtemsBarrierReqCreate_Post_Name_Valid,
635    RtemsBarrierReqCreate_Post_Class_Manual,
636    RtemsBarrierReqCreate_Post_IdValue_Assigned
637  }, {
638    RtemsBarrierReqCreate_Post_Status_TooMany,
639    RtemsBarrierReqCreate_Post_Name_Invalid,
640    RtemsBarrierReqCreate_Post_Class_NoObj,
641    RtemsBarrierReqCreate_Post_IdValue_Unchanged
642  }, {
643    RtemsBarrierReqCreate_Post_Status_InvAddr,
644    RtemsBarrierReqCreate_Post_Name_Invalid,
645    RtemsBarrierReqCreate_Post_Class_NoObj,
646    RtemsBarrierReqCreate_Post_IdValue_Unchanged
647  }, {
648    RtemsBarrierReqCreate_Post_Status_InvAddr,
649    RtemsBarrierReqCreate_Post_Name_Invalid,
650    RtemsBarrierReqCreate_Post_Class_NoObj,
651    RtemsBarrierReqCreate_Post_IdValue_Unchanged
652  }, {
653    RtemsBarrierReqCreate_Post_Status_Ok,
654    RtemsBarrierReqCreate_Post_Name_Valid,
655    RtemsBarrierReqCreate_Post_Class_Manual,
656    RtemsBarrierReqCreate_Post_IdValue_Assigned
657  }, {
658    RtemsBarrierReqCreate_Post_Status_TooMany,
659    RtemsBarrierReqCreate_Post_Name_Invalid,
660    RtemsBarrierReqCreate_Post_Class_NoObj,
661    RtemsBarrierReqCreate_Post_IdValue_Unchanged
662  }, {
663    RtemsBarrierReqCreate_Post_Status_InvAddr,
664    RtemsBarrierReqCreate_Post_Name_Invalid,
665    RtemsBarrierReqCreate_Post_Class_NoObj,
666    RtemsBarrierReqCreate_Post_IdValue_Unchanged
667  }, {
668    RtemsBarrierReqCreate_Post_Status_InvAddr,
669    RtemsBarrierReqCreate_Post_Name_Invalid,
670    RtemsBarrierReqCreate_Post_Class_NoObj,
671    RtemsBarrierReqCreate_Post_IdValue_Unchanged
672  }, {
673    RtemsBarrierReqCreate_Post_Status_Ok,
674    RtemsBarrierReqCreate_Post_Name_Valid,
675    RtemsBarrierReqCreate_Post_Class_Manual,
676    RtemsBarrierReqCreate_Post_IdValue_Assigned
677  }, {
678    RtemsBarrierReqCreate_Post_Status_TooMany,
679    RtemsBarrierReqCreate_Post_Name_Invalid,
680    RtemsBarrierReqCreate_Post_Class_NoObj,
681    RtemsBarrierReqCreate_Post_IdValue_Unchanged
682  }, {
683    RtemsBarrierReqCreate_Post_Status_InvAddr,
684    RtemsBarrierReqCreate_Post_Name_Invalid,
685    RtemsBarrierReqCreate_Post_Class_NoObj,
686    RtemsBarrierReqCreate_Post_IdValue_Unchanged
687  }, {
688    RtemsBarrierReqCreate_Post_Status_InvAddr,
689    RtemsBarrierReqCreate_Post_Name_Invalid,
690    RtemsBarrierReqCreate_Post_Class_NoObj,
691    RtemsBarrierReqCreate_Post_IdValue_Unchanged
692  }, {
693    RtemsBarrierReqCreate_Post_Status_Ok,
694    RtemsBarrierReqCreate_Post_Name_Valid,
695    RtemsBarrierReqCreate_Post_Class_Manual,
696    RtemsBarrierReqCreate_Post_IdValue_Assigned
697  }, {
698    RtemsBarrierReqCreate_Post_Status_TooMany,
699    RtemsBarrierReqCreate_Post_Name_Invalid,
700    RtemsBarrierReqCreate_Post_Class_NoObj,
701    RtemsBarrierReqCreate_Post_IdValue_Unchanged
702  }, {
703    RtemsBarrierReqCreate_Post_Status_InvAddr,
704    RtemsBarrierReqCreate_Post_Name_Invalid,
705    RtemsBarrierReqCreate_Post_Class_NoObj,
706    RtemsBarrierReqCreate_Post_IdValue_Unchanged
707  }, {
708    RtemsBarrierReqCreate_Post_Status_InvAddr,
709    RtemsBarrierReqCreate_Post_Name_Invalid,
710    RtemsBarrierReqCreate_Post_Class_NoObj,
711    RtemsBarrierReqCreate_Post_IdValue_Unchanged
712  }, {
713    RtemsBarrierReqCreate_Post_Status_InvNum,
714    RtemsBarrierReqCreate_Post_Name_Invalid,
715    RtemsBarrierReqCreate_Post_Class_NoObj,
716    RtemsBarrierReqCreate_Post_IdValue_Unchanged
717  }, {
718    RtemsBarrierReqCreate_Post_Status_InvNum,
719    RtemsBarrierReqCreate_Post_Name_Invalid,
720    RtemsBarrierReqCreate_Post_Class_NoObj,
721    RtemsBarrierReqCreate_Post_IdValue_Unchanged
722  }, {
723    RtemsBarrierReqCreate_Post_Status_InvAddr,
724    RtemsBarrierReqCreate_Post_Name_Invalid,
725    RtemsBarrierReqCreate_Post_Class_NoObj,
726    RtemsBarrierReqCreate_Post_IdValue_Unchanged
727  }, {
728    RtemsBarrierReqCreate_Post_Status_InvAddr,
729    RtemsBarrierReqCreate_Post_Name_Invalid,
730    RtemsBarrierReqCreate_Post_Class_NoObj,
731    RtemsBarrierReqCreate_Post_IdValue_Unchanged
732  }, {
733    RtemsBarrierReqCreate_Post_Status_Ok,
734    RtemsBarrierReqCreate_Post_Name_Valid,
735    RtemsBarrierReqCreate_Post_Class_Auto,
736    RtemsBarrierReqCreate_Post_IdValue_Assigned
737  }, {
738    RtemsBarrierReqCreate_Post_Status_TooMany,
739    RtemsBarrierReqCreate_Post_Name_Invalid,
740    RtemsBarrierReqCreate_Post_Class_NoObj,
741    RtemsBarrierReqCreate_Post_IdValue_Unchanged
742  }, {
743    RtemsBarrierReqCreate_Post_Status_InvAddr,
744    RtemsBarrierReqCreate_Post_Name_Invalid,
745    RtemsBarrierReqCreate_Post_Class_NoObj,
746    RtemsBarrierReqCreate_Post_IdValue_Unchanged
747  }, {
748    RtemsBarrierReqCreate_Post_Status_InvAddr,
749    RtemsBarrierReqCreate_Post_Name_Invalid,
750    RtemsBarrierReqCreate_Post_Class_NoObj,
751    RtemsBarrierReqCreate_Post_IdValue_Unchanged
752  }, {
753    RtemsBarrierReqCreate_Post_Status_InvName,
754    RtemsBarrierReqCreate_Post_Name_Invalid,
755    RtemsBarrierReqCreate_Post_Class_NoObj,
756    RtemsBarrierReqCreate_Post_IdValue_Unchanged
757  }, {
758    RtemsBarrierReqCreate_Post_Status_InvName,
759    RtemsBarrierReqCreate_Post_Name_Invalid,
760    RtemsBarrierReqCreate_Post_Class_NoObj,
761    RtemsBarrierReqCreate_Post_IdValue_Unchanged
762  }, {
763    RtemsBarrierReqCreate_Post_Status_InvName,
764    RtemsBarrierReqCreate_Post_Name_Invalid,
765    RtemsBarrierReqCreate_Post_Class_NoObj,
766    RtemsBarrierReqCreate_Post_IdValue_Unchanged
767  }, {
768    RtemsBarrierReqCreate_Post_Status_InvName,
769    RtemsBarrierReqCreate_Post_Name_Invalid,
770    RtemsBarrierReqCreate_Post_Class_NoObj,
771    RtemsBarrierReqCreate_Post_IdValue_Unchanged
772  }, {
773    RtemsBarrierReqCreate_Post_Status_InvName,
774    RtemsBarrierReqCreate_Post_Name_Invalid,
775    RtemsBarrierReqCreate_Post_Class_NoObj,
776    RtemsBarrierReqCreate_Post_IdValue_Unchanged
777  }, {
778    RtemsBarrierReqCreate_Post_Status_InvName,
779    RtemsBarrierReqCreate_Post_Name_Invalid,
780    RtemsBarrierReqCreate_Post_Class_NoObj,
781    RtemsBarrierReqCreate_Post_IdValue_Unchanged
782  }, {
783    RtemsBarrierReqCreate_Post_Status_InvName,
784    RtemsBarrierReqCreate_Post_Name_Invalid,
785    RtemsBarrierReqCreate_Post_Class_NoObj,
786    RtemsBarrierReqCreate_Post_IdValue_Unchanged
787  }, {
788    RtemsBarrierReqCreate_Post_Status_InvName,
789    RtemsBarrierReqCreate_Post_Name_Invalid,
790    RtemsBarrierReqCreate_Post_Class_NoObj,
791    RtemsBarrierReqCreate_Post_IdValue_Unchanged
792  }, {
793    RtemsBarrierReqCreate_Post_Status_InvName,
794    RtemsBarrierReqCreate_Post_Name_Invalid,
795    RtemsBarrierReqCreate_Post_Class_NoObj,
796    RtemsBarrierReqCreate_Post_IdValue_Unchanged
797  }, {
798    RtemsBarrierReqCreate_Post_Status_InvName,
799    RtemsBarrierReqCreate_Post_Name_Invalid,
800    RtemsBarrierReqCreate_Post_Class_NoObj,
801    RtemsBarrierReqCreate_Post_IdValue_Unchanged
802  }, {
803    RtemsBarrierReqCreate_Post_Status_InvName,
804    RtemsBarrierReqCreate_Post_Name_Invalid,
805    RtemsBarrierReqCreate_Post_Class_NoObj,
806    RtemsBarrierReqCreate_Post_IdValue_Unchanged
807  }, {
808    RtemsBarrierReqCreate_Post_Status_InvName,
809    RtemsBarrierReqCreate_Post_Name_Invalid,
810    RtemsBarrierReqCreate_Post_Class_NoObj,
811    RtemsBarrierReqCreate_Post_IdValue_Unchanged
812  }, {
813    RtemsBarrierReqCreate_Post_Status_InvName,
814    RtemsBarrierReqCreate_Post_Name_Invalid,
815    RtemsBarrierReqCreate_Post_Class_NoObj,
816    RtemsBarrierReqCreate_Post_IdValue_Unchanged
817  }, {
818    RtemsBarrierReqCreate_Post_Status_InvName,
819    RtemsBarrierReqCreate_Post_Name_Invalid,
820    RtemsBarrierReqCreate_Post_Class_NoObj,
821    RtemsBarrierReqCreate_Post_IdValue_Unchanged
822  }, {
823    RtemsBarrierReqCreate_Post_Status_InvName,
824    RtemsBarrierReqCreate_Post_Name_Invalid,
825    RtemsBarrierReqCreate_Post_Class_NoObj,
826    RtemsBarrierReqCreate_Post_IdValue_Unchanged
827  }, {
828    RtemsBarrierReqCreate_Post_Status_InvName,
829    RtemsBarrierReqCreate_Post_Name_Invalid,
830    RtemsBarrierReqCreate_Post_Class_NoObj,
831    RtemsBarrierReqCreate_Post_IdValue_Unchanged
832  }, {
833    RtemsBarrierReqCreate_Post_Status_InvName,
834    RtemsBarrierReqCreate_Post_Name_Invalid,
835    RtemsBarrierReqCreate_Post_Class_NoObj,
836    RtemsBarrierReqCreate_Post_IdValue_Unchanged
837  }, {
838    RtemsBarrierReqCreate_Post_Status_InvName,
839    RtemsBarrierReqCreate_Post_Name_Invalid,
840    RtemsBarrierReqCreate_Post_Class_NoObj,
841    RtemsBarrierReqCreate_Post_IdValue_Unchanged
842  }, {
843    RtemsBarrierReqCreate_Post_Status_InvName,
844    RtemsBarrierReqCreate_Post_Name_Invalid,
845    RtemsBarrierReqCreate_Post_Class_NoObj,
846    RtemsBarrierReqCreate_Post_IdValue_Unchanged
847  }, {
848    RtemsBarrierReqCreate_Post_Status_InvName,
849    RtemsBarrierReqCreate_Post_Name_Invalid,
850    RtemsBarrierReqCreate_Post_Class_NoObj,
851    RtemsBarrierReqCreate_Post_IdValue_Unchanged
852  }, {
853    RtemsBarrierReqCreate_Post_Status_InvName,
854    RtemsBarrierReqCreate_Post_Name_Invalid,
855    RtemsBarrierReqCreate_Post_Class_NoObj,
856    RtemsBarrierReqCreate_Post_IdValue_Unchanged
857  }, {
858    RtemsBarrierReqCreate_Post_Status_InvName,
859    RtemsBarrierReqCreate_Post_Name_Invalid,
860    RtemsBarrierReqCreate_Post_Class_NoObj,
861    RtemsBarrierReqCreate_Post_IdValue_Unchanged
862  }, {
863    RtemsBarrierReqCreate_Post_Status_InvName,
864    RtemsBarrierReqCreate_Post_Name_Invalid,
865    RtemsBarrierReqCreate_Post_Class_NoObj,
866    RtemsBarrierReqCreate_Post_IdValue_Unchanged
867  }, {
868    RtemsBarrierReqCreate_Post_Status_InvName,
869    RtemsBarrierReqCreate_Post_Name_Invalid,
870    RtemsBarrierReqCreate_Post_Class_NoObj,
871    RtemsBarrierReqCreate_Post_IdValue_Unchanged
872  }
873};
874
875static const struct {
876  uint8_t Skip : 1;
877  uint8_t Pre_Name_NA : 1;
878  uint8_t Pre_Class_NA : 1;
879  uint8_t Pre_MaxWait_NA : 1;
880  uint8_t Pre_Id_NA : 1;
881  uint8_t Pre_Free_NA : 1;
882} RtemsBarrierReqCreate_TransitionInfo[] = {
883  {
884    0, 0, 0, 0, 0, 0
885  }, {
886    0, 0, 0, 0, 0, 0
887  }, {
888    0, 0, 0, 0, 0, 0
889  }, {
890    0, 0, 0, 0, 0, 0
891  }, {
892    0, 0, 0, 0, 0, 0
893  }, {
894    0, 0, 0, 0, 0, 0
895  }, {
896    0, 0, 0, 0, 0, 0
897  }, {
898    0, 0, 0, 0, 0, 0
899  }, {
900    0, 0, 0, 0, 0, 0
901  }, {
902    0, 0, 0, 0, 0, 0
903  }, {
904    0, 0, 0, 0, 0, 0
905  }, {
906    0, 0, 0, 0, 0, 0
907  }, {
908    0, 0, 0, 0, 0, 0
909  }, {
910    0, 0, 0, 0, 0, 0
911  }, {
912    0, 0, 0, 0, 0, 0
913  }, {
914    0, 0, 0, 0, 0, 0
915  }, {
916    0, 0, 0, 0, 0, 0
917  }, {
918    0, 0, 0, 0, 0, 0
919  }, {
920    0, 0, 0, 0, 0, 0
921  }, {
922    0, 0, 0, 0, 0, 0
923  }, {
924    0, 0, 0, 0, 0, 0
925  }, {
926    0, 0, 0, 0, 0, 0
927  }, {
928    0, 0, 0, 0, 0, 0
929  }, {
930    0, 0, 0, 0, 0, 0
931  }, {
932    0, 0, 0, 0, 0, 0
933  }, {
934    0, 0, 0, 0, 0, 0
935  }, {
936    0, 0, 0, 0, 0, 0
937  }, {
938    0, 0, 0, 0, 0, 0
939  }, {
940    0, 0, 0, 0, 0, 0
941  }, {
942    0, 0, 0, 0, 0, 0
943  }, {
944    0, 0, 0, 0, 0, 0
945  }, {
946    0, 0, 0, 0, 0, 0
947  }, {
948    0, 0, 0, 0, 0, 0
949  }, {
950    0, 0, 0, 0, 0, 0
951  }, {
952    0, 0, 0, 0, 0, 0
953  }, {
954    0, 0, 0, 0, 0, 0
955  }, {
956    0, 0, 0, 0, 0, 0
957  }, {
958    0, 0, 0, 0, 0, 0
959  }, {
960    0, 0, 0, 0, 0, 0
961  }, {
962    0, 0, 0, 0, 0, 0
963  }, {
964    0, 0, 0, 0, 0, 0
965  }, {
966    0, 0, 0, 0, 0, 0
967  }, {
968    0, 0, 0, 0, 0, 0
969  }, {
970    0, 0, 0, 0, 0, 0
971  }, {
972    0, 0, 0, 0, 0, 0
973  }, {
974    0, 0, 0, 0, 0, 0
975  }, {
976    0, 0, 0, 0, 0, 0
977  }, {
978    0, 0, 0, 0, 0, 0
979  }
980};
981
982static void RtemsBarrierReqCreate_Action( RtemsBarrierReqCreate_Context *ctx )
983{
984  ctx->status = rtems_barrier_create(
985    ctx->name,
986    ctx->attribute_set,
987    ctx->maximum_waiters,
988    ctx->id
989  );
990}
991
992static void RtemsBarrierReqCreate_Cleanup( RtemsBarrierReqCreate_Context *ctx )
993{
994  if ( ctx->id_value != INVALID_ID ) {
995    rtems_status_code sc;
996
997    sc = rtems_barrier_delete( ctx->id_value );
998    T_rsc_success( sc );
999
1000    ctx->id_value = INVALID_ID;
1001  }
1002
1003  T_surrender_objects( &ctx->seized_objects, rtems_barrier_delete );
1004}
1005
1006/**
1007 * @fn void T_case_body_RtemsBarrierReqCreate( void )
1008 */
1009T_TEST_CASE_FIXTURE( RtemsBarrierReqCreate, &RtemsBarrierReqCreate_Fixture )
1010{
1011  RtemsBarrierReqCreate_Context *ctx;
1012  size_t index;
1013
1014  ctx = T_fixture_context();
1015  ctx->in_action_loop = true;
1016  index = 0;
1017
1018  for (
1019    ctx->pcs[ 0 ] = RtemsBarrierReqCreate_Pre_Name_Valid;
1020    ctx->pcs[ 0 ] < RtemsBarrierReqCreate_Pre_Name_NA;
1021    ++ctx->pcs[ 0 ]
1022  ) {
1023    if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Name_NA ) {
1024      ctx->pcs[ 0 ] = RtemsBarrierReqCreate_Pre_Name_NA;
1025      index += ( RtemsBarrierReqCreate_Pre_Name_NA - 1 )
1026        * RtemsBarrierReqCreate_Pre_Class_NA
1027        * RtemsBarrierReqCreate_Pre_MaxWait_NA
1028        * RtemsBarrierReqCreate_Pre_Id_NA
1029        * RtemsBarrierReqCreate_Pre_Free_NA;
1030    }
1031
1032    for (
1033      ctx->pcs[ 1 ] = RtemsBarrierReqCreate_Pre_Class_Default;
1034      ctx->pcs[ 1 ] < RtemsBarrierReqCreate_Pre_Class_NA;
1035      ++ctx->pcs[ 1 ]
1036    ) {
1037      if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Class_NA ) {
1038        ctx->pcs[ 1 ] = RtemsBarrierReqCreate_Pre_Class_NA;
1039        index += ( RtemsBarrierReqCreate_Pre_Class_NA - 1 )
1040          * RtemsBarrierReqCreate_Pre_MaxWait_NA
1041          * RtemsBarrierReqCreate_Pre_Id_NA
1042          * RtemsBarrierReqCreate_Pre_Free_NA;
1043      }
1044
1045      for (
1046        ctx->pcs[ 2 ] = RtemsBarrierReqCreate_Pre_MaxWait_Zero;
1047        ctx->pcs[ 2 ] < RtemsBarrierReqCreate_Pre_MaxWait_NA;
1048        ++ctx->pcs[ 2 ]
1049      ) {
1050        if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_MaxWait_NA ) {
1051          ctx->pcs[ 2 ] = RtemsBarrierReqCreate_Pre_MaxWait_NA;
1052          index += ( RtemsBarrierReqCreate_Pre_MaxWait_NA - 1 )
1053            * RtemsBarrierReqCreate_Pre_Id_NA
1054            * RtemsBarrierReqCreate_Pre_Free_NA;
1055        }
1056
1057        for (
1058          ctx->pcs[ 3 ] = RtemsBarrierReqCreate_Pre_Id_Valid;
1059          ctx->pcs[ 3 ] < RtemsBarrierReqCreate_Pre_Id_NA;
1060          ++ctx->pcs[ 3 ]
1061        ) {
1062          if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Id_NA ) {
1063            ctx->pcs[ 3 ] = RtemsBarrierReqCreate_Pre_Id_NA;
1064            index += ( RtemsBarrierReqCreate_Pre_Id_NA - 1 )
1065              * RtemsBarrierReqCreate_Pre_Free_NA;
1066          }
1067
1068          for (
1069            ctx->pcs[ 4 ] = RtemsBarrierReqCreate_Pre_Free_Yes;
1070            ctx->pcs[ 4 ] < RtemsBarrierReqCreate_Pre_Free_NA;
1071            ++ctx->pcs[ 4 ]
1072          ) {
1073            if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Free_NA ) {
1074              ctx->pcs[ 4 ] = RtemsBarrierReqCreate_Pre_Free_NA;
1075              index += ( RtemsBarrierReqCreate_Pre_Free_NA - 1 );
1076            }
1077
1078            if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Skip ) {
1079              ++index;
1080              continue;
1081            }
1082
1083            RtemsBarrierReqCreate_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] );
1084            RtemsBarrierReqCreate_Pre_Class_Prepare( ctx, ctx->pcs[ 1 ] );
1085            RtemsBarrierReqCreate_Pre_MaxWait_Prepare( ctx, ctx->pcs[ 2 ] );
1086            RtemsBarrierReqCreate_Pre_Id_Prepare( ctx, ctx->pcs[ 3 ] );
1087            RtemsBarrierReqCreate_Pre_Free_Prepare( ctx, ctx->pcs[ 4 ] );
1088            RtemsBarrierReqCreate_Action( ctx );
1089            RtemsBarrierReqCreate_Post_Status_Check(
1090              ctx,
1091              RtemsBarrierReqCreate_TransitionMap[ index ][ 0 ]
1092            );
1093            RtemsBarrierReqCreate_Post_Name_Check(
1094              ctx,
1095              RtemsBarrierReqCreate_TransitionMap[ index ][ 1 ]
1096            );
1097            RtemsBarrierReqCreate_Post_Class_Check(
1098              ctx,
1099              RtemsBarrierReqCreate_TransitionMap[ index ][ 2 ]
1100            );
1101            RtemsBarrierReqCreate_Post_IdValue_Check(
1102              ctx,
1103              RtemsBarrierReqCreate_TransitionMap[ index ][ 3 ]
1104            );
1105            RtemsBarrierReqCreate_Cleanup( ctx );
1106            ++index;
1107          }
1108        }
1109      }
1110    }
1111  }
1112}
1113
1114/** @} */
Note: See TracBrowser for help on using the repository browser.