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

Last change on this file since c0c4b8b was c0c4b8b, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 2, 2021 at 6:54:17 AM

validation: Format comment blocks

  • Property mode set to 100644
File size: 29.8 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 class.
282       */
283      /* Nothing to do */
284      break;
285    }
286
287    case RtemsBarrierReqCreate_Pre_Class_Manual: {
288      /*
289       * The ``attribute_set`` parameter shall specify the manual release
290       * class.
291       */
292      ctx->attribute_set |= RTEMS_BARRIER_MANUAL_RELEASE;
293      break;
294    }
295
296    case RtemsBarrierReqCreate_Pre_Class_Auto: {
297      /*
298       * The ``attribute_set`` parameter shall specify the automatic release
299       * class.
300       */
301      ctx->attribute_set |= RTEMS_BARRIER_AUTOMATIC_RELEASE;
302      break;
303    }
304
305    case RtemsBarrierReqCreate_Pre_Class_NA:
306      break;
307  }
308}
309
310static void RtemsBarrierReqCreate_Pre_MaxWait_Prepare(
311  RtemsBarrierReqCreate_Context    *ctx,
312  RtemsBarrierReqCreate_Pre_MaxWait state
313)
314{
315  switch ( state ) {
316    case RtemsBarrierReqCreate_Pre_MaxWait_Zero: {
317      /*
318       * The ``maximum_waiters`` parameter shall be zero.
319       */
320      ctx->maximum_waiters = 0;
321      break;
322    }
323
324    case RtemsBarrierReqCreate_Pre_MaxWait_Positive: {
325      /*
326       * The ``maximum_waiters`` parameter shall be positive.
327       */
328      ctx->maximum_waiters = 1;
329      break;
330    }
331
332    case RtemsBarrierReqCreate_Pre_MaxWait_NA:
333      break;
334  }
335}
336
337static void RtemsBarrierReqCreate_Pre_Id_Prepare(
338  RtemsBarrierReqCreate_Context *ctx,
339  RtemsBarrierReqCreate_Pre_Id   state
340)
341{
342  switch ( state ) {
343    case RtemsBarrierReqCreate_Pre_Id_Valid: {
344      /*
345       * The ``id`` parameter shall reference an object identifier value.
346       */
347      ctx->id = &ctx->id_value;
348      break;
349    }
350
351    case RtemsBarrierReqCreate_Pre_Id_Null: {
352      /*
353       * The ``id`` parameter shall be NULL.
354       */
355      ctx->id = NULL;
356      break;
357    }
358
359    case RtemsBarrierReqCreate_Pre_Id_NA:
360      break;
361  }
362}
363
364static void RtemsBarrierReqCreate_Pre_Free_Prepare(
365  RtemsBarrierReqCreate_Context *ctx,
366  RtemsBarrierReqCreate_Pre_Free state
367)
368{
369  switch ( state ) {
370    case RtemsBarrierReqCreate_Pre_Free_Yes: {
371      /*
372       * The system shall have at least one inactive barrier object available.
373       */
374      /* Nothing to do */
375      break;
376    }
377
378    case RtemsBarrierReqCreate_Pre_Free_No: {
379      /*
380       * The system shall have no inactive partition object available.
381       */
382      ctx->seized_objects = T_seize_objects( Create, NULL );
383      break;
384    }
385
386    case RtemsBarrierReqCreate_Pre_Free_NA:
387      break;
388  }
389}
390
391static void RtemsBarrierReqCreate_Post_Status_Check(
392  RtemsBarrierReqCreate_Context    *ctx,
393  RtemsBarrierReqCreate_Post_Status state
394)
395{
396  switch ( state ) {
397    case RtemsBarrierReqCreate_Post_Status_Ok: {
398      /*
399       * The return status of rtems_barrier_create() shall be RTEMS_SUCCESSFUL.
400       */
401      T_rsc_success( ctx->status );
402      break;
403    }
404
405    case RtemsBarrierReqCreate_Post_Status_InvName: {
406      /*
407       * The return status of rtems_barrier_create() shall be
408       * RTEMS_INVALID_NAME.
409       */
410      T_rsc( ctx->status, RTEMS_INVALID_NAME );
411      break;
412    }
413
414    case RtemsBarrierReqCreate_Post_Status_InvAddr: {
415      /*
416       * The return status of rtems_barrier_create() shall be
417       * RTEMS_INVALID_ADDRESS.
418       */
419      T_rsc( ctx->status, RTEMS_INVALID_ADDRESS );
420      break;
421    }
422
423    case RtemsBarrierReqCreate_Post_Status_InvNum: {
424      /*
425       * The return status of rtems_barrier_create() shall be
426       * RTEMS_INVALID_NUMBER.
427       */
428      T_rsc( ctx->status, RTEMS_INVALID_NUMBER );
429      break;
430    }
431
432    case RtemsBarrierReqCreate_Post_Status_TooMany: {
433      /*
434       * The return status of rtems_barrier_create() shall be RTEMS_TOO_MANY.
435       */
436      T_rsc( ctx->status, RTEMS_TOO_MANY );
437      break;
438    }
439
440    case RtemsBarrierReqCreate_Post_Status_NA:
441      break;
442  }
443}
444
445static void RtemsBarrierReqCreate_Post_Name_Check(
446  RtemsBarrierReqCreate_Context  *ctx,
447  RtemsBarrierReqCreate_Post_Name state
448)
449{
450  rtems_status_code sc;
451  rtems_id          id;
452
453  switch ( state ) {
454    case RtemsBarrierReqCreate_Post_Name_Valid: {
455      /*
456       * The unique object name shall identify the barrier created by the
457       * rtems_barrier_create() call.
458       */
459      id = 0;
460      sc = rtems_barrier_ident( NAME, &id );
461      T_rsc_success( sc );
462      T_eq_u32( id, ctx->id_value );
463      break;
464    }
465
466    case RtemsBarrierReqCreate_Post_Name_Invalid: {
467      /*
468       * The unique object name shall not identify a barrier.
469       */
470      sc = rtems_barrier_ident( NAME, &id );
471      T_rsc( sc, RTEMS_INVALID_NAME );
472      break;
473    }
474
475    case RtemsBarrierReqCreate_Post_Name_NA:
476      break;
477  }
478}
479
480static void RtemsBarrierReqCreate_Post_Class_Check(
481  RtemsBarrierReqCreate_Context   *ctx,
482  RtemsBarrierReqCreate_Post_Class state
483)
484{
485  rtems_status_code sc;
486
487  switch ( state ) {
488    case RtemsBarrierReqCreate_Post_Class_NoObj: {
489      /*
490       * The barrier class is not applicable since there was no barrier
491       * created.
492       */
493      /* Not applicable */
494      break;
495    }
496
497    case RtemsBarrierReqCreate_Post_Class_Manual: {
498      /*
499       * The class of the barrier shall be manual release.
500       */
501      sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
502      T_rsc_success( sc );
503
504      ++ctx->release_expected;
505      T_eq_u32( ctx->release_done, ctx->release_expected );
506      break;
507    }
508
509    case RtemsBarrierReqCreate_Post_Class_Auto: {
510      /*
511       * The class of the barrier shall be automatic release.
512       */
513      sc = rtems_barrier_wait( ctx->id_value, RTEMS_NO_TIMEOUT );
514      T_rsc_success( sc );
515
516      T_eq_u32( ctx->release_done, ctx->release_expected );
517      break;
518    }
519
520    case RtemsBarrierReqCreate_Post_Class_NA:
521      break;
522  }
523}
524
525static void RtemsBarrierReqCreate_Post_IdValue_Check(
526  RtemsBarrierReqCreate_Context     *ctx,
527  RtemsBarrierReqCreate_Post_IdValue state
528)
529{
530  switch ( state ) {
531    case RtemsBarrierReqCreate_Post_IdValue_Assigned: {
532      /*
533       * The value of the object identifier variable shall be equal to the
534       * object identifier of the barrier created by the rtems_barrier_create()
535       * call.
536       */
537      T_eq_ptr( ctx->id, &ctx->id_value );
538      T_ne_u32( ctx->id_value, INVALID_ID );
539      break;
540    }
541
542    case RtemsBarrierReqCreate_Post_IdValue_Unchanged: {
543      /*
544       * The value of the object identifier variable shall be unchanged by the
545       * rtems_barrier_create() call.
546       */
547      T_eq_u32( ctx->id_value, INVALID_ID );
548      break;
549    }
550
551    case RtemsBarrierReqCreate_Post_IdValue_NA:
552      break;
553  }
554}
555
556static void RtemsBarrierReqCreate_Setup( RtemsBarrierReqCreate_Context *ctx )
557{
558  rtems_status_code sc;
559
560  memset( ctx, 0, sizeof( *ctx ) );
561  ctx->id_value = INVALID_ID;
562
563  sc = rtems_task_create(
564    rtems_build_name( 'W', 'O', 'R', 'K' ),
565    PRIO_LOW,
566    RTEMS_MINIMUM_STACK_SIZE,
567    RTEMS_DEFAULT_MODES,
568    RTEMS_DEFAULT_ATTRIBUTES,
569    &ctx->worker_id
570  );
571  T_assert_rsc_success( sc );
572
573  sc = rtems_task_start( ctx->worker_id, Worker, (rtems_task_argument) ctx );
574  T_assert_rsc_success( sc );
575}
576
577static void RtemsBarrierReqCreate_Setup_Wrap( void *arg )
578{
579  RtemsBarrierReqCreate_Context *ctx;
580
581  ctx = arg;
582  ctx->in_action_loop = false;
583  RtemsBarrierReqCreate_Setup( ctx );
584}
585
586static void RtemsBarrierReqCreate_Teardown(
587  RtemsBarrierReqCreate_Context *ctx
588)
589{
590  rtems_status_code sc;
591
592  if ( ctx->worker_id != 0 ) {
593    sc = rtems_task_delete( ctx->worker_id );
594    T_rsc_success( sc );
595  }
596}
597
598static void RtemsBarrierReqCreate_Teardown_Wrap( void *arg )
599{
600  RtemsBarrierReqCreate_Context *ctx;
601
602  ctx = arg;
603  ctx->in_action_loop = false;
604  RtemsBarrierReqCreate_Teardown( ctx );
605}
606
607static size_t RtemsBarrierReqCreate_Scope( void *arg, char *buf, size_t n )
608{
609  RtemsBarrierReqCreate_Context *ctx;
610
611  ctx = arg;
612
613  if ( ctx->in_action_loop ) {
614    return T_get_scope( RtemsBarrierReqCreate_PreDesc, buf, n, ctx->pcs );
615  }
616
617  return 0;
618}
619
620static T_fixture RtemsBarrierReqCreate_Fixture = {
621  .setup = RtemsBarrierReqCreate_Setup_Wrap,
622  .stop = NULL,
623  .teardown = RtemsBarrierReqCreate_Teardown_Wrap,
624  .scope = RtemsBarrierReqCreate_Scope,
625  .initial_context = &RtemsBarrierReqCreate_Instance
626};
627
628static const uint8_t RtemsBarrierReqCreate_TransitionMap[][ 4 ] = {
629  {
630    RtemsBarrierReqCreate_Post_Status_Ok,
631    RtemsBarrierReqCreate_Post_Name_Valid,
632    RtemsBarrierReqCreate_Post_Class_Manual,
633    RtemsBarrierReqCreate_Post_IdValue_Assigned
634  }, {
635    RtemsBarrierReqCreate_Post_Status_TooMany,
636    RtemsBarrierReqCreate_Post_Name_Invalid,
637    RtemsBarrierReqCreate_Post_Class_NoObj,
638    RtemsBarrierReqCreate_Post_IdValue_Unchanged
639  }, {
640    RtemsBarrierReqCreate_Post_Status_InvAddr,
641    RtemsBarrierReqCreate_Post_Name_Invalid,
642    RtemsBarrierReqCreate_Post_Class_NoObj,
643    RtemsBarrierReqCreate_Post_IdValue_Unchanged
644  }, {
645    RtemsBarrierReqCreate_Post_Status_InvAddr,
646    RtemsBarrierReqCreate_Post_Name_Invalid,
647    RtemsBarrierReqCreate_Post_Class_NoObj,
648    RtemsBarrierReqCreate_Post_IdValue_Unchanged
649  }, {
650    RtemsBarrierReqCreate_Post_Status_Ok,
651    RtemsBarrierReqCreate_Post_Name_Valid,
652    RtemsBarrierReqCreate_Post_Class_Manual,
653    RtemsBarrierReqCreate_Post_IdValue_Assigned
654  }, {
655    RtemsBarrierReqCreate_Post_Status_TooMany,
656    RtemsBarrierReqCreate_Post_Name_Invalid,
657    RtemsBarrierReqCreate_Post_Class_NoObj,
658    RtemsBarrierReqCreate_Post_IdValue_Unchanged
659  }, {
660    RtemsBarrierReqCreate_Post_Status_InvAddr,
661    RtemsBarrierReqCreate_Post_Name_Invalid,
662    RtemsBarrierReqCreate_Post_Class_NoObj,
663    RtemsBarrierReqCreate_Post_IdValue_Unchanged
664  }, {
665    RtemsBarrierReqCreate_Post_Status_InvAddr,
666    RtemsBarrierReqCreate_Post_Name_Invalid,
667    RtemsBarrierReqCreate_Post_Class_NoObj,
668    RtemsBarrierReqCreate_Post_IdValue_Unchanged
669  }, {
670    RtemsBarrierReqCreate_Post_Status_Ok,
671    RtemsBarrierReqCreate_Post_Name_Valid,
672    RtemsBarrierReqCreate_Post_Class_Manual,
673    RtemsBarrierReqCreate_Post_IdValue_Assigned
674  }, {
675    RtemsBarrierReqCreate_Post_Status_TooMany,
676    RtemsBarrierReqCreate_Post_Name_Invalid,
677    RtemsBarrierReqCreate_Post_Class_NoObj,
678    RtemsBarrierReqCreate_Post_IdValue_Unchanged
679  }, {
680    RtemsBarrierReqCreate_Post_Status_InvAddr,
681    RtemsBarrierReqCreate_Post_Name_Invalid,
682    RtemsBarrierReqCreate_Post_Class_NoObj,
683    RtemsBarrierReqCreate_Post_IdValue_Unchanged
684  }, {
685    RtemsBarrierReqCreate_Post_Status_InvAddr,
686    RtemsBarrierReqCreate_Post_Name_Invalid,
687    RtemsBarrierReqCreate_Post_Class_NoObj,
688    RtemsBarrierReqCreate_Post_IdValue_Unchanged
689  }, {
690    RtemsBarrierReqCreate_Post_Status_Ok,
691    RtemsBarrierReqCreate_Post_Name_Valid,
692    RtemsBarrierReqCreate_Post_Class_Manual,
693    RtemsBarrierReqCreate_Post_IdValue_Assigned
694  }, {
695    RtemsBarrierReqCreate_Post_Status_TooMany,
696    RtemsBarrierReqCreate_Post_Name_Invalid,
697    RtemsBarrierReqCreate_Post_Class_NoObj,
698    RtemsBarrierReqCreate_Post_IdValue_Unchanged
699  }, {
700    RtemsBarrierReqCreate_Post_Status_InvAddr,
701    RtemsBarrierReqCreate_Post_Name_Invalid,
702    RtemsBarrierReqCreate_Post_Class_NoObj,
703    RtemsBarrierReqCreate_Post_IdValue_Unchanged
704  }, {
705    RtemsBarrierReqCreate_Post_Status_InvAddr,
706    RtemsBarrierReqCreate_Post_Name_Invalid,
707    RtemsBarrierReqCreate_Post_Class_NoObj,
708    RtemsBarrierReqCreate_Post_IdValue_Unchanged
709  }, {
710    RtemsBarrierReqCreate_Post_Status_InvNum,
711    RtemsBarrierReqCreate_Post_Name_Invalid,
712    RtemsBarrierReqCreate_Post_Class_NoObj,
713    RtemsBarrierReqCreate_Post_IdValue_Unchanged
714  }, {
715    RtemsBarrierReqCreate_Post_Status_InvNum,
716    RtemsBarrierReqCreate_Post_Name_Invalid,
717    RtemsBarrierReqCreate_Post_Class_NoObj,
718    RtemsBarrierReqCreate_Post_IdValue_Unchanged
719  }, {
720    RtemsBarrierReqCreate_Post_Status_InvAddr,
721    RtemsBarrierReqCreate_Post_Name_Invalid,
722    RtemsBarrierReqCreate_Post_Class_NoObj,
723    RtemsBarrierReqCreate_Post_IdValue_Unchanged
724  }, {
725    RtemsBarrierReqCreate_Post_Status_InvAddr,
726    RtemsBarrierReqCreate_Post_Name_Invalid,
727    RtemsBarrierReqCreate_Post_Class_NoObj,
728    RtemsBarrierReqCreate_Post_IdValue_Unchanged
729  }, {
730    RtemsBarrierReqCreate_Post_Status_Ok,
731    RtemsBarrierReqCreate_Post_Name_Valid,
732    RtemsBarrierReqCreate_Post_Class_Auto,
733    RtemsBarrierReqCreate_Post_IdValue_Assigned
734  }, {
735    RtemsBarrierReqCreate_Post_Status_TooMany,
736    RtemsBarrierReqCreate_Post_Name_Invalid,
737    RtemsBarrierReqCreate_Post_Class_NoObj,
738    RtemsBarrierReqCreate_Post_IdValue_Unchanged
739  }, {
740    RtemsBarrierReqCreate_Post_Status_InvAddr,
741    RtemsBarrierReqCreate_Post_Name_Invalid,
742    RtemsBarrierReqCreate_Post_Class_NoObj,
743    RtemsBarrierReqCreate_Post_IdValue_Unchanged
744  }, {
745    RtemsBarrierReqCreate_Post_Status_InvAddr,
746    RtemsBarrierReqCreate_Post_Name_Invalid,
747    RtemsBarrierReqCreate_Post_Class_NoObj,
748    RtemsBarrierReqCreate_Post_IdValue_Unchanged
749  }, {
750    RtemsBarrierReqCreate_Post_Status_InvName,
751    RtemsBarrierReqCreate_Post_Name_Invalid,
752    RtemsBarrierReqCreate_Post_Class_NoObj,
753    RtemsBarrierReqCreate_Post_IdValue_Unchanged
754  }, {
755    RtemsBarrierReqCreate_Post_Status_InvName,
756    RtemsBarrierReqCreate_Post_Name_Invalid,
757    RtemsBarrierReqCreate_Post_Class_NoObj,
758    RtemsBarrierReqCreate_Post_IdValue_Unchanged
759  }, {
760    RtemsBarrierReqCreate_Post_Status_InvName,
761    RtemsBarrierReqCreate_Post_Name_Invalid,
762    RtemsBarrierReqCreate_Post_Class_NoObj,
763    RtemsBarrierReqCreate_Post_IdValue_Unchanged
764  }, {
765    RtemsBarrierReqCreate_Post_Status_InvName,
766    RtemsBarrierReqCreate_Post_Name_Invalid,
767    RtemsBarrierReqCreate_Post_Class_NoObj,
768    RtemsBarrierReqCreate_Post_IdValue_Unchanged
769  }, {
770    RtemsBarrierReqCreate_Post_Status_InvName,
771    RtemsBarrierReqCreate_Post_Name_Invalid,
772    RtemsBarrierReqCreate_Post_Class_NoObj,
773    RtemsBarrierReqCreate_Post_IdValue_Unchanged
774  }, {
775    RtemsBarrierReqCreate_Post_Status_InvName,
776    RtemsBarrierReqCreate_Post_Name_Invalid,
777    RtemsBarrierReqCreate_Post_Class_NoObj,
778    RtemsBarrierReqCreate_Post_IdValue_Unchanged
779  }, {
780    RtemsBarrierReqCreate_Post_Status_InvName,
781    RtemsBarrierReqCreate_Post_Name_Invalid,
782    RtemsBarrierReqCreate_Post_Class_NoObj,
783    RtemsBarrierReqCreate_Post_IdValue_Unchanged
784  }, {
785    RtemsBarrierReqCreate_Post_Status_InvName,
786    RtemsBarrierReqCreate_Post_Name_Invalid,
787    RtemsBarrierReqCreate_Post_Class_NoObj,
788    RtemsBarrierReqCreate_Post_IdValue_Unchanged
789  }, {
790    RtemsBarrierReqCreate_Post_Status_InvName,
791    RtemsBarrierReqCreate_Post_Name_Invalid,
792    RtemsBarrierReqCreate_Post_Class_NoObj,
793    RtemsBarrierReqCreate_Post_IdValue_Unchanged
794  }, {
795    RtemsBarrierReqCreate_Post_Status_InvName,
796    RtemsBarrierReqCreate_Post_Name_Invalid,
797    RtemsBarrierReqCreate_Post_Class_NoObj,
798    RtemsBarrierReqCreate_Post_IdValue_Unchanged
799  }, {
800    RtemsBarrierReqCreate_Post_Status_InvName,
801    RtemsBarrierReqCreate_Post_Name_Invalid,
802    RtemsBarrierReqCreate_Post_Class_NoObj,
803    RtemsBarrierReqCreate_Post_IdValue_Unchanged
804  }, {
805    RtemsBarrierReqCreate_Post_Status_InvName,
806    RtemsBarrierReqCreate_Post_Name_Invalid,
807    RtemsBarrierReqCreate_Post_Class_NoObj,
808    RtemsBarrierReqCreate_Post_IdValue_Unchanged
809  }, {
810    RtemsBarrierReqCreate_Post_Status_InvName,
811    RtemsBarrierReqCreate_Post_Name_Invalid,
812    RtemsBarrierReqCreate_Post_Class_NoObj,
813    RtemsBarrierReqCreate_Post_IdValue_Unchanged
814  }, {
815    RtemsBarrierReqCreate_Post_Status_InvName,
816    RtemsBarrierReqCreate_Post_Name_Invalid,
817    RtemsBarrierReqCreate_Post_Class_NoObj,
818    RtemsBarrierReqCreate_Post_IdValue_Unchanged
819  }, {
820    RtemsBarrierReqCreate_Post_Status_InvName,
821    RtemsBarrierReqCreate_Post_Name_Invalid,
822    RtemsBarrierReqCreate_Post_Class_NoObj,
823    RtemsBarrierReqCreate_Post_IdValue_Unchanged
824  }, {
825    RtemsBarrierReqCreate_Post_Status_InvName,
826    RtemsBarrierReqCreate_Post_Name_Invalid,
827    RtemsBarrierReqCreate_Post_Class_NoObj,
828    RtemsBarrierReqCreate_Post_IdValue_Unchanged
829  }, {
830    RtemsBarrierReqCreate_Post_Status_InvName,
831    RtemsBarrierReqCreate_Post_Name_Invalid,
832    RtemsBarrierReqCreate_Post_Class_NoObj,
833    RtemsBarrierReqCreate_Post_IdValue_Unchanged
834  }, {
835    RtemsBarrierReqCreate_Post_Status_InvName,
836    RtemsBarrierReqCreate_Post_Name_Invalid,
837    RtemsBarrierReqCreate_Post_Class_NoObj,
838    RtemsBarrierReqCreate_Post_IdValue_Unchanged
839  }, {
840    RtemsBarrierReqCreate_Post_Status_InvName,
841    RtemsBarrierReqCreate_Post_Name_Invalid,
842    RtemsBarrierReqCreate_Post_Class_NoObj,
843    RtemsBarrierReqCreate_Post_IdValue_Unchanged
844  }, {
845    RtemsBarrierReqCreate_Post_Status_InvName,
846    RtemsBarrierReqCreate_Post_Name_Invalid,
847    RtemsBarrierReqCreate_Post_Class_NoObj,
848    RtemsBarrierReqCreate_Post_IdValue_Unchanged
849  }, {
850    RtemsBarrierReqCreate_Post_Status_InvName,
851    RtemsBarrierReqCreate_Post_Name_Invalid,
852    RtemsBarrierReqCreate_Post_Class_NoObj,
853    RtemsBarrierReqCreate_Post_IdValue_Unchanged
854  }, {
855    RtemsBarrierReqCreate_Post_Status_InvName,
856    RtemsBarrierReqCreate_Post_Name_Invalid,
857    RtemsBarrierReqCreate_Post_Class_NoObj,
858    RtemsBarrierReqCreate_Post_IdValue_Unchanged
859  }, {
860    RtemsBarrierReqCreate_Post_Status_InvName,
861    RtemsBarrierReqCreate_Post_Name_Invalid,
862    RtemsBarrierReqCreate_Post_Class_NoObj,
863    RtemsBarrierReqCreate_Post_IdValue_Unchanged
864  }, {
865    RtemsBarrierReqCreate_Post_Status_InvName,
866    RtemsBarrierReqCreate_Post_Name_Invalid,
867    RtemsBarrierReqCreate_Post_Class_NoObj,
868    RtemsBarrierReqCreate_Post_IdValue_Unchanged
869  }
870};
871
872static const struct {
873  uint8_t Skip : 1;
874  uint8_t Pre_Name_NA : 1;
875  uint8_t Pre_Class_NA : 1;
876  uint8_t Pre_MaxWait_NA : 1;
877  uint8_t Pre_Id_NA : 1;
878  uint8_t Pre_Free_NA : 1;
879} RtemsBarrierReqCreate_TransitionInfo[] = {
880  {
881    0, 0, 0, 0, 0, 0
882  }, {
883    0, 0, 0, 0, 0, 0
884  }, {
885    0, 0, 0, 0, 0, 0
886  }, {
887    0, 0, 0, 0, 0, 0
888  }, {
889    0, 0, 0, 0, 0, 0
890  }, {
891    0, 0, 0, 0, 0, 0
892  }, {
893    0, 0, 0, 0, 0, 0
894  }, {
895    0, 0, 0, 0, 0, 0
896  }, {
897    0, 0, 0, 0, 0, 0
898  }, {
899    0, 0, 0, 0, 0, 0
900  }, {
901    0, 0, 0, 0, 0, 0
902  }, {
903    0, 0, 0, 0, 0, 0
904  }, {
905    0, 0, 0, 0, 0, 0
906  }, {
907    0, 0, 0, 0, 0, 0
908  }, {
909    0, 0, 0, 0, 0, 0
910  }, {
911    0, 0, 0, 0, 0, 0
912  }, {
913    0, 0, 0, 0, 0, 0
914  }, {
915    0, 0, 0, 0, 0, 0
916  }, {
917    0, 0, 0, 0, 0, 0
918  }, {
919    0, 0, 0, 0, 0, 0
920  }, {
921    0, 0, 0, 0, 0, 0
922  }, {
923    0, 0, 0, 0, 0, 0
924  }, {
925    0, 0, 0, 0, 0, 0
926  }, {
927    0, 0, 0, 0, 0, 0
928  }, {
929    0, 0, 0, 0, 0, 0
930  }, {
931    0, 0, 0, 0, 0, 0
932  }, {
933    0, 0, 0, 0, 0, 0
934  }, {
935    0, 0, 0, 0, 0, 0
936  }, {
937    0, 0, 0, 0, 0, 0
938  }, {
939    0, 0, 0, 0, 0, 0
940  }, {
941    0, 0, 0, 0, 0, 0
942  }, {
943    0, 0, 0, 0, 0, 0
944  }, {
945    0, 0, 0, 0, 0, 0
946  }, {
947    0, 0, 0, 0, 0, 0
948  }, {
949    0, 0, 0, 0, 0, 0
950  }, {
951    0, 0, 0, 0, 0, 0
952  }, {
953    0, 0, 0, 0, 0, 0
954  }, {
955    0, 0, 0, 0, 0, 0
956  }, {
957    0, 0, 0, 0, 0, 0
958  }, {
959    0, 0, 0, 0, 0, 0
960  }, {
961    0, 0, 0, 0, 0, 0
962  }, {
963    0, 0, 0, 0, 0, 0
964  }, {
965    0, 0, 0, 0, 0, 0
966  }, {
967    0, 0, 0, 0, 0, 0
968  }, {
969    0, 0, 0, 0, 0, 0
970  }, {
971    0, 0, 0, 0, 0, 0
972  }, {
973    0, 0, 0, 0, 0, 0
974  }, {
975    0, 0, 0, 0, 0, 0
976  }
977};
978
979static void RtemsBarrierReqCreate_Action( RtemsBarrierReqCreate_Context *ctx )
980{
981  ctx->status = rtems_barrier_create(
982    ctx->name,
983    ctx->attribute_set,
984    ctx->maximum_waiters,
985    ctx->id
986  );
987}
988
989static void RtemsBarrierReqCreate_Cleanup( RtemsBarrierReqCreate_Context *ctx )
990{
991  if ( ctx->id_value != INVALID_ID ) {
992    rtems_status_code sc;
993
994    sc = rtems_barrier_delete( ctx->id_value );
995    T_rsc_success( sc );
996
997    ctx->id_value = INVALID_ID;
998  }
999
1000  T_surrender_objects( &ctx->seized_objects, rtems_barrier_delete );
1001}
1002
1003/**
1004 * @fn void T_case_body_RtemsBarrierReqCreate( void )
1005 */
1006T_TEST_CASE_FIXTURE( RtemsBarrierReqCreate, &RtemsBarrierReqCreate_Fixture )
1007{
1008  RtemsBarrierReqCreate_Context *ctx;
1009  size_t index;
1010
1011  ctx = T_fixture_context();
1012  ctx->in_action_loop = true;
1013  index = 0;
1014
1015  for (
1016    ctx->pcs[ 0 ] = RtemsBarrierReqCreate_Pre_Name_Valid;
1017    ctx->pcs[ 0 ] < RtemsBarrierReqCreate_Pre_Name_NA;
1018    ++ctx->pcs[ 0 ]
1019  ) {
1020    if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Name_NA ) {
1021      ctx->pcs[ 0 ] = RtemsBarrierReqCreate_Pre_Name_NA;
1022      index += ( RtemsBarrierReqCreate_Pre_Name_NA - 1 )
1023        * RtemsBarrierReqCreate_Pre_Class_NA
1024        * RtemsBarrierReqCreate_Pre_MaxWait_NA
1025        * RtemsBarrierReqCreate_Pre_Id_NA
1026        * RtemsBarrierReqCreate_Pre_Free_NA;
1027    }
1028
1029    for (
1030      ctx->pcs[ 1 ] = RtemsBarrierReqCreate_Pre_Class_Default;
1031      ctx->pcs[ 1 ] < RtemsBarrierReqCreate_Pre_Class_NA;
1032      ++ctx->pcs[ 1 ]
1033    ) {
1034      if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Class_NA ) {
1035        ctx->pcs[ 1 ] = RtemsBarrierReqCreate_Pre_Class_NA;
1036        index += ( RtemsBarrierReqCreate_Pre_Class_NA - 1 )
1037          * RtemsBarrierReqCreate_Pre_MaxWait_NA
1038          * RtemsBarrierReqCreate_Pre_Id_NA
1039          * RtemsBarrierReqCreate_Pre_Free_NA;
1040      }
1041
1042      for (
1043        ctx->pcs[ 2 ] = RtemsBarrierReqCreate_Pre_MaxWait_Zero;
1044        ctx->pcs[ 2 ] < RtemsBarrierReqCreate_Pre_MaxWait_NA;
1045        ++ctx->pcs[ 2 ]
1046      ) {
1047        if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_MaxWait_NA ) {
1048          ctx->pcs[ 2 ] = RtemsBarrierReqCreate_Pre_MaxWait_NA;
1049          index += ( RtemsBarrierReqCreate_Pre_MaxWait_NA - 1 )
1050            * RtemsBarrierReqCreate_Pre_Id_NA
1051            * RtemsBarrierReqCreate_Pre_Free_NA;
1052        }
1053
1054        for (
1055          ctx->pcs[ 3 ] = RtemsBarrierReqCreate_Pre_Id_Valid;
1056          ctx->pcs[ 3 ] < RtemsBarrierReqCreate_Pre_Id_NA;
1057          ++ctx->pcs[ 3 ]
1058        ) {
1059          if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Id_NA ) {
1060            ctx->pcs[ 3 ] = RtemsBarrierReqCreate_Pre_Id_NA;
1061            index += ( RtemsBarrierReqCreate_Pre_Id_NA - 1 )
1062              * RtemsBarrierReqCreate_Pre_Free_NA;
1063          }
1064
1065          for (
1066            ctx->pcs[ 4 ] = RtemsBarrierReqCreate_Pre_Free_Yes;
1067            ctx->pcs[ 4 ] < RtemsBarrierReqCreate_Pre_Free_NA;
1068            ++ctx->pcs[ 4 ]
1069          ) {
1070            if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Pre_Free_NA ) {
1071              ctx->pcs[ 4 ] = RtemsBarrierReqCreate_Pre_Free_NA;
1072              index += ( RtemsBarrierReqCreate_Pre_Free_NA - 1 );
1073            }
1074
1075            if ( RtemsBarrierReqCreate_TransitionInfo[ index ].Skip ) {
1076              ++index;
1077              continue;
1078            }
1079
1080            RtemsBarrierReqCreate_Pre_Name_Prepare( ctx, ctx->pcs[ 0 ] );
1081            RtemsBarrierReqCreate_Pre_Class_Prepare( ctx, ctx->pcs[ 1 ] );
1082            RtemsBarrierReqCreate_Pre_MaxWait_Prepare( ctx, ctx->pcs[ 2 ] );
1083            RtemsBarrierReqCreate_Pre_Id_Prepare( ctx, ctx->pcs[ 3 ] );
1084            RtemsBarrierReqCreate_Pre_Free_Prepare( ctx, ctx->pcs[ 4 ] );
1085            RtemsBarrierReqCreate_Action( ctx );
1086            RtemsBarrierReqCreate_Post_Status_Check(
1087              ctx,
1088              RtemsBarrierReqCreate_TransitionMap[ index ][ 0 ]
1089            );
1090            RtemsBarrierReqCreate_Post_Name_Check(
1091              ctx,
1092              RtemsBarrierReqCreate_TransitionMap[ index ][ 1 ]
1093            );
1094            RtemsBarrierReqCreate_Post_Class_Check(
1095              ctx,
1096              RtemsBarrierReqCreate_TransitionMap[ index ][ 2 ]
1097            );
1098            RtemsBarrierReqCreate_Post_IdValue_Check(
1099              ctx,
1100              RtemsBarrierReqCreate_TransitionMap[ index ][ 3 ]
1101            );
1102            RtemsBarrierReqCreate_Cleanup( ctx );
1103            ++index;
1104          }
1105        }
1106      }
1107    }
1108  }
1109}
1110
1111/** @} */
Note: See TracBrowser for help on using the repository browser.